纹理创建
2016-10-09 本文已影响398人
孙健会员
the first
- (GLuint) createTexture{
GLuint _texture;//创建对象
glActiveTexture(GL_TEXTURE1);//激活纹理单元1
glGenTextures(1, &_texture);//生成纹理对象
glBindTexture(GL_TEXTURE_2D, _texture);//采样纹理对象
//设置纹理属性
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
return _texture;
}
the second
- (GLuint)createTexture{
//创建纹理对象
GLuint _texture;
//激活纹理单元
glActiveTexture(GL_TEXTURE1);
//生成纹理对象
glGenTexture(1, &_texture);
//采样纹理对象
glBindTexture(GL_TEXTURE_2D, _texture);
//设置纹理属性
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINERA);//线性插值
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINERA);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
g lTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
//返回生成纹理
return _texture;
}