OpenGL texture element Texture Target Understanding Glactivetexture glbindtexture

Source: Internet
Author: User


It can be simply understood as: There are n texture units in the graphics card (the number depends on your graphics card capabilities), each texture unit (GL_TEXTURE0, GL_TEXTURE1, etc.) have gl_texture_1d, gl_texture_2d, and so on, the following code:

struct Textureunit
{
    gluint targettexture1d;
    Gluint targettexture2d;
    Gluint Targettexture3d;
    Gluint Targettexturecube;
    ...
};
 
Textureunit Textureunits[gl_max_texture_image_units]
gluint currenttextureunit = 0;

By default, the currently active texture unit is 0.

void Glactivetexture (Glenum textureunit)
{
    currenttextureunit = textureunit  -gl_texture0;
}


Instead of activating the texture unit, Glactivetextue selects the currently active texture cell.


void Glbindtexture (Glenum texturetarget, Gluint textureobject)
{
    Textureunit *texunit = &textureunits[ Currenttextureunit];
    Switch (texturetarget)
    {case
    gl_texture_1d:texunit->targettexture1d = textureobject;
    Case gl_texture_2d:texunit->targettexture2d = Textureobject; break;
    Case Gl_texture_3d:texunit->targettexture3d = Textureobject; break;
    Case gl_texture_cubemap:texunit->targettexturecube = Textureobject; break;
    }
}

As you can see from the sample code: When you bind a texture target, it is the currently active texture cell.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.