在看一些画图形的书当画一个正方体时,只要确定顶点和画的要求就可以画出一个正方体了,使我不明白的是,在画八个顶点时,比如说
glBegin(GL_POLYGON);
glNormal3d(0.0,0.0,1.0);
glTexCoord2f(0.0, 1.0); glVertex3d(-x, x, x);
glTexCoord2f(1.0, 1.0); glVertex3d(-x, -x, x);
glTexCoord2f(1.0, 0.0); glVertex3d( x, -x, x);
glTexCoord2f(0.0, 0.0); glVertex3d( x, x, x);
glEnd();
glBegin(GL_POLYGON);
glNormal3d(0.0,0.0,-1.0);
glTexCoord2f(0.0, 1.0); glVertex3d( x, x, -x);
glTexCoord2f(0.0, 0.0); glVertex3d( x, -x, -x);
glTexCoord2f(1.0, 0.0); glVertex3d( -x, -x, -x);
glTexCoord2f(1.0, 1.0); glVertex3d( -x, x, -x);
glEnd();
glBegin(GL_POLYGON);
glNormal3d(1.0,0.0,0.0);
glTexCoord2f(0.0, 0.0); glVertex3d( x, x, x);
glTexCoord2f(1.0, 0.0); glVertex3d( x, -x, x);
glTexCoord2f(1.0, 1.0); glVertex3d( x, -x, -x);
glTexCoord2f(0.0, 1.0); glVertex3d( x, x, -x);
glEnd();
glBegin(GL_POLYGON);
glNormal3d(-1.0,0.0,0.0);
glTexCoord2f(0.0, 0.0); glVertex3d( -x, x, x);
glTexCoord2f(1.0, 0.0); glVertex3d( -x, x, -x);
glTexCoord2f(1.0, 1.0); glVertex3d( -x, -x, -x);
glTexCoord2f(0.0, 1.0); glVertex3d( -x, -x, x);
glEnd();
glBegin(GL_POLYGON);
glNormal3d(0.0,-1.0,0.0);
glTexCoord2f(0.0, 0.0); glVertex3d( -x, -x, x);
glTexCoord2f(1.0, 0.0); glVertex3d( -x, -x, -x);
glTexCoord2f(1.0, 1.0); glVertex3d( x, -x, -x);
glTexCoord2f(0.0, 1.0); glVertex3d( x, -x, x);
glEnd();
glBegin(GL_POLYGON);
glNormal3d(0.0,1.0,0.0);
glTexCoord2f(0.0, 0.0); glVertex3d( -x, x, x);
glTexCoord2f(1.0, 0.0); glVertex3d( x, x, x);
glTexCoord2f(1.0, 1.0); glVertex3d( x, x, -x);
glTexCoord2f(0.0, 1.0); glVertex3d( -x, x, -x);
glEnd();就可以实现了,但是它的坐标是怎么来的,怎样建立坐标啊,坐标不确定的话,那些顶点怎么知道画在哪里,说的有点糊涂
总之,就是怎么建立坐标,点画在对应的三维坐标上,谢谢