-5

我如何平铺这个?或者把它变大,让草的纹理出现在整个屏幕上,就像覆盖整个地板一样?

这里的代码和结果:

(图)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 );
4

2 回答 2

0

如果你想平铺它,只需使用'for (int x = 0; x < so on...)' 和'translate' 方法。确保每次翻译图块时都弹出矩阵,否则它将不起作用。

于 2013-01-07T21:48:14.783 回答
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

所以如果你想让你的多边形更大,只需改变定义它的数字。

于 2013-01-06T11:03:21.113 回答