/ comp / gb.opengl / gl / bindtexture
Gl.BindTexture (gb.opengl)
Syntax

    STATIC SUB BindTexture ( Target AS Integer, Texture AS Integer )

### Bind a named texture to a texture target

#### Parameters

- Target specifies the target to which the texture is bound. Must be either Gl.GL_TEXTURE_1D, Gl.GL_TEXTURE_2D.

- Texture specifies the name of a texture.

#### Description

Gl.BindTexture binds the texture named texture to the specified target. If the name does not exist, it is created. Calling Gl.BindTexture with target set to Gl.GL_TEXTURE_1D or Gl.GL_TEXTURE_2D and texture set to the name of the new texture binds the texture name to the target. When a texture is bound to a target, the previous binding for that target is broken.

Texture names are constants. The value 0 is 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 GL rendering context; two rendering contexts share texture names only if they also share display lists. Gl.GenTextures may be used to generate a set of new texture names.

When a texture is first bound, it assumes the dimensionality of its target: A texture first bound to Gl.GL_TEXTURE_1D becomes 1-dimensional, a texture first bound to Gl.GL_TEXTURE_2D becomes 2-dimensional. The state of a 1-dimensional texture immediately after it is first bound is equivalent to the state of the default Gl.GL_TEXTURE_1D at GL initialization, and similarly for 2-dimensional textures.

While a texture is bound, GL operations on the target to which it is bound affect the bound texture, and queries of the target to which it is bound return state from the bound texture. If texture mapping of the dimensionality of the target to which a texture is bound is active, the bound texture is used. In effect, the texture targets become aliases for the textures currently bound to them, and the texture name zero refers to the default textures that were bound to them at initialization. A texture binding created with Gl.BindTexture remains active until a different texture is bound to the same target, or until the bound texture is deleted with Gl.DeleteTextures.

Once created, a named texture may be rebound to the target of the matching dimensionality as often as needed. It is usually much faster to use Gl.BindTexture to bind an existing named texture to one of the texture targets than it is to reload the texture image using Gl.TexImage1D or Gl.TexImage2D. For additional control over performance, use Gl.PrioritizeTextures.

Gl.BindTexture is included in display lists.

| Gl.BindTexture is available only if the GL version is 1.1 or greater.

#### Errors

Gl.GL_INVALID_ENUM is generated if target is not one of the allowable values.
Gl.GL_INVALID_OPERATION is generated if texture has a dimensionality which does not match that of target.
Gl.GL_INVALID_OPERATION is generated if Gl.BindTexture is executed between the execution of Gl.Begin and the corresponding execution of GL.End.

#### Assciated Gets

Gl.GetTexture1DBinding
Gl.GetTexture2DBinding

### See also

Gl.AreTexturesResident, Gl.DeleteTextures , Gl.GenTextures, Gl.GetTexParameter, Gl.IsTexture, Gl.PrioritizeTextures, Gl.TexImage1D, Gl.TexImage2D, Gl.TexParameter