问题描述:glBegin(GL_QUADS);
glTexCoord2f(0.0f,0.0f);glVertex3f(-1.0f,-1.0f,0.0f);
glTexCoord2f(0.0f,1.0f);glVertex3f(-1.0f,1.0f,0.0f);
glTexCoord2f(1.0f,1.0f);glVertex3f(1.0f,1.0f,0.0f);
glTexCoord2f(1.0f,0.0f);glVertex3f(1.0f,-1.0f,0.0f);
glEnd();
glDisable(GL_TEXTURE_2D);
这是对于纹理坐标的定义
要是我有这么一个四边形
glBegin(GL_POLYGON);
glVertex3f(-0.5f, 0.5f, 0.5f);
glVertex3f(-0.5f, -0.5f, 0.5f);
glVertex3f(0.5f, -0.5f, 0.5f);
glVertex3f(0.5f, 0.5f, 0.5f);
glEnd();
怎么给它贴上照片,
求详细代码
各位大哥帮帮忙
回答:纹理贴图的步骤:创建纹理对象,指定一个纹理;确定纹理的使用方式;启用纹理;提供纹理坐标绘制几何图形。 你代码上面部分本身就是设置纹理坐标并且绘制了一个方形的。然后 glDisable(GL_TEXTURE_2D);这句话禁用了纹理。 至于绘制部分,比较简单,改成如下即可: glBegin(GL_POLYGON); glTexCoord2f(0.0f,0.0f);glVertex3f(-0.5f, 0.5f, 0.5f); glTexCoord2f(1.0f,0.0f);glVertex3f(-0.5f, -0.5f, 0.5f); glTexCoord2f(1.0f,1.0f);glVertex3f(0.5f, -0.5f, 0.5f); glTexCoord2f(1.0f,0.0f);glVertex3f(0.5f, 0.5f, 0.5f); glEnd(); |
|