资源描述:
《opengl 立方体》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、三角形#include#includevoidmyinit(void){glClearColor(1.0,1.0,1.0,1.0);}voidDrawTriangle(void){glBegin(GL_TRIANGLES);glVertex2f(20.0,20.0);glVertex2f(80.0,30.0);glVertex2f(50.0,70.0);glEnd();}voiddisplay(void){glClear(GL_COLOR_BUFFER_BIT);glColor
2、3f(0.0,0.0,0.0);glPolygonMode(GL_FRONT,GL_LINE);DrawTriangle();glPushMatrix();glEnable(GL_LINE_STIPPLE);glLineStipple(1,0xF0F0);glTranslatef(90.0,0.0,0.0);DrawTriangle();glPopMatrix();glPushMatrix();glLineStipple(1,0x8888);glTranslatef(20.0,80.0,0.0);glScalef(0.5
3、,1.5,1.0);DrawTriangle();glPopMatrix();glPushMatrix();glLineStipple(1,0xF00F);glTranslatef(110.0,90.0,0.0);glRotatef(30.0,0.0,0.0,1.0);DrawTriangle();glPopMatrix();glFlush();}voidmyreshape(intw,inth){glViewport(0,0,(GLsizei)w,(GLsizei)h);glMatrixMode(GL_PROJECTIO
4、N);glLoadIdentity();gluOrtho2D(0.0,(GLdouble)w,0.0,(GLdouble)h);}intmain(intargc,char*argv[]){glutInit(&argc,argv);glutInitWindowSize(200,200);glutInitWindowPosition(200,200);glutCreateWindow("Transform");myinit();glutDisplayFunc(display);glutReshapeFunc(myreshap
5、e);glutMainLoop();return0;}voiddisplay(void){glClear(GL_COLOR_BUFFER_BIT);glColor3f(0.0,0.0,0.0);glPolygonMode(GL_FRONT,GL_LINE);DrawTriangle();/*glPushMatrix();glEnable(GL_LINE_STIPPLE);glLineStipple(1,0xF0F0);glTranslatef(90.0,0.0,0.0);DrawTriangle();glPopMatri
6、x();glPushMatrix();glLineStipple(1,0x8888);glTranslatef(20.0,80.0,0.0);glScalef(0.5,1.5,1.0);DrawTriangle();glPopMatrix();glPushMatrix();glLineStipple(1,0xF00F);glTranslatef(110.0,90.0,0.0);glRotatef(30.0,0.0,0.0,1.0);DrawTriangle();glPopMatrix();*/glFlush();}voi
7、ddisplay(void){glClear(GL_COLOR_BUFFER_BIT);glColor3f(0.0,0.0,0.0);/*glPolygonMode(GL_FRONT,GL_LINE);DrawTriangle();*/glPushMatrix();glEnable(GL_LINE_STIPPLE);glLineStipple(1,0xF0F0);glTranslatef(90.0,0.0,0.0);DrawTriangle();glPopMatrix();/*glPushMatrix();glLineS
8、tipple(1,0x8888);glTranslatef(20.0,80.0,0.0);glScalef(0.5,1.5,1.0);DrawTriangle();glPopMatrix();glPushMatrix();glLineStipple(1,0xF00F);glTranslatef(110.0,90.0,