Skip to main content
GameDev.net gamedev.net
🔒 Locked

texture not showing up

Started by rick_appleton Nov 18, 2004 at 4:30 PM 1 replies 3k views
Original Post
rick_appleton
rick_appleton
I'm reading a .TGA file from file, and passing it to OpenGL with glTexImage2D. This works on my pc code, but on the Brew program the texture is not showing up. Drawing code:

int FaceData[9] =
{
  ITOFP(1), ITOFP(0), ITOFP(0),    // First vertex position
  ITOFP(0),  ITOFP(1), ITOFP(0),    // Second vertex position
  ITOFP(0),  ITOFP(0), FTOFP(1.5)    // Third vertex position
};
fixed TextureData[6] =
{
  FTOFP(0.f), FTOFP(0.f),
  FTOFP(1.f), FTOFP(0.f),
  FTOFP(0.f), FTOFP(1.f)
};
glTexEnvx(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, mTrackTexID);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(3, GL_FIXED, 0, FaceData);
glTexCoordPointer(2, GL_FIXED, 0, TextureData);
glDrawArrays( GL_TRIANGLES, 0, 3);
Texture loading code:

unsigned int texID;
int textureType = GL_RGB;
if(pImage->channels == 4)
  textureType = GL_RGBA;
glGenTextures(1, &(texID));
glBindTexture(GL_TEXTURE_2D, texID);

glTexImage2D(GL_TEXTURE_2D, 0, pImage->channels, pImage->width, pImage->height, 0, textureType, GL_UNSIGNED_BYTE, pImage->data);
I have verified the data in: - pImage->data (unsigned char's, correctly filled) - pImage->channels ( = 3, RGB) - pImage->width,height (=256) Can anyone see what I'm doing wrong?
Myopic Rhino
Myopic Rhino
It looks like you're using the default minification filter, which uses one of the mipmapping modes. By definition, if you try to use mipmapping without all the levels defined, it's as if texturing is disabled. Just set the minification filter to GL_LINEAR, and you'll be fine.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.