赞
踩
源码还是这样,把背景改下:
https://blog.csdn.net/qq78442761/article/details/81228557
采用GL_CLAMP方式过滤时大于1.0的所有的纹理坐标,会取纹理坐标为1.0上的纹理颜色
源码如下:
- void Draw() {
- glClearColor(0.1f, 0.4f, 0.6f, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT);
- glEnable(GL_TEXTURE_2D); //开启2D纹理
- glBindTexture(GL_TEXTURE_2D, texture);//将当前纹理设置为新创建的纹理对象
- glBegin(GL_QUADS);
- glColor4ub(255, 255, 255, 255);
- glTexCoord2f(0.0f, 0.0f);
- glVertex3f(-0.1f, -0.1f, -0.4f);
- glTexCoord2f(1.0f, 0.0f);
- glVertex3f(0.1f, -0.1f, -0.4f);
- glTexCoord2f(1.0f, 1.0f);
- glVertex3f(0.1f, 0.1f, -0.4f);
- glTexCoord2f(0.0f, 1.0f);
- glVertex3f(-0.1f, 0.1f, -0.4f);
- glEnd();
- }
运行截图如下:
当修改纹理坐标后,如下图:
源码如下:
- void Draw() {
- glClearColor(0.1f, 0.4f, 0.6f, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT);
- glEnable(GL_TEXTURE_2D); //开启2D纹理
- glBindTexture(GL_TEXTURE_2D, texture);//将当前纹理设置为新创建的纹理对象
- glBegin(GL_QUADS);
- glColor4ub(255, 255, 255, 255);
- glTexCoord2f(0.0f, 0.0f);
- glVertex3f(-0.1f, -0.1f, -0.4f);
- glTexCoord2f(2.0f, 0.0f);
- glVertex3f(0.1f, -0.1f, -0.4f);
- glTexCoord2f(2.0f, 2.0f);
- glVertex3f(0.1f, 0.1f, -0.4f);
- glTexCoord2f(0.0f, 2.0f);
- glVertex3f(-0.1f, 0.1f, -0.4f);
- glEnd();
- }
采用GL_CLAMP方式过滤时大于1.0的所有的纹理坐标,会取纹理坐标为1.0上的纹理颜色
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。