我该如何平铺?或者做大一点,让草纹理出现在整个屏幕上,就像覆盖整个地板一样?
这里是代码和结果:
(图片)http://tinypic.com/r/dyvc7t/6
glBegin(GL_QUADS);
glNormal3f(0.0f, 0.0f, 1.0f);
glTexCoord2f(0.0,0.0);
glVertex3f(-140.0, 0.0,100.0);
glTexCoord3f(1.0,0.0,0.0);
glVertex3f(140.0, 0.0,100.0);
glTexCoord2f(1.0,1.0);
glVertex3f(140.0, 140.0,100.0);
glTexCoord2f(0.0,1.0);
glVertex3f(-140.0, 140.0,100.0);
glEnd();
glDisable( GL_TEXTURE_2D );
答案 0 :(得分:0)
这是一个正方形的opengl代码:
glVertex3f(-1.0f, -1.0f, 0.0f); // The bottom left corner
glVertex3f(-1.0f, 1.0f, 0.0f); // The top left corner
glVertex3f(1.0f, 1.0f, 0.0f); // The top right corner
glVertex3f(1.0f, -1.0f, 0.0f); // The bottom right corner
这是相同的代码,对于更大的方块:
glVertex3f(-2.0f, -2.0f, 0.0f); // The bottom left corner
glVertex3f(-2.0f, 2.0f, 0.0f); // The top left corner
glVertex3f(2.0f, 2.0f, 0.0f); // The top right corner
glVertex3f(2.0f, -2.0f, 0.0f); // The bottom right corner
因此,如果您想要更大的多边形,只需更改定义它的数字即可。
答案 1 :(得分:0)
如果你想平铺它,只需使用'for(int x = 0; x< so on ...)'和'translate'方法。每次翻译图块时务必弹出矩阵,否则它将无效。