Question

I have read around on this, including Nehe and here for solutions, but I cant find a specific answer.

I am trying to load a a photo, called stars.jpg. I want to make this my background of the scene, by mapping it using uv coordinates, doing it by

glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex2f(0,0);

However I am just very confused about how to load the actual textures in, all the calls for

glActiveTexture();
glEnable(GL_TEXTURE_2d);
glBindTexture(GL_TEXTURE);

All they do is confuse me, what do all these mean/do, and in what order am I suppose to put these in, in order to get the stars.jpg to be my background?

Was it helpful?

Solution

Here's a step by step tutorial on loading textures
http://www.nullterminator.net/gltexture.html

Its important to remember that OpenGL is a state machine, so you have to tell it "I'm going to talk about textures now" that's where the glActiveTexture(); comes in.

Also keep in mind that you will have to load in pixel by pixel the colors from your .jpg (compressed) to your texture array, so either you will need to find a library that will give you bitmap values of your .jpg file or you will need to pre-convert it into a .ppm or a .bmp which will make reading in the values easier.

OTHER TIPS

Your number-one tool for loading textures in OpenGL is the Simple OpenGL Image Loader (SOIL) library. You just need to pass the filename and some flags and you'll get your texture ID.

Also, you're learning very old and outdated version of OpenGL now - you might want to have a google for newer tutorials or browse the specs whenever you feel ready.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top