Sign in to follow this  
musicon

Loading images in Opengl

Recommended Posts

Sorry if this has come up a gazillion times but I really need some help loading images/photos in Opengl/GLUT. I can do vector graphics but loading pre taken images (bmp/png/jpeg etc.) seem a real pitfall and more complicated than I had hoped.

To show what I have tried already I found out about Devil but I downloaded it and found nothing other than an uninstall file. Also much advice I found is from quite a few years ago and is probably outdated (eg NeHe tuts using the Glaux library - now deprecated). So basically what is the current best online tutorial or books for this?

My first project I have set myself is a Pong game in Opengl (already done in XNA), then onto shooter type games.

Also I use MSVC++ Express 2010 if that helps. Edited by musicon

Share this post


Link to post
Share on other sites
The rendering APIs themselves, both OpenGL and Direct3D, do not support loading images directly. You are still responsible for loading your textures.

There are libraries such as DevIL and SDL that do all the work of decoding images for you.

If possible you should try to get your textures in a natively-supported format, such as DXT1 or DXT5. Since those are hardware supported on all machines that matter to you, you can simply feed the data directly to the card instead of spending your time learning how to decode the hundreds of jpeg variants.

Share this post


Link to post
Share on other sites
I used SDL with SDL_image to load in a wide variety of different image formats, and it worked really well for me.

There's a basic tutorial [url="http://content.gpwiki.org/index.php/SDL:Tutorials:Using_SDL_with_OpenGL"]here[/url] for loading in a .bmp, but it's essentially the same procedure with SDL_image - you get back an SDL_Surface and you send it to the GPU via glTexImage2D.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this