Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

glBindTexture function

The glBindTexture function enables the creation of a named texture that is bound to a texture target.

Syntax


void WINAPI glBindTexture(
   GLenum target,
   GLuint texture
);

Parameters

target

The target to which the texture is bound. Must have the value GL_TEXTURE_1D or GL_TEXTURE_2D.

texture

The name of a texture; the texture name cannot currently be in use.

Return value

This function does not return a value.

Error codes

The following error codes can be retrieved by the glGetError function.

NameMeaning
GL_INVALID_ENUM

The parameter target was not an accepted value.

GL_INVALID_OPERATION

The parameter texture did not have the same dimensionality as target, or the function was called between a call to glBegin and the corresponding call to glEnd.

Error codes

The following error codes can be retrieved by the glGetError function.

NameMeaning
GL_INVALID_ENUM

The parameter target was not an accepted value.

GL_INVALID_OPERATION

The parameter texture did not have the same dimensionality as target, or the function was called between a call to glBegin and the corresponding call to glEnd.

Remarks

The glBindTexture function enables you to create a named texture. Calling glBindTexture with target set to GL_TEXTURE_1D or GL_TEXTURE_2D, and texture set to the name of the new texture you have created binds the texture name to the appropriate texture target. When a texture is bound to a target, the previous binding for that target is no longer in effect.

Texture names are unsigned integers with the value zero reserved to represent the default texture for each texture target. Texture names and the corresponding texture contents are local to the shared display-list space of the current OpenGL rendering context; two rendering contexts share texture names only if they also share display lists. You can generate a set of new texture names using glGenTextures.

When a texture is first bound, it assumes the dimensionality of its texture target; a texture bound to GL_TEXTURE_1D becomes one-dimensional and a texture bound to GL_TEXTURE_2D becomes two-dimensional. Operations you perform on a texture target also affect a texture bound to the target. When you query a texture target, the return value is the state of the texture bound to it. Texture targets become aliases for textures currently bound to them.

When you bind a texture with glBindTexture, the binding remains active until a different texture is bound to the same target or you delete the bound texture with the glDeleteTextures function. Once you create a named texture you can bind it to a texture target that has the same dimensionality as often as needed.

It is usually much faster to use glBindTexture to bind an existing named texture to one of the texture targets than it is to reload the texture image using glTexImage1D or glTexImage2D. For additional control of texturing performance, use glPrioritizeTextures.

You can include calls to glBindTexture in display lists.

Note  The glBindTexture function is only available in OpenGL version 1.1 or later.
 

The following functions retrieve information related to glBindTexture:

  • glGet with argument GL_TEXTURE_1D_BINDING

glGet with argument GL_TEXTURE_2D_BINDING

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Gl.h

Library

Opengl32.lib

DLL

Opengl32.dll

See also

glAreTexturesResident
glDeleteTextures
glGenTextures
glGet
glGetTexParameter
glIsTexture
glPrioritizeTextures
glTexImage1D
glTexImage2D
glTexParameter

 

 

Show: