OpenGL超级宝典学习笔记(4)

for(GLfloat z = -60.0f; z <= 0.0f; z += 10.0f)
{
//绑定地板纹理绘制地板,注意glBeindTexture在glBegin和glEnd中是无效的
glBindTexture(GL_TEXTURE_2D, textureName[FLOOR]);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-10.0f, -10.0f, z);

glTexCoord2f(1.0f, 0.0f);
glVertex3f(-10.0f, -10.0f, z + 10.0f);

glTexCoord2f(1.0f, 1.0f);
glVertex3f(10.0f, -10.0f, z + 10.0f);

glTexCoord2f(0.0f, 1.0f);
glVertex3f(10.0f, -10.0f, z);

glEnd();

//绑定天花板纹理
glBindTexture(GL_TEXTURE_2D, textureName[CEILING]);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-10.0f, 10.0f, z);

glTexCoord2f(1.0f, 0.0f);
glVertex3f(-10.0f, 10.0f, z + 10.0f);

glTexCoord2f(1.0f, 1.0f);
glVertex3f(10.0f, 10.0f, z + 10.0f);

glTexCoord2f(0.0f, 1.0f);
glVertex3f(10.0f, 10.0f, z);
glEnd();

//绑定砖墙的纹理
glBindTexture(GL_TEXTURE_2D, textureName[BRICK]);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-10.0f, -10.0f, z);

glTexCoord2f(1.0f, 0.0f);
glVertex3f(-10.0f, 10.0f, z);

glTexCoord2f(1.0f, 1.0f);
glVertex3f(-10.0f, 10.0f, z + 10.0f);

glTexCoord2f(0.0f, 1.0f);
glVertex3f(-10.0f, -10.0f, z + 10.0f);

glTexCoord2f(0.0f, 0.0f);
glVertex3f(10.0f, -10.0f, z);

glTexCoord2f(1.0f, 0.0f);
glVertex3f(10.0f, 10.0f, z);

glTexCoord2f(1.0f, 1.0f);
glVertex3f(10.0f, 10.0f, z + 10.0f);

glTexCoord2f(0.0f, 1.0f);
glVertex3f(10.0f, -10.0f, z + 10.0f);
glEnd();
}

tunnel示例中,切换mipmap纹理过滤器时,只修改了缩小过滤器

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/2769732a4e11137c7378ed96e6bb3fce.html