当前位置:   article > 正文

C++ opengl 纹理过滤之GL_CLAMP_glclampcolor

glclampcolor

源码还是这样,把背景改下:

https://blog.csdn.net/qq78442761/article/details/81228557

采用GL_CLAMP方式过滤时大于1.0的所有的纹理坐标,会取纹理坐标为1.0上的纹理颜色

源码如下:

  1. void Draw() {
  2. glClearColor(0.1f, 0.4f, 0.6f, 1.0f);
  3. glClear(GL_COLOR_BUFFER_BIT);
  4. glEnable(GL_TEXTURE_2D); //开启2D纹理
  5. glBindTexture(GL_TEXTURE_2D, texture);//将当前纹理设置为新创建的纹理对象
  6. glBegin(GL_QUADS);
  7. glColor4ub(255, 255, 255, 255);
  8. glTexCoord2f(0.0f, 0.0f);
  9. glVertex3f(-0.1f, -0.1f, -0.4f);
  10. glTexCoord2f(1.0f, 0.0f);
  11. glVertex3f(0.1f, -0.1f, -0.4f);
  12. glTexCoord2f(1.0f, 1.0f);
  13. glVertex3f(0.1f, 0.1f, -0.4f);
  14. glTexCoord2f(0.0f, 1.0f);
  15. glVertex3f(-0.1f, 0.1f, -0.4f);
  16. glEnd();
  17. }

运行截图如下:

当修改纹理坐标后,如下图:

源码如下:

  1. void Draw() {
  2. glClearColor(0.1f, 0.4f, 0.6f, 1.0f);
  3. glClear(GL_COLOR_BUFFER_BIT);
  4. glEnable(GL_TEXTURE_2D); //开启2D纹理
  5. glBindTexture(GL_TEXTURE_2D, texture);//将当前纹理设置为新创建的纹理对象
  6. glBegin(GL_QUADS);
  7. glColor4ub(255, 255, 255, 255);
  8. glTexCoord2f(0.0f, 0.0f);
  9. glVertex3f(-0.1f, -0.1f, -0.4f);
  10. glTexCoord2f(2.0f, 0.0f);
  11. glVertex3f(0.1f, -0.1f, -0.4f);
  12. glTexCoord2f(2.0f, 2.0f);
  13. glVertex3f(0.1f, 0.1f, -0.4f);
  14. glTexCoord2f(0.0f, 2.0f);
  15. glVertex3f(-0.1f, 0.1f, -0.4f);
  16. glEnd();
  17. }

 

采用GL_CLAMP方式过滤时大于1.0的所有的纹理坐标,会取纹理坐标为1.0上的纹理颜色

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/574162
推荐阅读
相关标签
  

闽ICP备14008679号