Im trying to show some textures in my program, and I have this code thats used to load bitmaps into openGL textures:
void LoadGLTextures()
{
// Bitmap handle and structure
HBITMAP hBMP;
BITMAP BMP;
// Generate list of textures from resources
byte Texture[] = {IDB_FONT, IDB_SKIN, IDB_PIANO};
glGenTextures(sizeof(Texture), &texture[0]);
// Iterate through texture list and load bitmaps
for (int loop=0; loop<sizeof(Texture); loop++)
{
hBMP = (HBITMAP)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(Texture[loop]),
IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
if (hBMP)
{
GetObject(hBMP,sizeof(BMP), &BMP);
glPixelStorei(GL_UNPACK_ALIGNMENT,4);
glBindTexture(GL_TEXTURE_2D, texture[loop]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
// Generate Mipmapped Texture (3 Bytes, Width, Height And Data From The BMP)
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, BMP.bmWidth, BMP.bmHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE, BMP.bmBits);
DeleteObject(hBMP);
}
}
And while my background skin loads, and gets drawn correctly, the other (piano) texture doesn't get drawn. Im sure the drawing code is correct because when i swap which texture is used (from the piano to the background texture, in this case), the other texture gets drawn. So i think the bitmap isn't being loaded correctly. But im not sure why? Is there something glaringly obvious i have overlooked?
The bitmap is 128*256 and 24 bit colour.
If you need any of the other code please let me know.
edit - If anyone knows of any librarys that would do what I require, please let me know