I am having some major issues with OpenGL textures. I have the following code to load a glTexture (typedef ed as a GLuint):
glTexture LoadBMP(const char *fname)
{
HBITMAP hBMP;
BITMAP BMP;
glTexture texid;
glGenTextures(1, &texid);
hBMP=(HBITMAP)LoadImage(GetModuleHandle(NULL), fname, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE );
if (!hBMP)
return NULL;
GetObject(hBMP, sizeof(BMP), &BMP);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glBindTexture(GL_TEXTURE_2D, texid); // Bind To The Texture ID
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Linear Min Filter
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Mag Filter
glTexImage2D(GL_TEXTURE_2D, 0, 3, BMP.bmWidth, BMP.bmHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, BMP.bmBits);
DeleteObject(hBMP); // Delete The Object
return texid; // Loading Was Successful
}
It works but for some reason it causes all of my drawings to get dark.
Here are 2 links to my program running, both with and without a texture:
Without a texture: http://i1221.photobucket.com/albums/dd464/lambdabeta/goodgl.jpg
With a texture: http://i1221.photobucket.com/albums/dd464/lambdabeta/badgl.jpg
Does anybody know what is causing the colour mix up?