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?