资源描述:
《using.opengl.in.visual.c》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、UsingOpenGLinVisualC++winxos11-01-28winxos11-01-28byAlanOurslandCopyright©2000InterfaceTechnologies,Inc.AllRightsReserved.SeriesOverviewWiththereleaseofNT3.5,OpenGLbecameapartoftheWindowsoperatingsystem.NowwithsupportforOpenGLinWindows95andWindows98andlowpricedgraphics
2、acceleratorsbecomingreadilyavailableevenonlowendmachines,theprospectsofusingOpenGLonanyWindowsmachineisbecomingmoreattractiveeveryday.Ifyouareinterestedincreatingquality2-Dor3-DgraphicsinWindows,orifyoualreadyknowanothervariantofGL,keepreading.Thistutorialwillshowyouho
3、wtouseOpenGLandsomeofitsbasiccommands.GLisaprogramminginterfacedesignedbySiliconGraphics.OpenGLisagenericversionoftheinterfacemadeavailabletoawidevarietyofoutsidevendorsintheinterestofstandardizationofthelanguage.OpenGLallowsyoutocreatehighquality3-Dimageswithoutdealin
4、gwiththeheavymathusuallyassociatedwithcomputergraphics.OpenGLhandlesgraphicsprimitives,2-Dand3-Dtransformations,lighting,shading,Z-buffering,hiddensurfaceremoval,andahostofotherfeatures.I'llusesomeofthesetopicsinthesampleprogramsfollowing;othersI'llleavetoyoutoexplorey
5、ourself.IfyouwanttolearnmoreaboutOpenGLyoucansearchtheMSDNwebsiteforthekeyword"OpenGL".Hereisthelistoftopicscoveredinthisseries:1.WritinganOpenGLProgram2.Simple2-DGraphics3.TransformationsandtheMatrixStack4.Simple3-DGraphicsWritinganOpenGLProgramThefirstprogramdemonstr
6、atedherewillshowyoutheminimumrequirementsforsettingupaWindowsprogramtodisplayOpenGLgraphics.AsGDIneedsaDeviceContext(DC)todrawimages,OpenGLrequiresaRenderingContext(RC).UnlikeGDI,inwhicheachGDIcommandrequiresthataDCispassedintoit,OpenGLusestheconceptofacurrentRC.Oncear
7、enderingcontexthasbeenmadecurrentinathread,allOpenGLcallsinthatthreadwillusethesamecurrentrenderingcontext.Whilemultiplerenderingcontextsmaybeusedtodrawinasinglewindow,onlyonerenderingcontextmaybecurrentatanytimeinasinglethread.Thegoalofthissampleistocreateandmakecurre
8、ntanOpenGLrenderingcontext.Therearethreestepstocreatingandmakingcurrentarenderingcontext:1.Setthewindow'spixelformat.