Exemple #1
0
GLuint FTTextureFontImpl::CreateTexture()
{
	CalculateTextureSize();

    int totalMemory = textureWidth * textureHeight;
    unsigned char* textureMemory = new unsigned char[totalMemory];
    memset(textureMemory, 0, totalMemory);
	
    GLuint textID;
    glGenTextures(1, (GLuint*)&textID);

    glBindTexture(GL_TEXTURE_2D, textID);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, textureWidth, textureHeight,
                 0, GL_ALPHA, GL_UNSIGNED_BYTE, textureMemory);
	
	printf("texture dimensions: %d %d\n", textureWidth, textureHeight);
	
    delete [] textureMemory;

    return textID;
}
GLuint FTGLTextureFont::CreateTexture() {
	CalculateTextureSize();

	int totalMemory = textureWidth * textureHeight;
	unsigned char* textureMemory = new unsigned char[totalMemory];
	memset (textureMemory, 0, totalMemory);

	GLuint textID;
	glGenTextures (1, (GLuint*)&textID);

	glBindTexture (GL_TEXTURE_2D, textID);
#ifdef USE_GLES1
	glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
#else
	glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
	glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
#endif
	glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

	glTexImage2D (GL_TEXTURE_2D, 0, GL_ALPHA, textureWidth, textureHeight, 0,
				  GL_ALPHA, GL_UNSIGNED_BYTE, textureMemory);

	delete [] textureMemory;
	return textID;
}