美文网首页
纹理创建

纹理创建

作者: 孙健会员 | 来源:发表于2016-10-09 14:52 被阅读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;
    }
    

    相关文章

      网友评论

          本文标题:纹理创建

          本文链接:https://www.haomeiwen.com/subject/btnpyttx.html