Results 1 to 2 of 2

Thread: Range of valid indices for glGenTextures, glGenBuffers

  1. #1
    Junior Member
    Join Date
    Jan 2013

    Range of valid indices for glGenTextures, glGenBuffers

    I'm programming OpenGL 1.1 ES in Android, i.e. using fixed pipeline.

    I'm using glGenTextures and glGenBuffers, which return an index in array (I use them only for one texture/buffer at a time). What is tha guaranteed range of this index?

    Empirically, I observed that valid indices start with 1, but documentation doesn't mention anything about it. Is the value 0 guaranteed to be invalid?

    I need it because sometimes I need to check if a texture/buffer was loaded already or not. If 0 can be valid, I need to initialize my values to -1 (to be able to detect that they are uninitialized/unloaded), but if 0 is invalid texture/buffer name, then things are easier.

    In Android, an int[] is filled, but in OpenGL ES API, I saw that there are GLUint values there. So I'm afraid that (in theory) even initializing to -1 in my Android program can be incorrect, because (in theory) an uint can return 0xFFFFFFFF.

    So what is the valid range, and what is the invalid range/value that I can be sure that it doesn't represent a valid texture/buffer name (index)?

  2. #2
    Join Date
    Jun 2012

    Re: Range of valid indices for glGenTextures, glGenBuffers

    This is covered in the Red Book:

    Naming A Texture Object
    Any nonzero unsigned integer may be used as a texture name. To avoid accidentally reusing names, consistently use
    glGenTextures() to provide unused texture names.
    void glGenTextures(GLsizei n, GLuint *textureNames);
    Returns n currently unused names for texture objects in the array textureNames. The names returned in
    textureNames do not have to be a contiguous set of integers.
    The names in textureNames are marked as used, but they acquire texture state and dimensionality (1D or 2D)
    only when they are first bound.
    Zero is a reserved texture name and is never returned as a texture name by glGenTextures().

    Regards, Clay

Similar Threads

  1. float4 and possible out of range?
    By sean.settle in forum OpenCL - parallel programming of heterogeneous systems
    Replies: 4
    Last Post: 02-02-2012, 09:48 PM
  2. glGenTextures and Java
    By uberbadger in forum OpenGL ES general technical discussions
    Replies: 7
    Last Post: 11-20-2007, 01:46 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