Results 1 to 4 of 4

Thread: textureloading

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2003
    Posts
    26

    textureloading

    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

    hope someone can help

    bye

    apo

  2. #2
    Member Contributor
    Join Date
    Feb 2002
    Location
    Italia
    Posts
    63

    Re: textureloading

    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

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: textureloading

    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.

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2003
    Posts
    26

    Re: textureloading

    ahh...thx i wasnt sure if iam able to delete the imagedata...now iam

    bye

    apo

Similar Threads

  1. again textureloading...
    By apocalexiz in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 08-10-2003, 12:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean