PDA

View Full Version : textureloading



apocalexiz
08-07-2003, 09:27 PM
hy there

i read the nehe tut no. 6 for understanding texture loading...but there is something i dont understood completely

he is loading the texture data in the function

int LoadGLTextures()

after this he was calling the standardfunctions for creating a texture...but then...he free's the allocated memory completely

now to my questions...
if ive done the following...

glGenTextures(1, &texture[0]);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);

...filtering func's...

what happens to opengl... cause nehe is deleting the image data... so i guess opengl does a copy of the data and assigning it to the texture[0] array value... is the value in the texture array an adress to a memory location???

i only want a detailed explanation what opengl does if i try to generate a texture http://www.opengl.org/discussion_boards/ubb/smile.gif

hope someone can help

bye

apo

Andrea Rossini
08-07-2003, 10:01 PM
texture[] is an array of texture names
and many times if texture is filled with
glGenTextures (supposed there are not textures currently loaded) it happens that:

texture[i] == i

it doesn't matter the values stored in this array any way..
if you want to access your texture #i

just call glBindTexture passing texture[i] as texture name
-------------------------------------
Then the tutorial deletes the texture data because OpenGL creates a copy of the tex inside the graphic memory or elsewhere if it runs out.

I hope I been of help

nexusone
08-08-2003, 05:03 AM
When you load a texture, it is in some format like BMP, TGA, etc.

First thing done is the image is read into a temp storage and decoded in a format that openGL can understand.

Once in a format that openGL can read, then we need to tell openGL that it is a texture.

glGenTextures // Set's up a name in which we can identify then new texture, done internal of opengl

glBindTexture // Tell openGL to use the generated name, with this texture.

glTexImage2D // Load the texture

Now openGL manages the textures ether putting them in the video cards memory or some other memory location, we call the texture by using the name (id) that openGL generated for us.

That is why in the NeHe tutor he deletes the one texture variable; since it is no longer needed and that texture is now in another location managed by openGL.

apocalexiz
08-08-2003, 06:22 AM
ahh...thx http://www.opengl.org/discussion_boards/ubb/smile.gif i wasnt sure if iam able to delete the imagedata...now iam

bye

apo