View Full Version : Building textures from any image file format

11-29-2001, 10:23 PM
Hello to you reader!
I wanted to ask you how textures are initialized. I mean, if i have the code for reading all the info included in an image file (*.png,*.jpg,*.pcx,etc.), how can i use it for building an OpenGL texture.
Is there a standard way of doing things before reading the image file, and after that, for building a texture?
Something like Display Lists.
In DL first you have to gen the list, then to compile it and after that you draw things normally. When you finish you glEnd... the list. Is there a similar way for building textures in OpenGL. Is there a standard initialization code, after you put all the image info somewhere (i don't know where) and then you end the texture?

Forgive my terrible English.


11-29-2001, 10:50 PM
First you need to load the image from file, using whatever code you have. This should give you a buffer containing the data for the image. Next step is to ask OpenGL for a free texture ID. This is done with glGenTextures. Then you upload the texture to OpenGL. Now, to use the texture, just bind it and enable texturing. The texture will be used until you disable texturing.

Have a look in the Red Book (http://ask.ii.uib.no/ebt-bin/nph-dweb/dynaweb/SGI_Developer/OpenGL_PG/) , chapter 9 is about texturing.

11-30-2001, 12:06 AM
Thanks Bob!
I'll try it. The reason asking such a thing is because every texture i use, had been loaded with someone else library (like glPNG) and because i want to understand what i am using i wanted to know how to build my texture library.

Thanks again.