View Full Version : Loading an image

Erin C.
11-01-2008, 04:05 PM
Hi there,
For a project, I need to load an image (png, jpeg, doesn't really matter) and display it in my window. Then I need to make it move across the screen, etc.

What library will be best for loading the image? I've looked into freeimage, but I couldn't figure out how to display the image once it was loaded.


11-01-2008, 04:24 PM
To load and use a 2D texture in opengl you need to:

1) Load image data into system memory
2) Generate a texture name with glGenTextures
3) Bind the texture name with gBindTexture
4) Set wrapping and filtering mode with glTexParameter
5) call glTexImage2D with the right parameters depending on the image nature to load image data into video memory

Finally just bind the texture before drawing it onto a quad.

Look at opengl man pages (http://www.opengl.org/sdk/docs/man/) for more information about all these functions.

11-01-2008, 04:29 PM
You can also look at the opengl wiki page and here (http://www.opengl.org/wiki/index.php/Texture_Mapping) for texture mapping.

11-02-2008, 04:28 AM
try this (http://www.flashbang.se/download/nehe_tga.rar) one i made for nehe.gamedev.net