#include <gl/glut.h>
void Initial(void)
{
glClearColor(0.0,0.0,0.0,0.0);
}
void myReshape(GLsizei w,GLsizei h)
{
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(80.0,(GLdouble)w/(GLdouble)h,1.0,20.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0,0.0,-8.0);
}
void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glColor3f(0.0,0.0,1.0);
glutSolidTeapot(1.5);
glPopMatrix();
glPushMatrix();
glTranslatef(5.0,0.0,0.0);
glColor3f(1.0,0.0,0.0);
glutSolidTeapot(1.0);
glPopMatrix();
glPushMatrix();
glTranslatef(-5.0,0.0,0.0);
glColor3f(0.0,1.0,0.0);
glutSolidTeapot(1.0);
glPopMatrix();
glFlush();
}
int main(int argc,char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(400,400);
glutInitWindowPosition(200,200);
glutCreateWindow("Double Triangles");
Initial();
glutReshapeFunc(myReshape);
glutDisplayFunc(myDisplay);
glutMainLoop();
return 0;
}
glTranslatef_茶壶
最新推荐文章于 2023-03-26 17:34:31 发布