🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

texture not showing up

Started by
1 comment, last by rick_appleton 19 years, 7 months ago
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?
Advertisement
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.
Yup, that was it. I thought the default was LINEAR or NEAREST so I hadn't set it up yet.

Thanks a lot.

This topic is closed to new replies.

Advertisement