Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: glGenTextures question

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2011
    Posts
    13

    glGenTextures question

    Is the first texture name returned from glGenTextures always guaranteed to be 1 for the first call in your program?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,128
    In the 4.2 core spec it says nothing about it. So in general, you shouldn't rely on the first name being one. Still, in my experience implementations tend to start with 1 and increment the following unused handles by one. This will of course not be valid if you have allocated space for objects 1-5, for instance, delete object 1, and then allocate space for two new objects. They will most likely be named 1 and 6.

    Why does it matter? You're supposed to remember the name anyway since you can't really clean up yourself without knowing the name.

  3. #3
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,264
    It sounds like you are a hard coder. Do not do that. Do not rely on predefined behavior. It is bad programming. For this texture case, make a texture class and create an object for each texture you'll be creating. Let your class hold the value returned by glGenTextures. You should not care what that value is.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,128
    Adding to V-Man suggestion, which is a good one in an OO framework, DON'T use the destructor to call glDeleteTextures! If you create a temporary object you texture object will be destroyed once the object goes out of scope. You might want to check out the common mistakes wiki: http://www.opengl.org/wiki/Common_Mi...nguage_Problem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •