question on texture maping

Im having a hard time seeing how a texture is bound. Example:

unsigned int texturedata[1];
.....
texture=LoadBMP("example.bmp");
glGenTextures(1,&texturedata);
glBindTexture(GL_TEXTURE_2D, texturedata[0]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, texture);
......

What I dont understand is how the texture name texturedata[0] is related to the data texture? I was looking at the nehe code for lesson 6 and they delete the data right after binding which really throws me off more, if someone could please explain thanks.

your variable names are adding to your confusion.

“texturedata[0]” is actually the name (identifier) for your texture, whereas the variable “texture” is the actual texture data.

BindTexture creates a texture object with the name which was returned by GenTextures. TexImage populates the texture object with a texture of the given dimensions and texel data.

after the TexImage call you no longer need “texture” because the GL now has a copy of the texture data, in a texture object identified by texturedata[0].

Those variable names were just from an example. I understand what each one is doing. I know that texturedata holds the name that is generated by glGenTextures and that texture is the image data. What im failing to see is how the name in texturedata[0] is bound to the image data texture, what I think happens is that glBindTexture tells gl which texture im using? and then the call to glTexImage2D stores the image data to the currently selected name?

exactly :wink: and then later in your program when you bind a texture, then that data is used.