GlBindTexture: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Created page with "'''_glBindTexture:''' bind a named texture to a texturing target {{PageSyntax}} :: SUB '''_glBindTexture''' (BYVAL target AS _UNSIGNED LONG, BYVAL texture AS _UNSIGNED LONG) :: void '''_glBindTexture'''(GLenum {{Parameter|target}}, GLuint {{Parameter|texture}}); ; target : Specifies the target to which the texture is bound. Must be either {{KW|_GL_TEXTURE_1D}}, {{KW|_GL_TEXTURE_2D}}, {{KW|_GL_TEXTURE_3D}}, or {{KW|_GL_TEXTURE_1D_ARRAY}}, {{KW|_GL_TEXTURE_2D_ARRAY}},...")
 
(Replaced content with "{{DISPLAYTITLE:_glBindTexture}} The _glBindTexture statement enables the creation of a named texture that is bound to a texture target. {{PageSyntax}} ;QB64 definition :SUB _glBindTexture (BYVAL target AS _UNSIGNED LONG, BYVAL texture AS _UNSIGNED LONG) ;C/C++ definition & description :See [https://docs.microsoft.com/en-us/windows/win32/opengl/glbindtexture Microsoft docs] {{PageSeeAlso}} SUB _GL")
Tag: Replaced
Line 1: Line 1:
'''_glBindTexture:''' bind a named texture to a texturing target
{{DISPLAYTITLE:_glBindTexture}}
The [[_glBindTexture]] statement enables the creation of a named texture that is bound to a texture target.




{{PageSyntax}}
{{PageSyntax}}
 
;QB64 definition
:: SUB '''_glBindTexture''' (BYVAL target AS _UNSIGNED LONG, BYVAL texture AS _UNSIGNED LONG)
:SUB [[_glBindTexture]] (BYVAL target AS _UNSIGNED LONG, BYVAL texture AS _UNSIGNED LONG)
:: void '''_glBindTexture'''(GLenum {{Parameter|target}}, GLuint {{Parameter|texture}});
;C/C++ definition & description
 
