Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

KevArnold

Loading textures

This topic is 5700 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This may be less of an OpenGL problem and more of a windows problem but basically I use the following code (found in a previoous post) to load a texture from a resource: //---------------------------------------------------------------------------------------------------- // LoadBitmapResource: // // Loads a bitmap straight from resources //---------------------------------------------------------------------------------------------------- BYTE* LoadBitmapResource(int iResource, int* iTextureWidth, int* iTextureHeight) { // Find the bitmap resource HINSTANCE hInstance = GetModuleHandle(NULL); HANDLE hBitmap = LoadBitmap(hInstance, MAKEINTRESOURCE(iResource)); // Get the details BITMAPINFO bmInfo; GetObject(hBitmap, sizeof(BITMAPINFO), &bmInfo); DeleteObject(hBitmap); // Reload and save a the data hBitmap = LoadResource(hInstance, FindResource(hInstance,MAKEINTRESOURCE(iResource), RT_BITMAP)); BYTE* pTextureImage = (BYTE*)LockResource(hBitmap); // Shift the pointer on to the image data itself pTextureImage += sizeof(BITMAPINFO)-1; // Save the bitmap dimensions *iTextureWidth = bmInfo.bmiHeader.biWidth; *iTextureHeight = bmInfo.bmiHeader.biHeight; return pTextureImage; } //---------------------------------------------------------------------------------------------------- // LoadTexture: // // Loads bitmaps and converts them to textures //---------------------------------------------------------------------------------------------------- bool LoadTexture(int iResource, GLuint* piTexture) { // Set up a return value and image storage bool fSuccessful = false; // Set the data to catch the bmp resource details BYTE* pTextureImage = NULL; int iTextureWidth; int iTextureHeight; if (pTextureImage = LoadBitmapResource(iResource, &iTextureWidth, &iTextureHeight)) { glGenTextures(1, piTexture); // Create Linear Filtered Texture glBindTexture(GL_TEXTURE_2D, *piTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, 3, iTextureWidth, iTextureHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, pTextureImage); // Mark the success fSuccessful = true; } return fSuccessful; } I don''t think the problem is related to OpenGL though because when I trace it the bmp structure says that the BMP is 392 x 192 which isn''t true, the bitmap is 128x128. Is there a reason this may be happening? thanks

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!