计算机图形-OpenGL几何变换.doc
文本预览下载声明
实验名称:OpenGL几何变换(实验二)
班级:信09-1
学号:2108190911211
姓名:王杰
【实验目的】
1、掌握GLUT中多面体和二次曲面的生成
2、掌握基本三维几何变换
【实验内容】
源程序
#include glut.h
GLsizei winWidth=500,winHeight=500;
void init(void)
{
glClearColor(1.0,1.0,1.0,1.0);
}
void displayWirePolyhedra(void)
{
glClear(GL_COLOR_BUFFER_BIT);//shut
glColor3f(0.0,9.0,0.0);
glTranslatef(0.0,0.0,-5.0);
glRotatef(45,2,2,2);//(1)四面体
//glutWireCube (2);//(2)六面体
//glutWireOctahedron ();//(3)八面体
//glutWireDodecahedron ( );//(4)十二面体
//glutWireIcosahedrion ( );//(5)二十面体
//glutWireSphere ( 1, 30, 30 );//(1)球面
//glutWireCone ( 1 , 2 , 20 , 20 );//(2)圆锥面
glutWireTorus ( 0.3, 0.2 , 10 , 10 );//(3)环面
glTranslatef(1.5,0.5,0.0);
glutWireTetrahedron();
glTranslatef(-3,-2.0,0.0);
glutWireOctahedron ();
glTranslatef(3,-1.0,0.0);
glutWireSphere ( 1, 15, 15 );
glFlush();
}
void winReshapeFcn(GLint newWidth,GLint newHeight)
{
glViewport(0,0,newWidth,newHeight);
glMatrixMode(GL_PROJECTION);
glFrustum(-1.0,1.0,-1.0,1.0,2.0,20.0);
glMatrixMode(GL_MODELVIEW);
glClear(GL_COLOR_BUFFER_BIT);
}
void main(int argc,char** argv)
{
glutInit(argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowPosition(100,100);
glutInitWindowSize(winWidth,winHeight);
glutCreateWindow(hello);
init();
glutDisplayFunc(displayWirePolyhedra);
glutReshapeFunc(winReshapeFcn);
glutMainLoop();
}
运行结果截图
多面体、二次曲面函数功能及使用说明
多面体:
(1)四面体
glutWireTetrahedron ( )
(2)六面体
glutWireCube ( edgeLength )
(3)八面体
glutWireOctahedron ( )
(4)十二面体
glutWireDodecahedron ( )
(5)二十面体
glutWireIcosahedrion ( )
二次曲面:
(1)球面
glutWireSphere ( r , nLongtitudes , nLatitudes )
(2)圆锥面
glutWireCone ( rBase , height , nLongtitudes , nLatitudes )
(3)环面
glutWireTorus ( rCrossSection , rAxial , nCondentrics , nRadialSlice )
计算机图形学与可视化(含OpenGL)实验报告
北京建筑工程学院理学院 信息与计算科学
显示全部