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 3 of 3

Thread: Question about glGenTextures / GLActiveTexture...

  1. #1
    Intern Contributor
    Join Date
    Jun 2009
    Posts
    68

    Question about glGenTextures / GLActiveTexture...

    So.. I know that using BindTexture after GlActiveTexture will bind that texture to whatever texture unit specified as an argument (ie. GL_TEXTURE0 + 2, or whatever..).. but if one doesn't call GlActiveTexture prior to binding a texture, is an active texture name still silently used in the background?

    I ask because I'm doing some work on some already heavily developed code, a little shader work that requires me to make a little GlActiveTexture calling and such, where some textures have already been generated by the time I'll be making this call and I'm trying to make sure I don't grab an already taken texture unit...

    If I use the id from glGenTextures and add that to GL_TEXTURE0, shouldn't that guarantee me a free texture? (ie:

    Code :
    	glGenTextures( 1, &id );
            glActiveTexture(GL_TEXTURE0 + id);

    that should keep me from having to worry about overwriting any prior texture units, right?

  2. #2
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,261

    Re: Question about glGenTextures / GLActiveTexture...

    Uwah, you've completely misunderstood texture-binding ^^"

    glActiveTexture() accepts values of GL_TEXTURE0 up to GL_TEXTURE31. These are the sampler-unit slots. Put textures in two slots, and you have multitexturing.
    glGenTextures creates a handle (the "id" or "name").
    Example:

    glGenTextures(1,&myTex); // myTex=2348972;
    glActiveTexture(GL_TEXTURE7); // g_glActiveTexunit=7;
    glBindTexture(GL_TEXTURE_2D,myTex); // g_glSamplers2D[7]=myTex;

  3. #3
    Intern Contributor
    Join Date
    Jun 2009
    Posts
    68

    Re: Question about glGenTextures / GLActiveTexture...

    ...ohhhhhhhh. Sooooo.. I don't have to worry about doing some kind of catastrophic damage then. :3 That's a good thing.. makes my life a lot easier. =)

Posting Permissions

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