Opengl五 纹理

1加载纹理

glTexImage(GLenum target,GLint level,GLint internalFormat,GLsizei width,GLint border,GLenum format,GLenum type,void * data);

参数:

target: GL_TEXTURE_1D,GL_TEXTURE_2D,GL_TEXTURE_3D

level:指定这些函数所加载的mipmap层,对于非mipmap纹理,此值可以设置为0

internalFormat : 告诉opengl每个纹理单元中存储多少颜色成分,一些常用值:GL_ALPHA,GL_LUMINANCE,GL_LUMINANCE_ALPHA,GL_RGB,GL_RGBA

width,height,depth:指定了纹理的宽度,高度和深度(这三个值推荐强制使用2的次数)

border:纹理贴图的边界宽度

format : 在内存中的格式

type : data数据的类型int,byte,short等

data:纹理数据

纹理替换:

glTextureSubImage : 替换纹理比重新加载一个新纹理速度更快

纹理对象允许我们一次加载多个纹理(放在内存中)。

1、glGenTexutres(GLsizei n,GLuint *textureIds) ; 分配纹理对象

2、glBindTexture(GLenum target,GLuint texture); 绑定纹理对象,以后操作使用此纹理

3、glDeleteTexture(GLsizei n, GLuint *textureIds);  删除纹理对象

 

以下是具体伪代码

glGenTexutreids

glBindTexture

glTexParameterf(GL_Texture_2D,GL_TEXUTRE_MIN_FILETER,GL_LINEAR);

glTexParamterf(GL_Texture_2D,GL_texture_mag_filter,GL_LINEAR);

glEnable(GL_TEXUTRE_2D)

glTexCoord3f

glVertex3f

 

发表评论?

0 条评论。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>