:See [https://docs.microsoft.com/en-us/windows/win32/opengl/glbindtexture Microsoft docs]
 
; target
: Specifies the target to which the texture is bound. Must be either {{KW|_GL_TEXTURE_1D}}, {{KW|_GL_TEXTURE_2D}}, {{KW|_GL_TEXTURE_3D}}, or {{KW|_GL_TEXTURE_1D_ARRAY}}, {{KW|_GL_TEXTURE_2D_ARRAY}}, {{KW|_GL_TEXTURE_RECTANGLE}}, {{KW|_GL_TEXTURE_CUBE_MAP}}, {{KW|_GL_TEXTURE_2D_MULTISAMPLE}}, {{KW|_GL_TEXTURE_2D_MULTISAMPLE_ARRAY}}, {{KW|_GL_TEXTURE_BUFFER}}, or {{KW|_GL_TEXTURE_CUBE_MAP_ARRAY}}.
; texture
: Specifies the name of a texture.
 
 
{{PageDescription}}
 
'''_glBindTexture''' lets you create or use a named texture. Calling '''_glBindTexture''' with {{Parameter|target}} set to {{KW|_GL_TEXTURE_1D}}, {{KW|_GL_TEXTURE_2D}}, {{KW|_GL_TEXTURE_3D}}, or {{KW|_GL_TEXTURE_1D_ARRAY}}, {{KW|_GL_TEXTURE_2D_ARRAY}}, {{KW|_GL_TEXTURE_RECTANGLE}}, {{KW|_GL_TEXTURE_CUBE_MAP}}, {{KW|_GL_TEXTURE_2D_MULTISAMPLE}} or {{KW|_GL_TEXTURE_2D_MULTISAMPLE_ARRAY}} and {{Parameter|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 automatically broken.
 
Texture names are unsigned integers. The value zero is reserved to represent the default texture for each texture target. Texture names and the corresponding texture contents are local to the shared object space of the current GL rendering context; two rendering contexts share texture names only if they explicitly enable sharing between contexts through the appropriate GL windows interfaces functions.
 
You must use {{KW|_glGenTextures}} to generate a set of new texture names.
 
When a texture is first bound, it assumes the specified target: A texture first bound to {{KW|_GL_TEXTURE_1D}} becomes one-dimensional texture, a texture first bound to {{KW|_GL_TEXTURE_2D}} becomes two-dimensional texture, a texture first bound to {{KW|_GL_TEXTURE_3D}} becomes three-dimensional texture, a texture first bound to {{KW|_GL_TEXTURE_1D_ARRAY}} becomes one-dimensional array texture, a texture first bound to {{KW|_GL_TEXTURE_2D_ARRAY}} becomes two-dimensional arary texture, a texture first bound to {{KW|_GL_TEXTURE_RECTANGLE}} becomes rectangle texture, a, texture first bound to {{KW|_GL_TEXTURE_CUBE_MAP}} becomes a cube-mapped texture, a texture first bound to {{KW|_GL_TEXTURE_2D_MULTISAMPLE}} becomes a two-dimensional multisampled texture, and a texture first bound to {{KW|_GL_TEXTURE_2D_MULTISAMPLE_ARRAY}} becomes a two-dimensional multisampled array texture. The state of a one-dimensional texture immediately after it is first bound is equivalent to the state of the default {{KW|_GL_TEXTURE_1D}} at GL initialization, and similarly for the other texture types.
 
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. 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 '''_glBindTexture''' remains active until a different texture is bound to the same target, or until the bound texture is deleted with {{KW|_glDeleteTextures}}.
 
Once created, a named texture may be re-bound to its same original target 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 {{KW|_glTexImage1D}}, {{KW|_glTexImage2D}}, {{KW|_glTexImage3D}} or another similar function.
 
 
{{PageNotes}}
 
The {{KW|_GL_TEXTURE_2D_MULTISAMPLE}} and {{KW|_GL_TEXTURE_2D_MULTISAMPLE_ARRAY}} targets are available only if the GL version is 3.2 or higher.
 
 
{{PageErrors}}
 
{{KW|_GL_INVALID_ENUM}} is generated if {{Parameter|target}} is not one of the allowable values.
 
{{KW|_GL_INVALID_VALUE}} is generated if {{Parameter|target}} is not a name returned from a previous call to {{KW|_glGenTextures}}.
 
{{KW|_GL_INVALID_OPERATION}} is generated if {{Parameter|texture}} was previously created with a target that doesn't match that of {{Parameter|target}}.
 
 
{{PageUseWith}}
 
{{KW|_glGet}} with argument {{KW|_GL_TEXTURE_BINDING_1D}}, {{KW|_GL_TEXTURE_BINDING_2D}}, {{KW|_GL_TEXTURE_BINDING_3D}}, {{KW|_GL_TEXTURE_BINDING_1D_ARRAY}}, {{KW|_GL_TEXTURE_BINDING_2D_ARRAY}}, {{KW|_GL_TEXTURE_BINDING_RECTANGLE}}, {{KW|_GL_TEXTURE_BINDING_2D_MULTISAMPLE}}, or {{KW|_GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY}}.


{{PageSeeAlso}}
{{PageSeeAlso}}
[[_GL|SUB _GL]]
[[_GL|SUB _GL]]
{{KW|_glActiveTexture}}, {{KW|_glDeleteTextures}}, {{KW|_glGenTextures}}, {{KW|_glGetTexParameter}}, {{KW|_glIsTexture}}, {{KW|_glTexParameter}}
{{PageCopyright}}

Revision as of 20:14, 10 July 2022

The _glBindTexture statement enables the creation of a named texture that is bound to a texture target.


Syntax

QB64 definition
SUB _glBindTexture (BYVAL target AS _UNSIGNED LONG, BYVAL texture AS _UNSIGNED LONG)
C/C++ definition & description
See Microsoft docs

See also

SUB _GL