图形学考题整理.doc
《图形学考题整理.doc》由会员分享,可在线阅读,更多相关《图形学考题整理.doc(22页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、OpenGL32.lib GLu32.lib 和 GLaux.lib图形学上机测试题目整理1. 立方体(正方体)放缩在前面定义:int Angle = 0;int DrawGLScene(GLvoid)glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glLoadIdentity();float a=10.0;glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);/清除颜色和深度缓冲区glEnable(GL_DEPTH_TEST);/启用深度检测glMatrixMode(GL_MODELVIEW);
2、glColor3f(1.0f,0.0f,0.0f);glLoadIdentity();glTranslatef(-0.0f,-0.0f,-22.0f);glScalef(0.05f,0.05f,0.05f);glRotatef(15.0f,1.0f,0.0f,0.0f);glRotatef(35.0f,0.0f,1.0f,0.0f);glScalef(Angle,Angle,Angle);glPushMatrix();glBegin(GL_QUADS);/glColor3f (1.0f,0.0f,0.0f);/将绘图色设置为红色leftglVertex3f(0,0,0);glVertex3f(
3、0,a,0);glVertex3f(0,a,a);glVertex3f(0,0,a);glColor3f (1.0f,1.0f,0.0f);/将绘图色设置为黄色前面glVertex3f(0,a,a);glVertex3f(0,0,a); glVertex3f(a,0,a);glVertex3f(a,a,a);glColor3f (0.0f,1.0f,0.0f);/将绘图色设置为绿色backglVertex3f(0,0,0);glVertex3f(0,a,0);glVertex3f(a,a,0);glVertex3f(a,0,0);glColor3f (0.0f,0.0f,1.0f);/将绘图色
4、设置为兰色upglVertex3f(a,a,0);glVertex3f(0,a,0);glVertex3f(0,a,a);glVertex3f(a,a,a);glColor3f (0.0f,1.0f,1.0f);/将绘图色设置为青色downglVertex3f(0,0,0);glVertex3f(a,0,0);glVertex3f(a,0,a);glVertex3f(0,0,a);glColor3f (1.0f,0.0f,1.0f);/将绘图色设置为紫色右glVertex3f(a,0,a);glVertex3f(a,0,0);glVertex3f(a,a,0);glVertex3f(a,a,a
5、);glEnd();glPopMatrix();if(Angle5)Angle=-0;Sleep(100);Angle +=1;/旋转角度增量Sleep(100);return TRUE;2. 圆锥放缩在前面定义:int Angle = 0;int DrawGLScene(GLvoid)glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glLoadIdentity();int a=10;glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);/清除颜色和深度缓冲区glEnable(GL_DEPTH_T
6、EST);/启用深度检测glMatrixMode(GL_MODELVIEW);glColor3f(1.0f,0.0f,0.0f);glLoadIdentity();glTranslatef(-0.0f,-0.0f,-22.0f);glScalef(0.05f,0.05f,0.05f);glRotatef(60.0f,1.0f,0.0f,0.0f);glRotatef(0.0f,0.0f,0.0f,1.0f);glPushMatrix();/圆柱台glBegin(GL_QUAD_STRIP);for(float j=0;j50)Angle=0;/旋转角度增量elseAngle +=10;Slee
7、p(100);return TRUE;3. 圆台大到小在前面定义:int Angle = 50;int DrawGLScene(GLvoid)glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glLoadIdentity();int a=10;glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);glEnable(GL_DEPTH_TEST);/启用深度检测glMatrixMode(GL_MODELVIEW);glColor3f(1.0f,0.0f,0.0f);glLoadIdentity();gl
8、Translatef(-0.0f,-0.0f,-22.0f);glScalef(0.05f,0.05f,0.05f);glRotatef(60.0f,1.0f,0.0f,0.0f); glRotatef(0.0f,0.0f,0.0f,1.0f);glPushMatrix();/圆柱台glBegin(GL_QUAD_STRIP);for(float j=0;j0)Angle-=10;/旋转角度增量elseAngle=50 ;Sleep(100);return TRUE;4.圆台前后旋转在前面定义:int Angle = 50;int DrawGLScene(GLvoid)glClear(GL_C
9、OLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glLoadIdentity();int a=10;glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);/清除颜色和深度缓冲区glEnable(GL_DEPTH_TEST);/启用深度检测glMatrixMode(GL_MODELVIEW);glColor3f(1.0f,0.0f,0.0f);glLoadIdentity();glTranslatef(-0.0f,-0.0f,-22.0f);glScalef(0.05f,0.05f,0.05f);glRotatef(90.
10、0f,0.0f,1.0f,0.0f);glRotatef(Angle,0.0f,0.0f,1.0f);glPushMatrix();/圆柱台glBegin(GL_QUAD_STRIP);for(float j=0;j360)Angle=0;/旋转角度增量Sleep(100);return TRUE;5圆柱左右旋转在前面定义:int Angle = 50;int DrawGLScene(GLvoid)glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glLoadIdentity();int a=10;glClear(GL_COLOR_BUFFE
11、R_BIT|GL_DEPTH_BUFFER_BIT);glEnable(GL_DEPTH_TEST);/启用深度检测glMatrixMode(GL_MODELVIEW);glColor3f(1.0f,0.0f,0.0f);glLoadIdentity();glTranslatef(-0.0f,-0.0f,-22.0f);glScalef(0.05f,0.05f,0.05f);glRotatef(90.0f,1.0f,1.0f,1.0f);glRotatef(0.0f,0.0f,0.0f,1.0f);glRotatef(Angle,1.0f,0.0f,0.0f);glPushMatrix();/
12、圆柱台glBegin(GL_QUAD_STRIP);for(float j=0;j363;j+) float k; /k=2/(j+2);glColor3f(1.0f,1.0f,0.0f);glVertex3f(50*cosf(j*3.1416/180),50, 50*sinf(j*3.1416/180) ); glColor3f(0.3f,0.0f,0.8f); glVertex3f(50*cosf(j*3.1416/180),-50, 50*sinf(j*3.1416/180) );/将50改30变圆台 glEnd();glPopMatrix();Angle -=15;if(Angle-3
13、60)Angle=0;/旋转角度增量Sleep(100);return TRUE;6.球前后旋转在前面定义:int Angle = 50;int DrawGLScene(GLvoid)glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glLoadIdentity();int a=10;glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);/清除颜色和深度缓冲区glEnable(GL_DEPTH_TEST);/启用深度检测glMatrixMode(GL_MODELVIEW);glColor3f(1.0
14、f,0.0f,0.0f);glLoadIdentity();glTranslatef(-0.0f,-0.0f,-22.0f);glScalef(0.1f,0.1f,0.1f);glRotatef(30.0f,1.0f,0.0f,0.0f);glRotatef(Angle,1.0f,0.0f,0.0f);glPushMatrix();/球前后旋转glScalef(50,50,50);float rx,ange1=0;for(float i=0;i20;i+)/上下20份float k,j;k=i/20;glBegin(GL_QUAD_STRIP);for( j=0;j360)Angle=0;/旋
15、转角度增量Sleep(100);return TRUE;7.球左右旋转。将上一题中的glRotatef(Angle,1.0f,0.0f,0.0f);改为glRotatef(Angle,0.0f,0.0f,1.0f);将glScalef(50,50,50);改为:glScalef(40,50,50);将Angle +=25;if(Angle360)Angle=0;/旋转角度增量改为:Angle -=30;if(Angle-360)Angle=0;/旋转角度增量8.半球旋转在前面定义:int Angle = 50;int DrawGLScene(GLvoid)glClear(GL_COLOR_BU
16、FFER_BIT | GL_DEPTH_BUFFER_BIT);glLoadIdentity();int a=10;glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);/清除颜色和深度缓冲区glEnable(GL_DEPTH_TEST);/启用深度检测glMatrixMode(GL_MODELVIEW);glColor3f(1.0f,0.0f,0.0f);glLoadIdentity();glTranslatef(-0.0f,-0.0f,-22.0f);glScalef(0.1f,0.1f,0.1f);glRotatef(45.0f,1.0f,0.
17、0f,0.0f);glRotatef(Angle,0.0f,0.0f,1.0f);glPushMatrix();/半球左右旋转glScalef(50,50,50);float rx,ange1=0;for(float i=0;i10;i+)/上下20份float k,j;k=i/10;glBegin(GL_QUAD_STRIP);for( j=0;j360)Angle=0;/旋转角度增量Sleep(100);return TRUE;9. 两个圆锥点对点左右旋转在前面定义:int Angle = 50;int DrawGLScene(GLvoid)glClear(GL_COLOR_BUFFER_
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 图形学 考题 整理
限制150内