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);