OpenGLES - glBindTexture 绑定纹理缓存到纹理单元

来源:互联网 发布:中银淘宝信用卡怎么样 编辑:程序博客网 时间:2024/06/15 03:07

OpenGLES - glBindTexture 绑定纹理缓存到纹理单元

太阳火神的美丽人生 (http://blog.csdn.net/opengl_es)

本文遵循“署名-非商业用途-保持一致”创作公用协议

转载请保留此句:太阳火神的美丽人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS、Android、Html5、Arduino、pcDuino否则,出自本博客的文章拒绝转载或再转载,谢谢合作。


名字
Name

glBindTexture — 绑定一个命名的纹理到一个使用中的纹理目标 bind a named texture to a texturing target

C 规范
C Specification

void glBindTexture(GLenum target, GLuint texture);
 

参数
Parameters

target

指定纹理要被绑定到的活动纹理单位,必须是 GL_TEXTURE_2D 或 GL_TEXTURE_CUBE_MAP
Specifies the target of the active texture unit to which the texture is bound. Must be either GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP.

texture

指定一个纹理对象的名字
Specifies the name of a texture.

描述
Description

glBindTexture 允许你创建和使用命名的纹理。调用 glBindTexture 并设置参数 target 的值为 GL_TEXTURE_2D 或 GL_TEXTURE_CUBE_MAP,参数 texture 设置为新纹理的名字,这将会绑定纹理名到目标指定的当前活动纹理单元。当一个纹理绑定到一个目标时,目标纹理单元先前绑定的纹理对象将被自动断开。

glBindTexture lets you create or use a named texture. Calling glBindTexture with target set to GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP and texture set to the name of the new texture binds the texture name to the target of the current active texture unit. When a texture is bound to a target, the previous binding for that target is automatically broken.

纹理名是无符号整型。值 0 为每一个纹理目标保留,用于表示默认纹理。纹理名和对应的纹理内容挂载到当前 GL 渲染上下文的共享对象空间。
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.

你可以使用 glGenTextures 生成一组新的纹理名。
You may use glGenTextures to generate a set of new texture names.

当一个纹理首次绑定时,它假定一个指定的目标:第一次绑定到 GL_TEXTURE_2D 的纹理会变成一个二维的纹理,而第一次绑定到 GL_TEXTURE_CUBE_MAP 的纹理会变成一个立方体贴图纹理。二维纹理的状态在其第一次绑定后会即刻与 GL 初始化时 GL_TEXTURE_2D 的默认状态相同,立方体贴图纹理也一样。
When a texture is first bound, it assumes the specified target: A texture first bound to GL_TEXTURE_2D becomes a two-dimensional texture and a texture first bound to GL_TEXTURE_CUBE_MAP becomes a cube-mapped texture. The state of a two-dimensional texture immediately after it is first bound is equivalent to the state of the default GL_TEXTURE_2D at GL initialization, and similarly for cube-mapped textures.

当一个纹理被绑定时,在绑定的目标上的 GL 操作将作用到绑定的纹理上,并且,对绑定的目标的查询也将返回其上绑定的纹理的状态。实际上,纹理目标变成了当前绑定在其上的纹理的别名,纹理名 0 指向初始化时绑定到的默认纹理。
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.

使用 glBindTexture 创建的纹理绑定一直保持激活,直到一个不同的纹理再次绑定到同一个目标,或直到绑定的纹理用 glDeleteTextures 删除。
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 glDeleteTextures.

一旦创建,一个命名的纹理每当需要时可以重新绑定到相同的源目标。通常使用 glBindTexture 绑定一个已存在的命名纹理到一个纹理目标要比使用 glTexImage2D 重新加载纹理图片要快得多。
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 glTexImage2D.


错误
Errors

如果 target 不是其中一个允许的值,将生成 GL_INVALID_ENUM  。
GL_INVALID_ENUM
 is generated if target is not one of the allowable values.

如果 texture 先前使用一个与 target 不匹配的目标创建的,将生成 GL_INVALID_OPERATION 。
GL_INVALID_OPERATION
 is generated if texture was previously created with a target that doesn't match that of target.


关联的获取方法
Associated Gets

glGet 带有参数 GL_TEXTURE_BINDING_2D 或 GL_TEXTURE_BINDING_CUBE_MAP
glGet
 with argument GL_TEXTURE_BINDING_2D or GL_TEXTURE_BINDING_CUBE_MAP


参见
See Also

glDeleteTexturesglGenTexturesglGetglGetTexParameterglIsTextureglTexImage2DglTexParameter


版权
Copyright

Copyright © 1991-2006 Silicon Graphics, Inc. This document is licensed under the SGI Free Software B License. For details, see http://oss.sgi.com/projects/FreeB/.

0 0
原创粉丝点击