用OPENGL绘制图形
大家能帮忙一下,怎么用向量绘制正方体,并有光线的真实感。
[解决办法]
OPENGL?帮楼主顶起
[解决办法]
glBegin(GL_POLYGON); //前表面 glColor3f(1.0,1.0,1.0); glVertex3f(5,5,5); glColor3f(1.0,1.0,0); glVertex3f(5,-5,5); glColor3f(1.0,0,0); glVertex3f(-5,-5,5); glColor3f(1.0,0,1.0); glVertex3f(-5,5,5); glEnd; glBegin(GL_POLYGON); //后表面 glColor3f(0,1.0,1.0); glVertex3f(5,5,-5); glColor3f(0,1.0,0); glVertex3f(5,-5,-5); glColor3f(0.0,0,0); glVertex3f(-5,-5,-5); glColor3f(0,0,1.0); glVertex3f(-5,5,-5); glEnd; glBegin(GL_POLYGON); //上表面 glColor3f(0,1.0,1.0); glVertex3f(5,5,-5); glColor3f(1.0,1.0,1); glVertex3f(5,5,5); glColor3f(1.0,0,1); glVertex3f(-5,5,5); glColor3f(0,0,1.0); glVertex3f(-5,5,-5); glEnd; glBegin(GL_POLYGON); //下表面 glColor3f(0,1.0,0); glVertex3f(5,-5,-5); glColor3f(1.0,1.0,0); glVertex3f(5,-5,5); glColor3f(1.0,0,0); glVertex3f(-5,-5,5); glColor3f(0,0,0.0); glVertex3f(-5,-5,-5); glEnd; glBegin(GL_POLYGON); //左表面 glColor3f(1,1.0,1.0); glVertex3f(5,5,5); glColor3f(0.0,1.0,1); glVertex3f(5,5,-5); glColor3f(0.0,1,0); glVertex3f(5,-5,-5); glColor3f(1,1,0.0); glVertex3f(5,-5,5); glEnd; glBegin(GL_POLYGON); //右表面 glColor3f(1,0.0,1.0); glVertex3f(-5,5,5); glColor3f(0.0,0.0,1); glVertex3f(-5,5,-5); glColor3f(0.0,0,0); glVertex3f(-5,-5,-5); glColor3f(1,0,0.0); glVertex3f(-5,-5,5); glEnd;