OpenGL中真实感图形的显示实现

OpenGL中真实感图形的显示实现

ID:40568573

大小:90.00 KB

页数:6页

时间:2019-08-04

OpenGL中真实感图形的显示实现_第1页
OpenGL中真实感图形的显示实现_第2页
OpenGL中真实感图形的显示实现_第3页
OpenGL中真实感图形的显示实现_第4页
OpenGL中真实感图形的显示实现_第5页
资源描述:

《OpenGL中真实感图形的显示实现》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、实验名称OpenGL中真实感图形的显示实现一、实验目的学习基于OpenGL真实感图形显示的原理与实现方法。二、实验内容利用向导生成应用程序框架,参考示例编写实现三维图形的应用程序,增加光照与材质效果实现真实感图形的显示。三、实验步骤1.利用向导生成应用程序框架。2.添加相应的函数,绘制立方体(参照上课给的实例)。3.添加相应的函数,实现三维球体的绘制。4.增加光源,并设置光源参数与材质参数,观察显示效果。实验代码及程序运行结果截图如下://2008cube.cpp:Definestheentrypointforthecon

2、soleapplication.//#include"stdafx.h"#include"gl/glut.h"#include"math.h"voidmyinit(){glClearColor(1.0,1.0,1.0,0.0);glMatrixMode(GL_PROJECTION);glLoadIdentity();glOrtho(-1.5,1.5,-1.5,1.5,-1.5,1.5);}voiddraw_cube(){glClear(GL_COLOR_BUFFER_BIT);glColor3f(1.0,0.0,0.0);

3、glBegin(GL_POLYGON);glVertex3f(0.0,0.0,0.0);glVertex3f(0.0,1.0,0.0);glVertex3f(1.0,1.0,0.0);glVertex3f(1.0,0.0,0.0);glEnd();glColor3f(0.0,1.0,0.0);glBegin(GL_POLYGON);glVertex3f(0.0,0.0,0.0);glVertex3f(0.0,1.0,0.0);glVertex3f(0.0,1.0,1.0);glVertex3f(0.0,0.0,1.0);g

4、lEnd();glColor3f(0.0,0.0,1.0);glBegin(GL_POLYGON);glVertex3f(0.0,0.0,1.0);glVertex3f(0.0,1.0,1.0);glVertex3f(1.0,1.0,1.0);glVertex3f(1.0,0.0,1.0);glEnd();glColor3f(1.0,1.0,0.0);glBegin(GL_POLYGON);glVertex3f(1.0,0.0,0.0);glVertex3f(1.0,1.0,0.0);glVertex3f(1.0,1.0,

5、1.0);glVertex3f(1.0,0.0,1.0);glEnd();glColor3f(1.0,0.0,1.0);glBegin(GL_POLYGON);glVertex3f(0.0,1.0,0.0);glVertex3f(1.0,1.0,0.0);glVertex3f(1.0,1.0,1.0);glVertex3f(0.0,1.0,1.0);glEnd();}voiddisplay(){glClear(GL_COLOR_BUFFER_BIT);glColor3f(1.0,0.0,0.0);gluLookAt(0.5

6、,0.5,0.0,1.0,1.0,1.0,1.0,0.0,1.0);glutWireCube(0.5);draw_cube();glFlush();}voidmain(intargc,char*argv[]){glutInit(&argc,argv);glutInitDisplayMode(GLUT_SINGLE

7、GLUT_RGB);glutInitWindowSize(300,300);glutCreateWindow("立方体的绘制");glutDisplayFunc(display);myinit();glutMai

8、nLoop();}//2008sphere.cpp:Definestheentrypointfortheconsoleapplication.//#include"stdafx.h"#include"gl/glut.h"#include"math.h"#defineM_PI3.1415926voiddraw_sphere(){doublec=M_PI/180.0;floatphi,phir,theta,thetar,x,y,z,phir20;glColor3f(1.0,1.0,1.0);for(phi=-10.0;phi<

9、100.0;phi+=4.0){phir=c*phi;phir20=c*(phi+20);glBegin(GL_QUAD_STRIP);for(theta=-200.0;theta<=200.0;theta+=1.0){thetar=c*theta;x=sin(thetar)*cos(phir);y=c

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。