Q: How to load an png image in openGL and move it by using the mouse? How can I load an image in openGL? How can I transfer the image data to the data that openGL can understand?

A: I'll break it into steps:


*

*Read the file contents into memory

*Decode the file to raw format required (RGB or RGBA)

*Create OpenGL texture object and give the raw image data to OpenGL

*Construct OpenGL primitive with appropriate texture coordinates and vertices positions.

*Bind the texture to appropriate texture unit and use a sampler object to use the texture data to produce final color.


6. Profit!
Step 1, 2 and 3 can be easily changed to simple SOIL_load_texture call, if you want to use SOIL image library.

A: First you have to decode the image into an RGBA-array. See here:
https://en.wikipedia.org/wiki/libpng
Then you have to map it to an OpenGL-texture and display:
http://nehe.gamedev.net/tutorial/texture_mapping/12038/
