Original Post
Greetings I am working on a wrapper for textures, but for some reason the textures are not showin up. Heres some of the code for it: then I have RenderScene() which looks like: However, the square is still just white. Whats happening? Note, angsty is 218 by 212. This shouldnt be a problem because I'm mipmapping. Also, even if I dont use mipmap it still doesnt show up. This is probably a stupid error that you will notice pretty fast. Thanks.
bool CTexture::CreateTexture(tString filename)
{
AUX_RGBImageRec *textureImage = NULL;
// Create the texture
textureImage = LoadBitmap(filename);
if(!textureImage)
return false;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, textureImage->sizeX, textureImage->sizeY, GL_RGB,
GL_UNSIGNED_BYTE, textureImage->data);
if(textureImage->data)
free(textureImage->data);
free(textureImage);
return true;
}
void CTexture::Bind()
{
// Bind the texture
glBindTexture(GL_TEXTURE_2D, texture);
}
void EnableTextures()
{
if(!glIsEnabled(GL_TEXTURE_2D))
glEnable(GL_TEXTURE_2D);
}
void DisableTextures()
{
if(glIsEnabled(GL_TEXTURE_2D))
glDisable(GL_TEXTURE_2D);
}
void RenderScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0, 0.0, -6.0f);
EnableTextures();
angsty.Bind();
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left
glTexCoord2f(1.0f, 1.0f); glVertex3f(1.0f, 1.0f, 0.0f); // Top Right
glTexCoord2f(1.0f, 0.0f); glVertex3f(1.0f, -1.0f, 0.0f); // Bottom Right
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom left
glEnd();
}