欢迎来到天天文库
浏览记录
ID:9946360
大小:53.71 KB
页数:16页
时间:2018-05-16
《《面向对象的程序设计》课程设计作业》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、郑州大学环境与水利学院《面向对象的程序设计》课程设计计算说明书专业:地理信息系统学生姓名:学生学号:指导教师:2011年12月7日Lesson07TextureFilters,Lighting&KeyboardControl第八课纹理滤波方式,和键盘控制InthistutorialI'llteachyouhowtousethreedifferenttexturefilters.I'llteachyouhowtomoveanobjectusingkeysonthekeyboard,andI'llalsoteac
2、hyouhowtoapplysimplelightingtoyourOpenGLscene.Lotscoveredinthistutorial,soiftheprevioustutorialsaregivingyouproblems,gobackandreview.It'simportanttohaveagoodunderstandingofthebasicsbeforeyoujumpintothefollowingcode.We'regoingtobemodifyingthecodefromlessonon
3、eagain.Asusual,ifthereareanymajorchanges,Iwillwriteouttheentiresectionofcodethathasbeenmodified.We'llstartoffbyaddingafewnewvariablestotheprogram.这一课我将教你如何使用三种不同的纹理滤波方式。我将教你如何使用键盘来移动场景中的对象,还会教你在OpenGL场景中添加简单的光照。这一课包含了很多内容,所以如果你之前的课程仍存在问题,就先回头复习一下。学习后面的代码之前,
4、很好的理解基础知识十分重要。我们准备在第一课的代码上稍作修改。跟以前一样,只要有任何大的改动,我都会写出整段被改动的代码。我们将以添加几个新的变量作为开始。#include//Window头文件#include//StandardInput/Output(ADD)头文件#include//TheOpenGL32Library头文件#include//TheGLu32Library头文件#include//Th
5、eGLauxLibrary头文件HDChDC=NULL;//GDIDeviceContextHGLRChRC=NULL;//RenderingContextHWNDhWnd=NULL;//窗体Window句柄HINSTANCEhInstance;//程序Instance句柄boolkeys[256];//用于键盘控制的矩阵boolactive=TRUE;//窗体激活标志boolfullscreen=TRUE;//全屏标志,缺省为真Thelinesbelowarenew.We'regoingtoaddthree
6、booleanvariables.BOOLmeansthevariablecanonlybeTRUEorFALSE.Wecreateavariablecalledlighttokeeptrackofwhetherornotthelightingisonoroff.Thevariableslpandfpareusedtostorewhetherornotthe'L'or'F'keyhasbeenpressed.I'llexplainwhyweneedthesevariableslateroninthecode.
7、Fornow,justknowthattheyareimportant下面几行是新的。我们将增加三个布尔变量。BOOL意味着变量只能是TRUE和FALSE。我们创造了light变量跟踪光照是否打开。变量lp和fp用来存储'L'和'F'键是否按下。后面我会解释为什么我们在代码中需要这些变量。现在,仅仅先记住他们很重要。BOOL light; //光源的开/关BOOL lp; //L键按下了么?BOOL fp; //F键按下了么?Nowwe'regoingtoset
8、upfivevariablesthatwillcontroltheangleonthexaxis(xrot),theangleontheyaxis(yrot),thespeedthecrateisspinningatonthexaxis(xspeed),andthespeedthecrateisspinningatontheyaxis(yspeed).We'llalsocreateavariable
此文档下载收益归作者所有