纹理创建

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;
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容