opengl游戏设计入门(英文版).pdf

上传人:曲**** 文档编号:96275566 上传时间:2023-10-10 格式:PDF 页数:336 大小:12.96MB
返回 下载 相关 举报
opengl游戏设计入门(英文版).pdf_第1页
第1页 / 共336页
opengl游戏设计入门(英文版).pdf_第2页
第2页 / 共336页
点击查看更多>>
资源描述

《opengl游戏设计入门(英文版).pdf》由会员分享,可在线阅读,更多相关《opengl游戏设计入门(英文版).pdf(336页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、BEBINNINBDpenGLGame ProgrammingTeamLRNCOURSE TECHNOLOGYTHOIVISONDave AstleKevin HawkinsBEBINNINBOpenGLGame ProgrammingTeamLRN 2004 by Pr emier Pr ess,a d iv isio n o f Co u r se Tec h n o l o g y.Al l r ig h t s r eser v ed.No pa r t o f t h is bo o k ma y be r epr o d u c ed o r t r a n smit t ed i

2、n a n y fo r m o r by a n y mea n s,el ec t r o n ic o r mec h a n ic a l,in c l u d in g ph o t o c o pyin g,r ec o r d in g,o r by a n y in fo r ma t io n st o r a g e o r r et r iev a l syst em w it h o u t w r it t en per missio n fr o m Co u r se PTR,ex c ept fo r t h e in c l u sio n o f br ie

3、f q u o t a t io n s in a r ev iew.Th e Pr emier Pr ess l o g o a n d r el a t ed t r a d e d r ess a r c t r a d ema r k s o f Pr emier Pr ess a n d ma y n o t be u sed w it h o u t w r it t en per missio n.Open GL is a r eg ist er ed t r a d ema r k o f SGI.g l Fo n t 2004 Br a d Fish,bh f5ema il.

4、byu.ed u.GLc c 2004 Ben Wo o d h o u se,bc n c l f-st o n c.c o m,w it h pa r t s c o pyr ig h t by SGI.Al l r ig h t s r eser v ed.Al l o t h er t r a d ema r k s a r c t h e pr o per t y o f t h eir r espec t iv e o w n er s.Important:Co u r se PTR c a n n o t pr o v id e so ft w a r e su ppo r t.

5、Pl ea se c o n t a c t t h e a ppr o pr ia t e so ft w a r e ma n u fa c t u r er s t ec h n ic a l su ppo r t l in e o r Web sit e fo r a ssist a n c e.Co u r se PTR a n d t h e a u t h o r s h a v e a t t empt ed t h r o u g h o u t t h is bo o k t o d ist ing u ish pr o pr iet a r y t r a d ema r

6、 k s fr o m d esc r ipt iv e t er ms by fo l l o w in g t h e c a pit a liz a t io n st yl e u sed by t h e ma n u fa c t u r er.In fo r ma t io n c o n t a in ed in t h is bo o k h a s been o bt a in ed by Co u r se PTR fr o m so u r c es bel iev ed t o be r el ia bl e.Ho w ev er,bec a u se o f t h

7、 e po ssibil it y o f h u ma n o r mec h a n ic a l er r o r by o u r so u r c es,Co u r se PTR,o r o t h er s,t h e Pu bl ish er d o es n o t g u a r a n t ee t h e a c c u r a c y,a d eq u a c y,o r c o mpl et en ess o f a n y in fo r ma t io n a n d is n o t r espo n sibl e fo r a n y er r o r s

8、o r o missio n s o r t h e r esu l t s o bt a in ed fr o m u se o f su c h in fo r ma t io n.Rea d er s sh o u l d be pa r t ic u l a r l y a w a r e o f t h e fa c t t h a t t h e In t er n et is a n ev er-c h a n g in g en t it y.So n ic fa c t s ma y h a v e c h a n g ed sin c e t h is bo o k w e

9、n t t o pr ess.Ed u c a t io n a l fa c il it ies,c o mpa n ies,a n d o r g a n iz a t io n s in t er est ed in mu l t ipl e c o pies o r l ic en sin g o f t h is bo o k sh o u l d c o n t a c t t h e pu bl ish er fo r q u a n t it y d isc o u n t in fo r ma t io n.Tr a in in g ma n u a l s,CD-ROMs,

10、a n d po r t io n s o f t h is bo o k a r c a l so a v a il a bl e in d iv id u a l l y o r c a n be t a il o r ed fo r spec ific n eed s.ISBN:1-59200-369-9Libr a r y o f Co n g r ess Ca t a l o g Ca r d Nu mber:2004090734Pr in t ed in t h e Un it ed St a t es o f Amer ic a04 05 06 07 08 BH 10 9 8 7

11、 6 5 4 3 2 1THOIV1SON-COURSE TECHNOLOGYPr o f essio nal Tr ade Ref er enc eCo u r se PTR,a d iv isio n o f Co u r se Tec h n o l o g y25 Th o mso n Pl a c eBo st o n,MA 02210h t t p:w w w.c o u r sept r.c o mSen io r Vic e Pr esid en t,Co u r se PTR Gr o u p:An d y Sh a fr a nPu bl ish er:St a c y L

12、.Hiq u etSen io r Ma r k et in g Ma n a g er:Sa r a h ODo n n el lMa r k et in g Ma n a g er:Hea t h er Hu r l eyMa n a g er o f Ed it o r ia l Ser v ic es:Hea t h er Ta l bo tSen io r Ac q u isit io n s Ed it o r:Emi Smit hAsso c ia t e Ma r k et in g Ma n a g er:Kr ist in Eisen z o pfPr o jec t Ed

13、 it o r:Sa n d y Do c l lTec h n ic a l Rev iew er:Ben Wo o d h o u seRet a il Ma r k et Co o r d in a t o r:Sa r a h Du bo isIn t er io r La yo u t Tec h:Ma r ia n Ha r t so u g hCo v er Desig n er:St ev e Dc sc h c n eCD-ROM Pr o d u c er:Br a n d o n Pc n t ic u ffIn d ex er:Ka t h er in e St ims

14、o nPr o o fr ea d er:Gen e Red d in gTeamLRNFor my family and friends KevinFor my crash of rhinos DaveTeamLRNAcknowledgmentsFir st a n d fo r emo st,I w a n t t o t h a n k my w ife Mel issa a n d my k id s,Rebi,Ev a n,El l ie,Tyl er,a n d Na t e,fo r a l l o f yo u r su ppo r t t h r o u g h o u t

15、t h is pr o jec t,a n d fo r d r a g g in g me a w a y fr o m t h e c o mpu t er ju st o ft en en o u g h fo r me t o r et a in mo st o f my sa n it y.I l o v e yo u a l l.Id a l so l ik e t o t h a n k Kev in,my pa r t n e r a n d c o l l a bo r a t o r,w it h o u t w h o m I n ev er w o u l d h a

16、v e d o n e t h is.I c a n t ima g in e fin d in g a bet t e r t ea mma t e.Big t h a n k s t o ev er yo n e a t Pr emier Pr ess/Co u r se Tec h n o l o g y.Yo u r e a g r ea t g r o u p o f peopl e t o w o r k w it h,a n d 1 g en u in el y a ppr ec ia t e t h e c o n fid en c e yo u pl a c e in me.

17、Ben Wo o d h o u se d eser v es spec ia l men t io n fo r h is effo r t s a s t ec h n ic a l ed it o r.He pr o v id ed v a l u a bl e feed ba c k t h a t h el ped ma k e t h is bo o k mu c h bet t er t h a n it w o u l d h a v e been o t her w ise.Th a n k s a l so t o Th e Mig h t y Pet e fo r a l

18、 l o w in g u s t o u se h is sk ybo x ima g es in ma n y o f t h e ex a mpl e pr o g r a ms,a n d t o Jeff Ro yl e fr o m ATI Tec h n o l o g ies fo r pr o v id in g u s w it h g r a ph ic s h a r d w a r e fo r t est in g pu r po ses.Fin a l l y,1 w a n t t o t h a n k ev er yo n e w h o h a s t a

19、 u g h t me in so me w a y,in c l u d in g Ch u c k Ha n sen,Ro ber t Kessl er a n d my o t h er pr o fesso r s a t t h e Un iv er sit y o f Ut a h,my c o w o r k er s a t Av a l a n c h e So ft w a r e a n d Qu a l c o mm,t h e d en iz en s o f t h e Ga meDc v.n et fo r u ms,a n d ev er yo n e el s

20、e w h o h a s t a k en t h e t ime t o sh a r e t h eir k n o w l ed g e a n d ex per ien c e v ia a Web sit e o r bo o k.Da v e Ast l eTeamLRNAc k n o w l e d g men t sv iiI,d l ik e t o t h a n k Da v e,fo r h is w o r k a s a g o o d t ea mma t e,mo t iv a t o r,a n d fr ien d.Ch a n c es a r e y

21、o u w o u l d n o t be h o l d in g t h is bo o k in yo u r h a n d s if h e h a d n o t u sed a l it t l e fr ien d l y c o er c io n o n me.Im a ma z ed a t w h a t w e w er e a bl e t o a c c o mpl ish w it h t h is pr o jec t,a n d a g o o d d ea l o f it s su c c ess is d u e t o o u r a bil it

22、 y t o w o r k t o g et h er a s a t ea m.1 a l so w a n t t o t h a n k my fa mil y fo r t h eir c o n st a n t su ppo r t fo r me in ev er yt h in g I d o.Oft en t imes t h ey d o n t g et a s mu c h c r ed it a s t h ey sh o u l d be g et t in g.My fr ien d s a n d c o w o r k er s a l so d eser

23、v e a sh a r e o f t h e t h a n k s.Wh et h er t h ey k n o w it o r n o t,Iv e l ea r n ed fr o m a l l o f t h em in so me fo r m o r a n o t h er a n d v a l u e t h eir fr ien d sh ips:Tu c k er,To m,Ch r ist ie,Mik e,Ra el,Kr ist in,Viv ia n,JP,An d y,Gr eg R.,Gr eg S.,Bil l,Kyl e,Ra n d a l l

24、,Jo r d a n,Ha c k,Ju st in,Na t e,Lu k e M.,Mik e M.,Jo h n n y Y.,Nic k M.,a n d so ma n y o t h er s t h a t w e d o n,t h a v e t h e spa c e fo r h er e.Al so,t h a n k yo u t o t h e Pr emier Pr ess g r o u p fo r t h e o ppo rt u n it y t o d o t h is pr o jec t a n d fo r ma in t a in in g a

25、 h ig h d eg r ee o f su ppo r t a n d c o n fid en c e in bo t h Da v e a n d me,a n d in Ga meDev.n et.An d fin a l l y,I w a n t t o t h a n k ev er yo n e w h o h a s pr o v id ed me w it h t h e a bil it y a n d t a l en t,d ir ec t l y o r in d ir ec t l y,t h a t h a s a l l o w ed me t o c r

26、 ea t e t h is bo o k,in c l u d in g t h e pr o fesso r s a t Embr y-Rid d l e,my ba seba l l c o a c h es a n d t ea mma t es,Ch r is Ha r g r o v e,Set h Ro bin so n,Jeff Mo l o fee,Ric h Ben so n,a n d a h o st o f so ft w a r e en g in eer in g c o l l ea g u es.Kev in Ha w k in sTeamLRNAbout t

27、he AuthorsDave Astle h a s been pr o g r a mmin g g a mes pr o fessio n a l l y fo r sev er a l yea r s,w o r k in g o n t it l es fo r t h e Xbo x,Pl a ySt a t io n 2,Ga mc Cu be,PC,a n d v a r io u s w ir el ess d ev ic es.Cu r r en t l y,h e is a l ea d en g in eer in t h e Ga min g a n d Gr a ph

28、 ic s g r o u p a t Qu a l c o mm,In c.He is t h e c o fbu n d c r a n d ex ec u t iv e pr o d u c e r o f Ga meDev.n et,t h e l ea d in g o n l in e c o mmu n it y fo r g a me d ev el o per s.He h a s a u t h o r ed o r c o n t r ibu t e d t o sev er a l g a me d ev el o pmen t bo o k s a n d h a s

29、 spo k en a t in d u st r y c o n fer en c es,in c l u d in g t h e Ga me Dev el o per s,Co n fer en c e.He r ec eiv ed h is ba c h el o r s d eg r ee in Co mpu t er Sc ien c e fr o m t h e Un iv er sit y o f Ut a h,w h er e h e spec ia l iz ed in g r a ph ic s,a r t ific ia l in t el l ig en c e,n

30、et w o r k in g,so ft w a r e en g in e er in g,a n d c o mpil er t h eo r y a n d d esig n.Kevin Hawkins is a l ea d so ft w a r e en g in eer a t Ra yd o n Co r po r a t io n w h er e h e d esig n s a n d d ev el o ps t r a in in g simu l a t io n s fo r a v a r iet y o f c u st o mer s,in c l u d

31、 in g t h e U.S.mil it a r y.In a d d it io n,Kev in is t h e c o fbu n d er a n d CEO o f Ga mc Dev.n et,t h e l ea d in g o n l in e c o mmun it y fo r g a me d ev el o per s.He h o l d s a ma st er s d eg r ee in So ft w a r e En g in eer in g a n d a ba c hel o r s d eg r ee in Co mpu t e r Sc i

32、en c e fr o m Embr y-Rid d l e Un iv er sit y,w h er e h e a l so pl a yed in t er c o l l eg ia t e ba seba l l a n d w a s d r a ft ed by t h e Cl ev el a n d In d ia n s in t h e 2002 a ma t eu r ba seba l l d r a ft.v iiiTeamLRNIn t r o d u c t io n.x v iiPart I OpenGL Basics.1Ch a pt er 1 Th e

33、Ex pl o r a t io n Beg in s Ag a in.3Ch a pt er 2 Cr ea t in g a Simpl e Open GL Appl ic a t io n.13Ch a pt er 3 Open GL St a t es a n d Pr imit iv es.35Ch a pt er 4 Tr a n sfo r ma t io n s a n d Ma t r ic es.67Ch a pt er 5 Co l o r s,Lig h t in g,Bl en d in g,a n d Fo g.99Ch a pt er 6 Bit ma ps a

34、n d Ima g es w it h Open GL.133Ch a pt er 7 Tex t u r e Ma ppin g.149Part II Beyond the Basics.1 83Ch a pt er 8 Open GL Ex t en sio n s.185Ch a pt er 9 Mo r e o n Tex t u r e Ma ppin g.197Ch a pt er 10 Up Yo u r Per fo r ma n c e.221Ch a pt er 11 Displ a yin g Tex t.249Ch a pt er 12 Open GL Bu ffe r

35、 s.261Ch a pt er 13 Th e En d g a me.277Part III Appendices.283Appen d ix A An sw er s t o Rev iew Qu est io n s a n d Ex er c ise s.285Appen d ix B Fu r t h er Rea d in g.295Appen d ix C Wh a t s o n t h e CD.299In d ex.301TeamLRNContentsInt r o duc t io n.xviiPart I OpenGL Basics.1Chapt er 1 The E

36、xpl o r at io n Beg ins.Ag ain.3Wh y Ma k e Ga mes?.3Th e Wo r l d o f 3D Ga mes.4Th e El emen t s o f a Ga me.4Wh a t Is Open GL?.6Open GL Hist o r y.7Open GL Ar c h it ec t u r e.7Rel a t ed Libr a r ies.9A Sn ea k Peek.10Su mma r y.12Chapt er 2 Cr eat ing a Simpl e OpenGL Appl ic at io n.13In t r

37、 o d u c t io n t o WGL.13Th e Ren d er in g Co n t ex t.14Pix el Fo r ma t s.16d w Fl a g s.18iPix el l ype.18c Co l o r Bit s.19Set t in g t h e Pix el Fo r ma t.19TeamLRNCo n t en t sx iAn Open GL Appl ic a t io n.20Fu l l-Sc r een Open GL.31Su mma r y.33Chapt er 3 OpenGL St at es and Pr imit ive

38、s.35St a t e Fu n c t io n s.35Qu er yin g Nu mer ic St a t es.36En a bl in g a n d Disa bl in g St a t es.36g l l s En a bl ed().37Qu er yin g St r in g Va l u e s.37Fin d in g Er r o r s.38Giv in g Open GL a Hin t.39Ha n d l in g Pr imit iv es.39Dr a w in g Po in t s in 3D.42Dr a w in g Lin es in

39、3D.47Dr a w in g Po l yg o n s in 3D.52Usin g Pr imit iv es:Tr ia n g l es a n d Qu a d s Ex a mpl e.60At t r ibu t es.64Su mma r y.65Chapt er 4 Tr ansf o r mat io ns and Mat r ic es.67Un d er st a n d in g Co o r d in a t e Tr a n sfo r ma t io n s.67Eye Co o r d in a t es.69View in g Tr a n sfo r

40、ma t io n s.70Mo d el in g Tr a n sfo r ma t io n s.71Pr o jec t io n Tr a n sfo r ma t io n s.73View po r t Tr a n sfo r ma t io n s.73Open GL a n d Ma t r ic es.73Th e Mo d el v iew Ma t r ix.74Tr a n sl a t io n.75Ro t a t io n.77Sc a l in g.80Ma t r ix St a c k s.82Th e Ro bo t Ex a mpl e.84Pr o

41、 je c t io n s.87Or t h o g r a ph ic.87Per spec t iv e.88Set t in g t h e View po r t.89Pr o jec t io n Ex a mpl e.90TeamLRNx iiCo n t en t sMa n ipu l a t in g t h e View po in t.91Usin g g l u Lo o k At().92Usin g g l Ro t a t e()a n d g l Tr a n sl a t e().93Cr ea t in g Yo u r Ow n Cu st o m Ro

42、 u t in e s.94Usin g Yo u r Ow n Ma t r ic es.95Lo a d in g Yo u r Ma t r ix.95Mu l t ipl yin g Ma t r ic e s.96Tr a n spo se Ma t r ic e s.96Su mma r y.97Chapt er 5 Co l o r s,Lig ht ing,Bl ending,and Fo g.99Usin g Co l o r s in Open GL.99Set t in g t h e Co l o r.100Sec o n d a r y Co l o r.101Sh

43、a d in g.102A Co l o r fu l Ex a mpl e.104Lig h t in g in Open GL.104Open GL Lig h t in g a n d t h e Rea l Wo r l d.104Lig h t So u r c es.106Spo t l ig h t s.109Ma t e r ia l s.111No r ma l s.115Th e Lig h t in g Mo d el.118Lig h t in g in Ac t io n.120Bl en d in g.121Sepa r a t e Bl en d Fu n c t

44、 io n s.125Th e Bl en d Eq u a t io n.125Co n st a n t Bl en d Co l o r.127Disk Bl en d er.127Fo g 128 Open GL Fo g.128Fo g Co o r d in a t es.130Fo g in Ac t io n.131Su mma r y.131Chapt er 6 Bit maps and Imag es w it h OpenGL.133Th e Open GL Bit ma p.133Po sit io n in g t h e Bit ma p.134Dr a w in

45、g t h e Bit ma p.135An Open GL Bit ma p Ex a mpl e.136TeamLRNCo n t en t sx iiiUsin g Ima g es.138Dr a w in g Ima g e Da t a.139Rea d in g fr o m t h e Sc r een.141Co pyin g Sc r een Da t a.141Ma g n ific a t io n,Red u c t io n,a n d Fl ippin g.142Ma n a g in g Pix el St o r a g e.142Ta r g a Ima g

46、 e Fil es.143Th e Ta r g a Fil e Fo r ma t.143Lo a d in g Ta r g a Fil es.145Su mma r y.147Chapt er 7 Text ur e Mapping.149An Ov er v iew o f Tex t u r e Ma ppin g.150Tex t u r e Co o r d in a t es.151Usin g t h e Tex t u r e Ma p.152Tex t u r e Objec t s.152Spec ifyin g Tex t u r es.155Tex t u r e

47、Fil t er in g.161Ba sic Tex t u r e Ex a mpl e.163Mipma ps.166Mipma ps a n d t h e Open GL Ut il it y Libr a r y.167Au t o ma t ic Mipma p Gen er a t io n.168Tex t u r e Pa r a met er s.169Tex t u r e Wr a p Mo d es.170Tex t u r e Lev el o f Det a il.173Tex t u r e En v ir o n men t s a n d Tex t u

48、r e Fu n c t io n s.174Spec ifyin g t h e Tex t u r e En v ir o n men t.175Tex t u r ed Ter r a in.178Bu il d in g t h e Mes h.178Su mma r y.181Part II Beyond the Basics.1 S3Chapt er 8 OpenGL Ext ensio ns.185An a t o my o f a n Ex t en sio n.185Ex t en sio n Na me s.186Na me St r in g s.187Fu n c t

49、io n s.187To k en s.188TeamLRNx ivCo n t en t sUsin g Ex t en sio n s.188Ch ec k in g t h e Na me St r in g.189Obt a in in g t h e Fu n c t io n s En t r y Po in t.190Dec l a r in g En u mer a n t s.191WGL Ex t en sio n s.191In t r o d u c t io n t o GLee.192Set t in g Up GLee.193Usin g GLee.193Usin

50、 g GLee w it h Co r e Ex t en sio n s.194Ex t en sio n s in Ac t io n.195Su mma r y.195Chapt er 9 Mo r e o n Text ur e Mapping.197Mo r e o n Tex t u r e Spec ific a t io n.197Su b-Ima g es.197Co pyin g fr o m t h e Co l o r Bu ffer.198Th e Tex t u r e Ma t r ix St a c k.201Tex t u r e Co o r d in a

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 技术资料 > 其他杂项

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