欢迎来到天天文库
浏览记录
ID:35342224
大小:102.75 KB
页数:3页
时间:2019-03-23
《实验报告8(用opengl生成曲线)》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、实验八:用OpenGL生成曲线实验目的:一、理解Bezier曲线和B样杀曲线的定义、性质及绘制算法。二、理解OpenGL中窗口坐标与世界坐标的映射关系。三、掌握OpenGL的Bezier曲线和NURBS曲线的绘制方法。实验内容:文件一:StdAfx.cpp//stdafx.cppjsourcefilethatincludesjustthestandardincludes//OpenGL框架.pchwillbethepre-compiledheader//stdafx.objwillcontainthepre-compiledty
2、peinformationinclude"stdafx.h"//TODO:referenceanyadditionalheadersyouneedinSTDAFX.H//andnotinthisfile文件二:StdAfx.h//stdafx.h:includefileforstandardsystemineludefiles,//orprojectspecificincludefilesthatareusedfrequently,but//arechangedinfrequently//#if!defined(AFXSTDAF
3、XHA9DB83DBA9FD11DOBFD1444553540000INCLUDEDJ#defineAFX_STDAFX_H_A9DB83DB_A9FD_11D0_BFD1_444553540000_INCLUDED廿pe###_VER>1000once_MSC_VER>1000#defineWIN32_LEANANDMEAN//Excluderarely-usedstu什fromWindowsheaders#includeinclude//OpenGL32库的头文件#include4、glu.h>//GLu32库的浜文彳牟#include//GLaux库的头文件#pragmacomment(lib,nwinmm.libn)#pragmacomment(lib,"opengl32.lib")//OpenGL32连接库#pragmacomment(lib,勺IL32」ibJ//GLu32逢接库#pragmacomment(lib,"glaux.lib11)//GLaux连接库//TODO:referenceadditionalheadersyourprogramrequireshere/5、/{{AFX_INSERT_LOCATION}}//MicrosoftVisualC++willinsertadditionaldeclarationsimmediatelybeforethepreviousline.熔剋僵严(AFX_STDAFX_H_A9DB8皿A9FDJ1D0_BFD1_444553540000_l文件三:bzcurve.cpp#includel,stdafx.h11voidmyinit(void);voidCALLBACKmyReshape(GLsizeiw,GLsizeih);voidCALLBACKd6、isplay(void);GLfloatctrlpoints[4][3]={{40厂400.0},-2.0,4.0,0.0},{204000},{40400.0}voidmyinit(void)glClearColor(0.0,0.0,0.0,1.0);glMap1f(GL_MAP1_VERTEX3,0.0,1.0,3,4,&ctrlpoints[0][0]);glEnable(G匚MAP匸VERTEXL3);glShadeModel(G「FLAT);一voidCALLBACKdisplay(void){inti;glClear7、(GL_COLOR_BUFFER_BIT);glColor3f(1X),1.0,1.0);glBegin(GL_LINE_STRIP);for(i=0;i<=30;i++)glEvalCoordlf((GLfloat)i/30.0);glEnd();/*显示控制点*/glPointSize(5.0);glColor3f(1.0,1.0,0.0);glBegin(GL_POINTS);for(i=0;i<4;i++)voidCALLBACKmyReshape(GLsizeiw,GLsizeih){glViewport(0,0,w,8、h);glMatrixMode(GL_PROJECTION);glLoadldentityO;if(w<=h)glOrtho(-5.0,5.0,-5.0*(GLfloat)h/(GLfloat)w,5.0*(GLfloat)h/(GLfloat)w,-5.0,5
4、glu.h>//GLu32库的浜文彳牟#include//GLaux库的头文件#pragmacomment(lib,nwinmm.libn)#pragmacomment(lib,"opengl32.lib")//OpenGL32连接库#pragmacomment(lib,勺IL32」ibJ//GLu32逢接库#pragmacomment(lib,"glaux.lib11)//GLaux连接库//TODO:referenceadditionalheadersyourprogramrequireshere/
5、/{{AFX_INSERT_LOCATION}}//MicrosoftVisualC++willinsertadditionaldeclarationsimmediatelybeforethepreviousline.熔剋僵严(AFX_STDAFX_H_A9DB8皿A9FDJ1D0_BFD1_444553540000_l文件三:bzcurve.cpp#includel,stdafx.h11voidmyinit(void);voidCALLBACKmyReshape(GLsizeiw,GLsizeih);voidCALLBACKd
6、isplay(void);GLfloatctrlpoints[4][3]={{40厂400.0},-2.0,4.0,0.0},{204000},{40400.0}voidmyinit(void)glClearColor(0.0,0.0,0.0,1.0);glMap1f(GL_MAP1_VERTEX3,0.0,1.0,3,4,&ctrlpoints[0][0]);glEnable(G匚MAP匸VERTEXL3);glShadeModel(G「FLAT);一voidCALLBACKdisplay(void){inti;glClear
7、(GL_COLOR_BUFFER_BIT);glColor3f(1X),1.0,1.0);glBegin(GL_LINE_STRIP);for(i=0;i<=30;i++)glEvalCoordlf((GLfloat)i/30.0);glEnd();/*显示控制点*/glPointSize(5.0);glColor3f(1.0,1.0,0.0);glBegin(GL_POINTS);for(i=0;i<4;i++)voidCALLBACKmyReshape(GLsizeiw,GLsizeih){glViewport(0,0,w,
8、h);glMatrixMode(GL_PROJECTION);glLoadldentityO;if(w<=h)glOrtho(-5.0,5.0,-5.0*(GLfloat)h/(GLfloat)w,5.0*(GLfloat)h/(GLfloat)w,-5.0,5
此文档下载收益归作者所有