Hello,
I followed the NeHe tutorial here: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=24
I can load Targas and use them as textures but I’ve encountered a problem and I don’t know how to solve it.
The two images are using the same drawing code. The only difference is that the targa file in the first image was saved at 32 BPP and the targa in the second image was saved at 24 BPP.
There is no transparency in the image.
32 BPP:
24 BPP:
As you can see, the 24BPP file draws misaligned. The only change is a resave of the image at a different BPP.
Here is the code I’m using to draw:
glPushAttrib(GL_ALL_ATTRIB_BITS);
glLoadIdentity();
glColor4f(1.0f, 1.0f, 1.0f, mTransparency);
glBindTexture(GL_TEXTURE_2D, mTextureID[0]);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D); glEnable(GL_CULL_FACE);
if (mRotation){
glTranslatef(x, y + height, 0); // Move to bottom left of image
glRotatef(mRotation, 0, 0, 1);
glTranslatef(-x, -(y + height), 0.0f); // Reverse move
}
glTranslatef(x, y, 0);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2d(0, height + 1); // Bottom Left Of The Texture and Quad
glTexCoord2f(1.0f, 0.0f);
glVertex2d(width + 1, height + 1); // Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f);
glVertex2d(width + 1, 0); // Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f);
glVertex2d(0, 0); // Top Left Of The Texture and
glEnd();
glPopAttrib();
Can anyone tell me why this occurs?