Loading images in Opengl

Started by
4 comments, last by musicon 11 years, 11 months ago
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.
Advertisement
I always used DevIL for all my projects and it works great.
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.
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 here 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.

+---------------------------------------------------------------------+

| Game Dev video tutorials -> http://www.youtube.com/goranmilovano | +---------------------------------------------------------------------+
Does anyone know a reliable place to download Devil? Unless I'm missing something I'm not getting any meaningful files installed.
Never mind. I've got SDL up and running so may not need Devil.

This topic is closed to new replies.

Advertisement