资源描述:
《3d游戏编程:opengl入门》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、OpenGL:IntroductionYanciZhangGameProgrammingIIOutlineOverviewofOpenGLOpenGLvs.DirectXOpenGL“HelloWorld”GLUTlibraryRenderingpipelineCoordinatesystemGameProgrammingIIWhatisOpenGL?OpenGL=OpenGraphicsLibraryGraphicsrenderingAPIProducehigh-qualitycolorimagescomposedof3Dgeometricobject
2、sandimagesHardwareindependentCrossplatformGameProgrammingIIBasicFunctionBasesformanyadvanceddatastructuresingameprogrammingTypicalapplicationsScenegraphStategraphDecisiontreeKd-tree,quadtree…GameProgrammingIIWhatCanOpenGLDo?Renderingbasicprimitives,likepoints,lines,triangles…Ma
3、trixoperationsLocalilluminationTexturemappingPixeloperations…GameProgrammingIIWhatCanNotOpenGLDo?CreatewindowsHandlewindoweventsResponsetouserinputScenemanagement…GameProgrammingIIOpenGLvs.DirectX1/2OpenGLisonlygraphicslibraryDirectXhandlesgraphics,audio,userinputUseOpenGLimpr
4、operly,systemdoesnothingUseDirectXimproperly,systemdoessomethingbeyondexpectationGameProgrammingIIOpenGLvs.DirectX2/2OpenGLIndustrystandardmaintainedbyOpenGLArchitecturalReviewBoard(ARB)StablefunctioninterfaceCrossplatformVeryclean,easytolearnDirectXMicrosoft’sproductInstablefu
5、nctioninterfaceOnlysupportWindowsGameProgrammingIIOpenGLFunctionsNamingWithprefixglCapitalletterforeachnewwordExamplesglBegin,glEndglEnable,glDisableglClearGameProgrammingIIDataType&ConstantBasicdatatypeWithprefixGLAllsmalllettersSimilartoC++datatypeExample:GLdouble=double,GL
6、float=float,GLint=int,GLuint=unsignedintConstantWithprefixGL_AllcapitallettersExamples:GL_POINTS,GL_CCWGameProgrammingIIHelloWorld1/3#includeAllopenglprogramsshouldincludegl.h.#includeAlmostallopenglprogramsincludeglu.hmain(){initWindow();Initializewindowwhichisapla
7、tform-dependentoperationglClearColor(0.0,0.0,0.0,0.0);ClearwindowswithblackcolorglClear(GL_COLOR_BUFFER_BIT);glColor3f(1.0,1.0,1.0);UsewhitecolortostartrenderingsomethingonthescreenglOrtho(0.0,1.0,0.0,1.0,-1.0,1.0);SpecifyprojectionmatrixGameProgrammingIIHelloWorld2