Archived

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

Loading GL Textures with SDL_Surface and SDL_LoadBMP

This topic is 5312 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

I was able to successfully load a texture into OpenGL using SDL_Surface and SDL_LoadBMP but when I render it, I get some brown-coloured texture instead of the original colour of the image, which is blue. How do I solve this?

Share this post


Link to post
Share on other sites
glColor3f(1,1,1);

or

glColor4f(1,1,1,1);

--- Edit ---
If that doesn't work, try inverting the r,b values of the bitmap. Windows normally uses BGR, while OpenGL (and everything else) uses RGB, so it might just be a matter of going through the bitmap and swapping the b,r components.

[edited by - Ready4Dis on May 29, 2003 6:57:53 AM]

Share this post


Link to post
Share on other sites
Welcome to the joyousness of the Win32 BMP format...

Rather than using an RGB system for storing 24-color bitmaps, it reverses them - BGR.

All you have to do is change the format flag on glTex*Image2D() from GL_RGB to GL_BGR_EXT. It''s a Win32-specific extension, so you might need to change it for other platforms, but it works under Win32.

Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.

Share this post


Link to post
Share on other sites
quote:
Original post by superpig
It''s a Win32-specific extension, so you might need to change it for other platforms, but it works under Win32.

It''s not Windows-specific. And it''s actually been part of the core OpenGL spec since 1.2, so you can use it on any platform that''s 1.2-compliant.

Share this post


Link to post
Share on other sites