Quake IIã®ãœãŒã¹ã³ãŒãã®èªã¿åãã«è²»ãããçŽ1ãæã®ç©ºãæéã idTech3ãšã³ãžã³ã¯å€§ããªå€åãããããããããé©ãã»ã©æçãªçµéšã§ãããQuake1ãQuake Worldãããã³QuakeGLã¯ã1ã€ã®çŸããã³ãŒãã¢ãŒããã¯ãã£ã«çµ±åãããŠããŸãã ç¹ã«èå³æ·±ãã®ã¯ãCããã°ã©ãã³ã°èšèªãå€çžæ§ãæäŸããªããšããäºå®ã«ãããããããã¢ãžã¥ãŒã«æ§ãéæãããæ¹æ³ã§ããã
Quake IIã¯ãå€ãã®ç¹ã§ããœãããŠã§ã¢ã®çŽ æŽãããäŸã§ããããã¯ããããïŒã©ã€ã»ã³ã¹ã®æ°ã§ïŒæã人æ°ã®ãã3次å ãšã³ãžã³ã§ãã£ãããã§ãã ããã«åºã¥ããŠã30以äžã®ã²ãŒã ãäœæãããŸããã ããã«ã圌ã¯ã²ãŒã æ¥çã®ãœãããŠã§ã¢/ 8ãããã«ã©ãŒã·ã¹ãã ããããŒããŠã§ã¢/ 24ããããžã®ç§»è¡ã瀺ããŸããã ãã®ç§»è¡ã¯1997幎é ã«çºçããŸããã
ãããã£ãŠãããã°ã©ãã³ã°ã奜ããªäººã¯ãã®ãšã³ãžã³ãåŠã¶ããšã匷ããå§ãããŸãã ãã€ãã®ããã«ãç§ã¯ç¡æ°ã®ã¡ã¢ãä¿ç®¡ããæŽçããŠæ°æéãç¯çŽããããã«èšäºãšããŠå ¬éããŸããã
ãã¯ãªãŒãã³ã°ãã®ããã»ã¹ã¯éåžžã«å€¢äžã«ãªããŸãããçŸåšããã®èšäºã«ã¯40ã¡ã¬ãã€ã以äžã®ãããªãã¹ã¯ãªãŒã³ã·ã§ãããã€ã©ã¹ãããããŸãã ç§ã®ä»äºã«ããã ãã®äŸ¡å€ããããã©ããããããŠå°æ¥ASCIIã§æªåŠçã®ã¡ã¢ãå ¬éããå¿ èŠããããã©ããã¯ããããŸããããããªãã®æèŠãè¿°ã¹ãŠãã ããã
æåã®äŒè°ãšç·šé
ãœãŒã¹ã³ãŒãã¯id Software ftpãµã€ãããç¡æã§å ¥æã§ããŸãã ãã®ãããžã§ã¯ãã¯Visual Studio Express 2008ã§éãããšãã§ããMicrosoft Webãµã€ãããç¡æã§ããŠã³ããŒãããããšãã§ããŸãã
æåã®åé¡ã¯ãVisual Studio 6ã®äœæ¥ç°å¢ã1ã€ã§ã¯ãªã5ã€ã®ãããžã§ã¯ããäœæããããšã§ãã ããã¯ãQuake2ãã¢ãžã¥ãŒã«æ¹åŒã§éçºãããããã§ãïŒããã«ã€ããŠã¯åŸã§èª¬æããŸãïŒã ãããžã§ã¯ãã®çµæã¯æ¬¡ã®ãšããã§ãã
ãããžã§ã¯ã | çµç« |
ctf | gamex86.dll |
ã²ãŒã | gamex86.dll |
å°é2 | quake.exe |
ref_soft | ref_soft.dll |
ref_gl | ref_gl.dll |
泚2ïŒ DirectXããããŒããªããããæåã«ãã«ãã倱æããŸãã
fatal error C1083: Cannot open include file: 'dsound.h': No such file or directory
Direct3D SDKãšMicrosoft SDKïŒMFCçšïŒãã€ã³ã¹ããŒã«ãããã¹ãŠãæ£åžžã«ã³ã³ãã€ã«ãããŸããã
ãœãããŠã§ã¢ã®äŸµé£ïŒ Quake 2ã§Quakeã³ãŒãããŒã¹ã§èµ·ãã£ãããšã¯èµ·ããå§ããããã§ããVisualStudio 2010ã§äœæ¥ç°å¢ãéãããšã¯äžå¯èœã§ããVS2008ã䜿çšããå¿ èŠããããŸãã
泚ïŒã³ã³ãã€ã«åŸã«ãšã©ãŒãçºçããå Žå
"Couldn't fall back to software refresh!"
ã
ããã¯ãã¬ã³ãã©ãŒDLLãæ£ããããŒãã§ããªãã£ãããšãæå³ããŸãã ããããããã¯ç°¡åã«ä¿®æ£ã§ããŸãã
Quake2ã«ãŒãã«ã¯ãwin32 APIïŒLoadLibraryã䜿çšããŠ2ã€ã®DLLãããŒãããŸãã DLLãäºæãããã®ã§ã¯ãªãå ŽåããŸãã¯DLLã®äŸåé¢ä¿ã解決ã§ããªãå Žåããšã©ãŒã¡ãã»ãŒãžã衚瀺ããã«ãšã©ãŒãçºçããŸãã ãããã£ãŠïŒ
- 5ã€ã®ãããžã§ã¯ããã¹ãŠã1ã€ã®ã©ã€ãã©ãªã«æ¥ç¶ããŸã-åãããžã§ã¯ããå³ã¯ãªãã¯->ããããã£-> C / C ++ïŒãã©ã³ã¿ã€ã ã©ã€ãã©ãªã=ãã«ãã¹ã¬ãããããã°DLLïŒæ§æããããã°ããããã§ãªããã°ãªãªãŒã¹ã䜿çšïŒã確èªããŸãã
id SoftwareããªãªãŒã¹ããquake2ããŒãžã§ã³ã䜿çšããŠããå Žåãããã§ãšã©ãŒãä¿®æ£ãããŸãã
- ç§ã®ããŒãžã§ã³ã䜿çšããŠããå ŽåïŒã¹ã¯ãªãŒã³ã·ã§ããããšã³ãžã³ã®PNGã«ä¿åããæ©èœãè¿œå ããã®ã§ãlibpngãšlibzããã«ãããå¿ èŠããããŸãïŒãããã¯ãµããã£ã¬ã¯ããªã«ãããŸãïŒã ãããã°DLLæ§æãéžæãããŠããããšã確èªããŠãã ããã ãã«ããããšããlibpngããã³zlib DLLãquake2.exeãšåããã©ã«ããŒã«çœ®ãããšãå¿ããªãã§ãã ããã
Quake2ã¢ãŒããã¯ãã£
Quake 1ã³ãŒããèªãã ãšãã èšäº ïŒç¿»èš³ã¯ãã¡ã ïŒã3ã€ã®éšåã«åå²ããŸããïŒããããã¯ãŒã¯ãããäºæž¬ãããèŠèŠåãã ãã®ã¢ãããŒãã¯Quake 2ã«é©ããŠããŸããäžæ žãšãªããšã³ãžã³ã¯ããã»ã©å€§ããªéãã¯ãããŸããããèšäºã次ã®3ã€ã®äž»èŠãªã¿ã€ãã®ãããžã§ã¯ãã«åå²ãããšæ¹åããããããããªããŸãã
ãããžã§ã¯ãã®çš®é¡ | ãããžã§ã¯ãæ å ± |
ã¡ã€ã³ãšã³ãžã³ïŒ.exeïŒ | ã¢ãžã¥ãŒã«ãåŒã³åºããã¯ã©ã€ã¢ã³ããšãµãŒããŒéã§æ
å ±ã亀æããã«ãŒãã«ã å®çšŒåç°å¢ã§ã¯ãããã¯quake2
ãããžã§ã¯ãã§ãã |
ã¬ã³ãã©ãŒã¢ãžã¥ãŒã«ïŒ.dllïŒ | èŠèŠåãæ
åœããŸãã äœæ¥ç°å¢ã«ã¯ããœãããŠã§ã¢ã¬ã³ãã©ãŒïŒ ref_soft
ïŒãšOpenGLã¬ã³ãã©ãŒïŒ ref_gl
ïŒãå«ãŸããŠããŸãã |
ã²ãŒã ã¢ãžã¥ãŒã«ïŒ.dllïŒ | ã²ãŒã ãã¬ã€ïŒã²ãŒã ã³ã³ãã³ããæŠåšãã¢ã³ã¹ã¿ãŒã®åäœãªã©ïŒãæ
åœããŸãã å®çšŒåç°å¢ã«ã¯ãã·ã³ã°ã«ãŠãŒã¶ãŒã¢ãžã¥ãŒã«ïŒ game
ïŒãšCapture The Flagã¢ãžã¥ãŒã«ïŒ ctf
ïŒãå«ãŸããŠããŸãã |
win32/sys_win.c
ãŸãã
WinMain
ã¡ãœããã¯ã次ã®ã¿ã¹ã¯ãå®è¡ããŸãã
game_export_t *ge; // dll refexport_t re; // dll WinMain() // quake2.exe { Qcommon_Init (argc, argv); while(1) { Qcommon_Frame { SV_Frame() // { // if (!svs.initialized) return; // game.dll ge->RunFrame(); } CL_Frame() // { // if (dedicated->value) return; // renderer.dll re.BeginFrame(); //[...] re.EndFrame(); } } } }
å®å šã«å解ããããµã€ã¯ã«ã¯ãç§ã®ããŒãã«èšèŒãããŠããŸãã
ããªãã¢ãŒããã¯ãã£ã®ãã®ãããªå€æŽãå¿ èŠãªã®ãããšå°ããããšãã§ããŸãã ãã®è³ªåã«çããããã«ã1996幎ãã1997幎ãŸã§ã®Quakeã®ãã¹ãŠã®ããŒãžã§ã³ãèŠãŠã¿ãŸãããã
- å°é
- WinQuake
- GLQuake
- VQuake ïŒéçºè ã®1人ã§ããStefan PodellïŒStefan PodellïŒããã Zãããã¡ãªã³ã° ïŒ ãã©ãŒ ïŒ ã«ãããV2200ã®åé¡ã«ã€ããŠã®ããã€ãã®èšèïŒã
- Quake World Serverã
- Quake World Clientã
å€ãã®å®è¡å¯èœãã¡ã€ã«ãäœæããããã®ãã³ã«
#ifdef
ããªããã»ããµãä»ããŠã³ãŒããåå²ãŸãã¯æ§æããå¿ èŠããããŸããã ããã¯å®å šãªæ··ä¹±ã§ããããããåãé€ãããã«å¿ èŠã§ããïŒ
- ã¯ã©ã€ã¢ã³ã/ãµãŒããŒãçµ±åããŸãã
- 亀æå¯èœãªã¢ãžã¥ãŒã«ãããŒãã§ããã«ãŒãã«ãæ§ç¯ããŸãã
æ°ããã¢ãããŒãã¯æ¬¡ã®ããã«èª¬æã§ããŸãã
2ã€ã®äž»èŠãªæ¹åïŒ
- ã¯ã©ã€ã¢ã³ããšãµãŒããŒã®çµ±åïŒã¯ã©ã€ã¢ã³ãçšãšãµãŒããŒçšã«1ã€ã®exeããªããªã£ããããã¡ã€ã³ã®å®è¡å¯èœãã¡ã€ã«ã¯ãµãŒããŒãã¯ã©ã€ã¢ã³ãããŸãã¯ãã®äž¡æ¹ãšããŠåæã«æ©èœããŸããã ã·ã³ã°ã«ãŠãŒã¶ãŒã¢ãŒãã§ããã¯ã©ã€ã¢ã³ããšãµãŒããŒã¯åãå®è¡å¯èœãã¡ã€ã«ã§å®è¡ãããŠããŸããïŒãã ãããã®å ŽåãããŒã¿äº€æã¯TCP IP / IPXã§ã¯ãªãããŒã«ã«ãããã¡ãŒãä»ããŠå®è¡ãããŸããïŒã
- ã¢ãžã¥ãŒã«æ§ïŒåçãªæ¥ç¶ã«ãããã³ãŒãã®äžéšã¯äº€æå¯èœã«ãªããŸããã ã¬ã³ãã©ãŒãšã²ãŒã ã³ãŒãã¯ãQuake2ã®ã³ã¢ãå€æŽããã«åãæ¿ããããšãã§ããã¢ãžã¥ãŒã«ã«ãªããŸããã ãããã£ãŠãé¢æ°ãã€ã³ã¿ãŒãå«ã2ã€ã®æ§é ã䜿çšããŠãããªã¢ãŒãã£ãºã ãå®çŸãããŸããã
ãããã®2ã€ã®å€æŽã«ãããã³ãŒãããŒã¹ãéåžžã«ãšã¬ã¬ã³ãã«ãªããã³ãŒããšã³ããããŒã«èŠããQuake 1ãããèªã¿ããããªããŸããã
å®è£ ã®èŠ³ç¹ãããDLLãããžã§ã¯ãã¯ãã¬ã³ãã©ãŒçšã®
GetRefAPI
ã¡ãœãããšã²ãŒã çšã®
GetGameAPI
ã1ã€ã ãå ¬éããå¿ èŠããããŸãïŒããªãœãŒã¹ãã¡ã€ã«ããã©ã«ããŒã®
GetGameAPI
ãã¡ã€ã«ãåç §ïŒã
reg_gl/Resource Files/reg_soft.def
EXPORTS GetGameAPI
ã«ãŒãã«ãã¢ãžã¥ãŒã«ãããŒãããå¿ èŠãããå ŽåãDLLãããã»ã¹ã¹ããŒã¹ã«ããŒããã
GetProcAddress
ã§
GetRefAPI
ã¢ãã¬ã¹ãååŸããå¿ èŠãªé¢æ°ãã€ã³ã¿ãŒãååŸããŸããããã ãã§ãã
èå³æ·±ãäºå®ïŒããŒã«ã«ã²ãŒã ã§ã¯ãã¯ã©ã€ã¢ã³ããšãµãŒããŒéã®éä¿¡ã¯ãœã±ãããä»ããŠå®è¡ãããŸããã 代ããã«ãã³ãã³ãã¯ãã³ãŒãã®ã¯ã©ã€ã¢ã³ãéšåã§
NET_SendLoopPacket
ã䜿çšããŠã«ãŒãããã¯ãããã¡ãŒã«ã¹ããŒãããŸãã ãµãŒããŒã¯
NET_GetLoopPacket
ã䜿çšããŠåããããã¡ãŒããã³ãã³ããåæ§ç¯ããŸãã
å¶ç¶ã®äºå®ïŒãã®åçãèŠãããšããããªãããããããžã§ã³ã»ã«ãŒããã¯ã1996幎é ã«å·šå€§ãªãã£ã¹ãã¬ã€ã«äœã䜿ã£ãŠããã®ãçåã«æãã§ãããã
Intergraphã補é ãã28ã€ã³ãã®InterView 28hd96ã¢ãã¿ãŒã§ããã ãã®ç£ã¯ãæ倧1920x1080ã®è§£å床ãæäŸããŸãããããã¯1995幎ã«ã¯éåžžã«å°è±¡çã§ãïŒè©³çŽ°ã«ã€ããŠã¯ã ãã¡ã ïŒ ãã©ãŒ ïŒãåç §ããŠãã ããïŒã
ãã¹ã¿ã«ãžãã¯ãªYoutubeãããªïŒ Intergraph Computer Systems Workstations ã
è¿œå ïŒãã®èšäºã¯ã ãJohn Carmackã1995幎ã«28ã€ã³ã16ïŒ9 1080pã¢ãã¿ãŒã§QuakeãäœæããããšããèšäºïŒ mirror ïŒãæžãããããgeek.comã®èª°ãã«åºæ¿ãäžããããã§ãã
æŽæ°ïŒ Doom 3ã®éçºæã«ããžã§ã³ã«ãŒããã¯ããã®ã¢ãã¿ãŒããŸã 䜿çšããŠããããã§ãã
å¯èŠå
ãœãããŠã§ã¢ã¬ã³ãã©ãŒïŒ
ref_soft
ïŒããã³ããŒããŠã§ã¢ã¢ã¯ã»ã©ã¬ãŒã¿ã¬ã³ãã©ãŒïŒ
ref_soft
ïŒ
ref_gl
ã¯éåžžã«å€§ããããããããã«ã€ããŠåå¥ã®ã»ã¯ã·ã§ã³ãäœæããŸããã
ç¹°ãè¿ãã«ãªããŸãããã«ãŒãã«ã¯ã©ã®ã¬ã³ãã©ãŒãæ¥ç¶ãããŠãããããç¥ããªãã£ãããšã¯æ³šç®ã«å€ããŸããããã¯åã«æ§é å ã§é¢æ°ãã€ã³ã¿ãŒãåŒã³åºããã ãã§ãã ã€ãŸããèŠèŠåãã€ãã©ã€ã³ã¯å®å šã«æœè±¡åãããŸããããã®C ++ãå¿ èŠãªã®ã¯ã ãã§ããã
èå³æ·±ãäºå®ïŒ id Softwareã¯ã1992幎ã®Wolfenstein 3Dã²ãŒã ã®åº§æšç³»ã䜿çšããŠããŸãïŒå°ãªããšãDoom3ã®å Žåã¯ããã§ããïŒã ããã¯ãã¬ã³ãã©ãŒã®ãœãŒã¹ã³ãŒããèªã¿åããšãã«ç¥ã£ãŠããããšãéèŠã§ãã
idã·ã¹ãã ã§ã¯ïŒ
- X軞=å·Š/å³
- Y軞=ããã³ã/ãªã¢
- Z軞=äžéš/äžéš
OpenGL座æšç³»ã®å ŽåïŒ
- X軞=å·Š/å³
- Y軞=äž/äž
- Z軞=ããã³ã/ãªã¢
ãã®ãããOpenGLã¬ã³ãã©ãŒã¯
GL_MODELVIEW
ãããªãã¯ã¹ã䜿çšããŠã
R_SetupGL
ã¡ãœããïŒ
glLoadIdentity
+
glRotatef
ïŒã䜿çšããŠåãã¬ãŒã ã®åº§æšç³»ããä¿®æ£ãããŸãã
åçãªæ¥ç¶
ã«ãŒãã«/ã¢ãžã¥ãŒã«ã®çžäºäœçšã«ã€ããŠã¯å€ãã®ããšãèšããŸããåçæ¥ç¶ã«é¢ããå¥ã®ã»ã¯ã·ã§ã³ãæžããŸããã
æ¹é ïŒgamex86.dll
ãããžã§ã¯ãã®ãã®éšåãèªãããšã¯ããã»ã©é¢çœããªãããšãå€æããŸããããã³ã³ãã€ã«ãããã¢ãžã¥ãŒã«ã®Quake-Cãçµäºãããšã2ã€ã®è¯ãçµæãš1ã€ã®éåžžã«æªãçµæã«ã€ãªãããŸããã
æªãç¹ïŒ
- 移æ€æ§ã¯ç ç²ã«ãªããŸããã²ãŒã ã¢ãžã¥ãŒã«ã¯ãç¹å®ã®ãªã³ã«ãŒãã©ã¡ãŒã¿ãŒã䜿çšããŠç°ãªããã©ãããã©ãŒã çšã«åã³ã³ãã€ã«ããå¿ èŠããããŸãã
è¯ãïŒ
- é床ïŒQuake1ã®ã²ãŒã èšèªQuake1ã¯ã³ãŒãã解éããŸããããåçã©ã€ãã©ãªã¢ãžã¥ãŒã«Quake2
gamex86.dll
ã¯ãã€ãã£ãã§ãã - èªç±ïŒæ¹é è ã¯ãQuake-Cã§å©çšå¯èœãªãã®ã ãã§ãªãããã¹ãŠã«ã¢ã¯ã»ã¹ã§ããŸããã
èå³æ·±ãäºå®ïŒ id Softwareãã²ãŒã ã人工ç¥èœãæ¹é ã«ä»®æ³ãã·ã³ïŒQVMïŒã䜿çšããããã«Quake3ã«åãæ¿ããããšã¯ç®èã§ãã
ç§ã®å°é2
ãããã³ã°ããã»ã¹äžã«ãQuake2ã®ãœãŒã¹ã³ãŒãããããã«å€æŽããŸããã Quakeã³ã³ãœãŒã«ãåŠç¿ããããã«ã²ãŒã ãäžæåæ¢ããã®ã§ã¯ãªããããã»ã¹ã§
printf
åºåãèŠãããã«DOSã³ã³ãœãŒã«ãè¿œå ããããšã匷ããå§ãããŸãã
DOSã¹ã¿ã€ã«ã®ã³ã³ãœãŒã«ãWin32ãŠã£ã³ããŠã«è¿œå ããã®ã¯éåžžã«ç°¡åã§ãã
// sys_win.c int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { AllocConsole(); freopen("conin$","r",stdin); freopen("conout$","w",stdout); freopen("conout$","w",stderr); consoleHandle = GetConsoleWindow(); MoveWindow(consoleHandle,1,1,680,480,1); printf("[sys_win.c] Console initialized.\n"); ... }
Parallelsã䜿çšããŠMacã§Windowsãå®è¡ããŠãããããã²ãŒã ã®å®è¡äžã«ãprintscreenããæŒãããšã¯å°é£ã§ããã ã¹ã¯ãªãŒã³ã·ã§ãããäœæããã«ã¯ãããžã¿ã«ãããã¯ããã*ãããŒãèšå®ããŸãã
// keys.c if (key == '*') { if (down) // ! Cmd_ExecuteString("screenshot"); }
ãããŠæåŸã«ãå€ãã®ã³ã¡ã³ããšå³ãè¿œå ããŸããã ãç§ã®ãå®å šãªãœãŒã¹ã³ãŒãã次ã«ç€ºããŸãã
ã¢ãŒã«ã€ã
ã¡ã¢ãªç®¡ç
DoomãšQuake1ã«ã¯ããZone Memory AllocationããšåŒã°ããç¬èªã®ã¡ã¢ãªãããŒãžã£ããããŸãããèµ·åæã«ã
malloc
å®è¡ãããã¡ã¢ãªãããã¯ã¯ãã€ã³ã¿ã®ãªã¹ãã䜿çšããŠå¶åŸ¡ãããŸããã ã¡ã¢ãªãŸãŒã³ãããŒã¯ããŠãç®çã®ã¡ã¢ãªã«ããŽãªããã°ããæ¶å»ã§ããŸãã ãŸãŒã³ã¡ã¢ãªã¢ãã±ãŒã¿ïŒ
common.c: Z_Malloc, Z_Free, Z_TagMalloc , Z_FreeTags
ïŒã¯Quake2ã«æ®ã£ãŠããŸããããã»ãšãã©åœ¹ã«ç«ã¡ãŸããïŒ
- ã¿ã°ã¯äœ¿çšããããã¡ã¢ãªå²ãåœãŠ/å²ãåœãŠè§£é€ã¯
malloc
ããã³free
ã§å®è¡ãããŸãïŒid Softwareããã®äœæ¥ãCæšæºã©ã€ãã©ãªã«å§ããããšã決ããçç±ã¯ããããŸããïŒã - ãªãŒããŒãããŒæ€åºåšïŒå®æ°
Z_MAGIC
ã䜿çšïŒã䜿çšãããããšã¯ãããŸãã
åã¡ã¢ãªãããã¯ãå²ãåœãŠãããåã«æ¿å ¥ãããããããŒã®
size
å±æ§ã«ãããã¡ã¢ãªæ¶è²»ã枬å®ããããšã¯äŸç¶ãšããŠéåžžã«äŸ¿å©ã§ãã
#define Z_MAGIC 0x1d1d typedef struct zhead_s { struct zhead_s *prev, *next; short magic; short tag; // int size; } zhead_t;
ãµãŒãã§ã¹ãã£ãã·ã¥ã·ã¹ãã ã«ã¯ç¬èªã®ã¡ã¢ãªãããŒãžã£ãŒããããŸãã åæ£ã¡ã¢ãªã®éã¯è§£å床ã«äŸåããå¥åŠãªåŒã«ãã£ãŠæ±ºå®ãããŸãããã¬ããŒãžããéåžžã«å¹æçã«ä¿è·ããŸãïŒ
malloc : ============================== size = SURFCACHE_SIZE_AT_320X240; //1024*768 pix = vid.width*vid.height; if (pix > 64000) size += (pix-64000)*3;
ããã³ã¯ã¢ãã±ãŒã¿ãŒãã¯ããªãœãŒã¹ïŒç»åããµãŠã³ããããã³ãã¯ã¹ãã£ïŒãèªã¿èŸŒãããã«äœ¿çšãããŸãã 圌ã¯ã
virtualAlloc
ã䜿çšããŠããŒã¿ãããŒãžãµã€ãºïŒ8 KBãWin98ã§ã¯4 KBã䜿çšãããŠããã«ããããããïŒïŒ
æåŸã«ãå€ãã®FIFOã¹ã¿ãã¯ããããŸãïŒãšããããééãä¿åããããïŒ ãæ©èœãæããã«å¶éãããŠããã«ãããããããéåžžã«ããŸãæ©èœããŸãã
ã¡ã¢ãªç®¡çïŒæ³šæã®ç§rick
Quake2ã¯å€ãã®éåžžã®ãã€ã³ã¿ãŒã管çããããã32ãããïŒãŸãã¯Windows 98ã4 KBããŒãžã䜿çšããŠããŠãPAGE_FAULTãæå°åããããã«8 KBïŒã«ãã€ã³ã¿ãŒãé 眮ããã®ã«è¯ãããªãã¯ã䜿çšãããŸãã
ããŒãžã¬ã€ã¢ãŠãïŒ8KBïŒïŒ
int roundUpToPageSize(int size) { size = (size + 8191) & ~8191; return size; }
ã¡ã¢ãªäœçœ®ïŒ4 BïŒïŒ
memLoc = (memLoc + 3) & ~3; // 4- .
ã³ã³ãœãŒã«ãµãã·ã¹ãã
Quake2ã«ãŒãã«ã«ã¯ãã€ã³ããã¯ã¹ãªã¹ããšç·åœ¢æ€çŽ¢ãåºç¯å²ã«äœ¿çšãã匷åãªã³ã³ãœãŒã«ã·ã¹ãã ãå«ãŸããŠããŸãã
次ã®3çš®é¡ã®ãªããžã§ã¯ãããããŸãã
- ã³ãã³ãïŒæå®ãããæååå€ã«é¢æ°ãã€ã³ã¿ãäžããŸãã
- CvarïŒæå®ãããæåååã®æååå€ãä¿åããŸãã
- ãšã€ãªã¢ã¹ïŒæå®ãããæååå€ã®çœ®æãæäŸããŸãã
ã³ãŒãã®èŠ³ç¹ããèŠããšããªããžã§ã¯ãã®åã¿ã€ãã«ã¯ãã€ã³ã¿ãŒã®ãªã¹ãããããŸãã
cmd_function_t *cmd_functions // , : void (*)() . cvar_t *cvar_vars // , . cmdalias_t *cmd_alias // , .
åè¡ãã³ã³ãœãŒã«ã«å ¥åããããšãã¹ãã£ã³ãããè£è¶³ããïŒãšã€ãªã¢ã¹ãšå¯Ÿå¿ããcvarã䜿çšïŒã次ã«2ã€ã®ã°ããŒãã«å€æ°
cmd_argc
ãš
cmd_argv
æ ŒçŽãããããŒã¯ã³ã«åå²ãããŸãã
static int cmd_argc; static char *cmd_argv[MAX_STRING_TOKENS];
äŸïŒ
ãããã¡ãŒå ã§èå¥ãããåããŒã¯ã³ã¯ã
memcpy
ã«ãã£ãŠã
cmd_argv
ããŠ
malloc
ã§ç€ºãããå Žæã«ã³ããŒãããŸãã ãã®ããã»ã¹ã¯ããªãéå¹ççã§ããããã®ãµãã·ã¹ãã ã«ã»ãšãã©æ³šæãæãããŠããªãããšã瀺ããŠããŸãã ã¡ãªã¿ã«ãããã¯å®å šã«æ£åœåãããŠããŸãããã£ãã«äœ¿çšããããã²ãŒã ã«ã»ãšãã©åœ±é¿ãäžããªããããæé©åã¯åªåãã䟡å€ããããŸããã§ããã ããé©åãªæ¹æ³ã¯ããœãŒã¹æååã«ããããé©çšããåããŒã¯ã³ã®ãã€ã³ã¿ãŒå€ãæžã蟌ãããšã§ãã
ããŒã¯ã³ã¯åŒæ°ã®é åå ã«ããããã
cmd_argv[0]
ãé¢æ°ãã€ã³ã¿ãŒã®ãªã¹ãã§å®£èšãããŠãããã¹ãŠã®é¢æ°ã«æºæ ããããã«ãéåžžã«äœéã§ç·åœ¢ã«ãã§ãã¯ãããŸãã äžèŽãèŠã€ãã£ãå Žåãé¢æ°ãã€ã³ã¿ãŒãåŒã³åºãããŸãã
äžèŽãããã®ããªãå Žåã¯ããšã€ãªã¢ã¹ãã€ã³ã¿ãŒã®ãªã¹ããç·åœ¢çã«ãã§ãã¯ãããããŒã¯ã³ãé¢æ°åŒã³åºãã§ãããã©ãããå€æãããŸãã ãšã€ãªã¢ã¹ãé¢æ°åŒã³åºãã眮ãæããå ŽåãåŒã³åºãããŸãã
æåŸã«ãäžèšã®ããããæ©èœããªãå ŽåãQuake2ã¯ããŒã¯ã³ãå€æ°å®£èšãšããŠïŒãŸãã¯å€æ°ãæ¢ã«ãã€ã³ã¿ãŒã®ãªã¹ãã«ããå Žåã¯æŽæ°ãšããŠïŒæ±ããŸãã
ããã§ã¯ããã€ã³ã¿ãŒã®ãªã¹ãã§å€ãã®ç·åœ¢æ€çŽ¢ãè¡ãããŸããããã·ã¥ããŒãã«ã䜿çšããããšãçæ³çã§ãã OïŒn²ïŒã§ã¯ãªãOïŒnïŒã®è€éããå®çŸã§ããŸãã
æ§æ解æã«é¢ããèå³æ·±ãäºå®1 ïŒ ASCIIããŒãã«ã¯ã¹ããŒãã«ç·šæãããŠããŸããæååã解æããŠããŒã¯ã³ãäœæããå Žåãã»ãã¬ãŒã¿ãŒãšã¹ããŒã¹æåãã¹ãããã§ããŸãã
char* returnNextToken(char* string) { while (string && *string < ' ') string++; return string; }
解æ2ã«é¢ããèå³æ·±ãäºå® ïŒ ASCIIããŒãã«ã¯éåžžã«å·§åŠã«æ§æãããŠããŸãã次ã®ããã«æåcãæŽæ°ã«å€æã§ããŸãã
intå€= c-'0';
int charToInt(char v) { return v - '0' ; }
cvarå€ã®ãã£ãã·ã¥ïŒ
ãã®ã·ã¹ãã ã®ã¡ã¢ãªå ã®cvarã®å ŽæïŒ
Cvar_Get
ïŒãOïŒn²ïŒïŒç·åœ¢æ€çŽ¢+åã¬ã³ãŒãã®strcmpïŒã§ãããããã¬ã³ãã©ãŒã¯ã¡ã¢ãªå ã®cvarã®å Žæããã£ãã·ã¥ããŸãã
// cvar_t *crosshair; // , // Cvar . crosshair = Cvar_Get ("crosshair", "0", CVAR_ARCHIVE); // // , . void SCR_DrawCrosshair (void) { if (!crosshair->value) // return; }
ãã®å€ãžã®ã¢ã¯ã»ã¹ã¯ãOïŒ1ïŒã§ååŸã§ããŸãã
æªåœ¹ã«å¯Ÿããä¿è·
äžæ£è¡çºããä¿è·ããããã«ãããã€ãã®ã¡ã«ããºã ãæ¿å ¥ãããŸããã
- UDPã«ã¯ç¬èªã®CRCããããŸãããQuake CRCïŒ
COM_BlockSequenceCRCByte
ïŒãåãã±ããã«è¿œå ãããå€æŽããä¿è·ãããŸãã - è©Šåéå§åã«ãã¬ãã«ã¯MD4ã䜿çšããŠããã·ã¥ãããŸãã ãã®ããã·ã¥ã¯ãµãŒããŒã«éä¿¡ãããã¯ã©ã€ã¢ã³ããå€æŽãããã«ãŒãïŒ
Com_BlockChecksumM
ïŒã䜿çšããªãããã«ããŸãã - åãã¬ã€ã€ãŒããã®1ç§ãããã®ããŒã æ°ïŒ
SV_ClientThink
ïŒããã§ãã¯ããã·ã¹ãã ããããŸããããããã©ãã»ã©å¹æçã ã£ããã¯æ£ç¢ºã«ã¯ããããŸããã
å éšã¢ã»ã³ãã©ãŒ
Quakeã®ãã¹ãŠã®ããŒãžã§ã³ãšåæ§ã«ãæçšãªé¢æ°ã®äžéšã¯ã¢ã»ã³ãã©ãŒã䜿çšããŠæé©åãããŸããïŒãã ããQuake3ã«ãã£ãæåãªãé«éå¹³æ¹æ ¹éé¢æ°ãã®çè·¡ã¯ãŸã ãããŸããïŒã
32ãããæµ®åå°æ°ç¹æ°ã®é«éçµ¶å¯Ÿå€ ïŒä»æ¥ã»ãšãã©ã®ã³ã³ãã€ã©ãŒã¯ãããèªåçã«è¡ããŸãïŒïŒ
float Q_fabs (float f) { int tmp = * ( int * ) &f; tmp &= 0x7FFFFFFF; return * ( float * ) &tmp; }
ãããŒãããæŽæ°ãžã®é«éå€æ
__declspec( naked ) long Q_ftol( float f ) { static int tmp; __asm fld dword ptr [esp+4] __asm fistp tmp __asm mov eax, tmp __asm ret }
ã³ãŒãçµ±èš
Clocã®ã³ãŒããåæãããšãã³ãŒãã«ã¯138,240è¡ããããšãããããŸããã ãã€ãã®ããã«ãå€ãã®ããšããšã³ãžã³ããŒãžã§ã³ã®å埩ãµã€ã¯ã«ã§èŠæšãŠãããããããã®æ°åã¯æè³ãããåªåã®ã¢ã€ãã¢ãæäŸããŸããããç§ã«ã¯æããããããã¯ãšã³ãžã³ã®å šäœçãªè€éãã®è¯ãææšã§ãã
$ cloc quake2-3.21/ 338 text files. 319 unique files. 34 files ignored. http://cloc.sourceforge.net v 1.53 T=3.0 s (96.0 files/s, 64515.7 lines/s) ------------------------------------------------------------------------------- Language files blank comment code ------------------------------------------------------------------------------- C 181 24072 19652 107757 C/C++ Header 72 2493 2521 14825 Assembly 22 2235 2170 8331 Objective C 6 1029 606 4290 make 2 436 67 1739 HTML 1 3 0 1240 Bourne Shell 2 17 6 54 Teamcenter def 2 0 0 4 ------------------------------------------------------------------------------- SUM: 288 30285 25022 138240 -------------------------------------------------------------------------------
泚ïŒãã¹ãŠã®ã¢ã»ã³ãã©ãŒã³ãŒãã¯ãæåã§äœæããããœãããŠã§ã¢ã¬ã³ãã©ãŒçšã§ãã
æšå¥šãããQuake2ãããã³ã°ããŒã«
- Visual Studio Express 2008ã
- idãŠã§ããµã€ãããã®ç¡æã®Quake2ãã¢ã
- ç§ãæžããæŽæ¢æ€å®¶ ã
- Wally ïŒWALç»å圢åŒãã¥ãŒã¢ã
- æåãªæŽç 究ããŒã«ïŒ PakExpl ïŒ
- FlipCode Webãµã€ãããã®BSPåœ¢åŒ ïŒ ãã©ãŒ ïŒ ã«é¢ããèšäº ã
- ãããã¡ã€ã©ãŒCïŒVTuneïŒIntelïŒãCodeAnalysisïŒAMDïŒãVisual Studio Team ProfilerïŒç§ã®æèŠã§ã¯æé«ïŒã
- 24/30ã€ã³ãã®å€§åã¹ã¯ãªãŒã³ã
- ããŒããŒãIBMã¢ãã«M
Quake2ã¯ã1ã€ã®ã³ã¢ãšãå®è¡æã«ããŒãããã2ã€ã®ã¢ãžã¥ãŒã«ïŒã²ãŒã ãšã¬ã³ãã©ãŒïŒã§æ§æãããŸãã ããªã¢ãŒãã£ãºã ã®ãããã§ãäœã§ãã³ã¢ã«æ¥ç¶ã§ããããšãéåžžã«èå³æ·±ãã§ãã
èªã¿ç¶ããåã«ããã®ãã°ãããèšäº ïŒ ãã©ãŒ ïŒã䜿çšããŠä»®æ³ã¡ã¢ãªã®åçãç解ããŠããããšã確èªããããšããå§ãããŸãã
åçæ¥ç¶ã䌎ãCã®å€æ æ§
åçæ¥ç¶ã«ã¯å€ãã®å©ç¹ããããŸãã
- ã¬ã³ãã©ãŒïŒ
- çŽç²ãªQuake2ã«ãŒãã«ã³ãŒããã³ãŒããšã³ããããŒã®åæžãã©ãã«ãçã£ã
#ifdef
ã¯ãããŸããã - è€æ°ã®ã¬ã³ãã©ãŒïŒãœãããŠã§ã¢ãopenGLïŒã䜿çšããã²ãŒã ã®ãªãªãŒã¹ã
- ã¬ã³ãã©ãŒã¯ã²ãŒã äžã«å€æŽã§ããŸãã
- ã²ãŒã ã®ãªãªãŒã¹åŸã«äœæãããæ©åšïŒGlideãVerityïŒã®æ°ããã¬ã³ãã©ãŒãäœæããæ©èœã
- çŽç²ãªQuake2ã«ãŒãã«ã³ãŒããã³ãŒããšã³ããããŒã®åæžãã©ãã«ãçã£ã
- æ¹é ã²ãŒã ïŒ
- modäœæè åãã®ãã®ä»ã®æ©èœãgame.dllã䜿çšããŠã²ãŒã ãå®å šã«å€æŽã§ããŸãã
- Modã§ã®å®å šãªã²ãŒã ã¹ããŒããQuakeCããã³Quake Virtual Machineã«äŸåããå¿ èŠã¯ãããŸããã
- QuakeCãåŠã¶å¿ èŠã¯ãããŸãããDLLã¯Cã§äœæãããŠããŸãã
ããããQuake2ã¯ãªããžã§ã¯ãæåããã°ã©ãã³ã°èšèªã§ã¯ãªãCã§æžãããŠããããããOOã§ã¯ãªãèšèªã§ããªã¢ãŒãã£ãºã ãå®è£ ããæ¹æ³ã¯ïŒããšããçåãçããŸããã
OOã·ãã¥ã¬ãŒã·ã§ã³ææ³ã¯ãJAVAããã³C ++ã§äœ¿çšãããæ¹æ³ã«äŒŒãŠããŸãïŒé¢æ°ãã€ã³ã¿ãŒãå«ãæ§é ã䜿çšããŸãã
ãããã£ãŠã4ã€ã®æ§é äœãé¢æ°ãã€ã³ã¿ãŒã亀æããããã«äœ¿çšãããŸããïŒ
refimport_t
ããã³
refexport_t
ã¯ãã¬ã³ãã©ãŒã¢ãžã¥ãŒã«ãããŒããããšãã«é¢æ°ãã€ã³ã¿ãŒã亀æããããã®ã³ã³ãããŒãšããŠæ©èœããŸããã
game_import_t
ããã³
game_export_t
ãã²ãŒã ã¢ãžã¥ãŒã«ã®ããŒãæ
game_export_t
䜿çšãããŸããã
é·ã説æãããå°ããªã€ã©ã¹ãã®æ¹ãè¯ã
ã¹ããã1ïŒåæ段éïŒ
-
quake2.exe
ã¯ãé¢æ°ãã€ã³ã¿ãNULL
ïŒç°è²ïŒã®æ§équake2.exe
ãå«ãŸããŠãNULL
ã - DLLã¢ãžã¥ãŒã«ïŒ
ref_opengl.dll
ïŒã«ã¯ãNULL
ïŒç°è²ïŒãžã®é¢æ°ãã€ã³ã¿ãŒãæã€kernel_fct_t
æ§é äœãå«ãŸããŠãNULL
ã
ããã»ã¹ã®ã¿ã¹ã¯ã¯ãåéšåãä»ãåŒã³åºãããšãã§ããããã«ãé¢æ°ã®ã¢ãã¬ã¹ãæž¡ãããšã§ãã
ã¹ããã2ïŒé¢æ°ãåŒã³åºãã«ãŒãã«ã¯ãç¬èªã®é¢æ°ãžã®ãã€ã³ã¿ãŒãå«ãæ§é äœãåãããããã®DLLå€ãéä¿¡ããŸãã
ã¹ããã3ïŒåä¿¡DLLã¯ãã«ãŒãã«é¢æ°ãã€ã³ã¿ãŒãã³ããŒããç¬èªã®é¢æ°ã¢ãã¬ã¹ãå«ãæ§é äœãè¿ããŸãã
å®åã䜿çšããããã»ã¹ã«ã€ããŠã¯ã次ã®2ã€ã®ã»ã¯ã·ã§ã³ã§è©³ãã説æããŸãã
ã¬ã³ãã©ãŒã©ã€ãã©ãª
ã¬ã³ãã©ãŒã¢ãžã¥ãŒã«ãåãåãã¡ãœããã¯
VID_LoadRefresh
ãšåŒã°ã
VID_LoadRefresh
ã Quakeãã¬ã³ãã©ãŒãåãæ¿ããããšãã§ããããã«ããã¹ãŠã®ãã¬ãŒã ãšåŒã°ããŸãïŒãã ããã¬ã³ãã©ãŒãå¿ èŠãšããååŠçã®ãããã¬ãã«ãåèµ·åããå¿ èŠããããŸãïŒã
Quake2ã«ãŒãã«åŽã§äœãèµ·ãããã次ã«ç€ºããŸãã
refexport_t re; qboolean VID_LoadRefresh( char *name ) { refimport_t ri; GetRefAPI_t GetRefAPI; ri.Sys_Error = VID_Error; ri.FS_LoadFile = FS_LoadFile; ri.FS_FreeFile = FS_FreeFile; ri.FS_Gamedir = FS_Gamedir; ri.Cvar_Get = Cvar_Get; ri.Cvar_Set = Cvar_Set; ri.Vid_GetModeInfo = VID_GetModeInfo; ri.Vid_MenuInit = VID_MenuInit; ri.Vid_NewWindow = VID_NewWindow; GetRefAPI = (void *) GetProcAddress( reflib_library, "GetRefAPI" ); re = GetRefAPI( ri ); ... }
äžèšã®ã³ãŒãã§ã¯ãQuake2ã«ãŒãã«ã¯ïŒãã«ãã€ã³win32ã¡ãœããïŒ
GetRefAPI
ã䜿çšããŠã¬ã³ãã©ãŒDLLããã¡ãœããé¢æ°ãã€ã³ã¿ãŒãååŸããŸã
GetProcAddress
ã
ããã¯äžã«äœãèµ·ãããã
GetRefAPI
å éšã®DLLã¬ã³ãã©ïŒ
refexport_t GetRefAPI (refimport_t rimp ) { refexport_t re; ri = rimp; re.api_version = API_VERSION; re.BeginRegistration = R_BeginRegistration; re.RegisterModel = R_RegisterModel; re.RegisterSkin = R_RegisterSkin; re.EndRegistration = R_EndRegistration; re.RenderFrame = R_RenderFrame; re.DrawPic = Draw_Pic; re.DrawChar = Draw_Char; re.Init = R_Init; re.Shutdown = R_Shutdown; re.BeginFrame = R_BeginFrame; re.EndFrame = GLimp_EndFrame; re.AppActivate = GLimp_AppActivate; return re; }
æåŸã«ãã«ãŒãã«ãšDLLã®éã§åæ¹åã®ããŒã¿äº€æã確ç«ãããŸããã¬ã³ãã©ãŒDLLã¯æ§é å ã®ç¬èªã®é¢æ°ã¢ãã¬ã¹ãè¿ããQuake2ã«ãŒãã«ã¯éããèªèãããåžžã«åãé¢æ°ãã€ã³ã¿ãŒãåŒã³åºããããããã¯ããªã¢ãŒãã£ãã¯ã§ãã
ã²ãŒã ã©ã€ãã©ãª
ã«ãŒãã«åŽã®ã²ãŒã ã©ã€ãã©ãªã§ããŸã£ããåãããã»ã¹ãå®è¡ãããŸãã
game_export_t *ge; void SV_InitGameProgs (void) { game_import_t import; import.linkentity = SV_LinkEdict; import.unlinkentity = SV_UnlinkEdict; import.BoxEdicts = SV_AreaEdicts; import.trace = SV_Trace; import.pointcontents = SV_PointContents; import.setmodel = PF_setmodel; import.inPVS = PF_inPVS; import.inPHS = PF_inPHS; import.Pmove = Pmove; // 30 ge = (game_export_t *)Sys_GetGameAPI (&import); ge->Init (); } void *Sys_GetGameAPI (void *parms) { void *(*GetGameAPI) (void *); //[...] GetGameAPI = (void *)GetProcAddress (game_library, "GetGameAPI"); if (!GetGameAPI) { Sys_UnloadGame (); return NULL; } return GetGameAPI (parms); }
ã²ãŒã DLLåŽã§è¡ãããããšã¯æ¬¡ã®ãšããã§ãã
game_import_t gi; game_export_t *GetGameAPI (game_import_t *import) { gi = *import; globals.apiversion = GAME_API_VERSION; globals.Init = InitGame; globals.Shutdown = ShutdownGame; globals.SpawnEntities = SpawnEntities; globals.WriteGame = WriteGame; globals.ReadGame = ReadGame; globals.WriteLevel = WriteLevel; globals.ReadLevel = ReadLevel; globals.ClientThink = ClientThink; globals.ClientConnect = ClientConnect; globals.ClientDisconnect = ClientDisconnect; globals.ClientBegin = ClientBegin; globals.RunFrame = G_RunFrame; globals.ServerCommand = ServerCommand; globals.edict_size = sizeof(edict_t); return &globals; }
é¢æ°ãã€ã³ã¿ãŒã䜿çšãã
ã¡ãœãããã€ã³ã¿ãŒãæž¡ããšãããªã¢ãŒãã£ãºã ãæå¹ã«ãªããŸããããã§ãã³ãŒãã§ã¯ãã«ãŒãã«ã¯ç°ãªãã¢ãžã¥ãŒã«ã«ããžã£ã³ããããŸãã
ã¬ã³ãã©ãŒã¯ãã«ãžã£ã³ããã
SCR_UpdateScreen
ãŸãïŒ
// quake.exe, , quake2.exe , . SCR_UpdateScreen() { // re - struct refexport_t, BeginFrame BeginFrame DLL. re.BeginFrame( separation[i] ); // DLL SCR_CalcVrect() SCR_TileClear() V_RenderView() SCR_DrawStats SCR_DrawNet SCR_CheckDrawCenterString SCR_DrawPause SCR_DrawConsole M_Draw SCR_DrawLoading re.EndFrame(); // quake.exe. }
ã²ãŒã ã¯ããžã£ã³ããã
SV_RunGameFrame
ãŸãïŒ
void SV_RunGameFrame (void) { sv.framenum++; sv.time = sv.framenum*100; // , if (!sv_paused->value || maxclients->value > 1) ge->RunFrame (); .... } }
ãœãããŠã§ã¢ã¬ã³ãã©ãŒ
Quake2ãœãããŠã§ã¢ã¬ã³ãã©ãŒã¯ãæ倧ãã€æãè€éãªãããç 究ã«ãšã£ãŠæãèå³æ·±ãã¢ãžã¥ãŒã«ã§ãã
ãã£ã¹ã¯ããå§ãŸããã¯ã»ã«ã§çµããé ããã¡ã«ããºã ã¯ãããŸããã
ãã¹ãŠã®ã³ãŒãã¯ãã¡ããšæäœæ¥ã§æé©åãããŠããŸãã圌ã¯åœŒã®çš®é¡ã®æåŸã§ãããæ代ã®çµãããããŒã¯ããŸããããã®åŸãæ¥çã¯å®å šã«ããŒããŠã§ã¢ã¢ã¯ã»ã©ã¬ãŒã·ã§ã³ã䜿çšããã¬ã³ããªã³ã°ã®ã¿ã«åãæ¿ããŸããã
OpenGLãœãããŠã§ã¢ã¬ã³ããªã³ã°ãšã¬ã³ããªã³ã°ã®åºæ¬çãªéãã¯ãä»æ¥ã®éåžžã®24ãããTrue Color RGBã·ã¹ãã ã®ä»£ããã«256è²ãã¬ããã·ã¹ãã ã䜿çšããŠããããšã§ãã
ã¬ã³ãã©ãŒãšããŒããŠã§ã¢ã¢ã¯ã»ã©ã¬ãŒã·ã§ã³ããã³ãœãããŠã§ã¢ã¬ã³ãã©ãŒãæ¯èŒãããšãæãæçœãª2ã€ã®éãã«æ°ä»ããŸãã
- ã«ã©ãŒç §æã®æ¬ åŠ
- ãã€ãªãã¢ãã£ã«ã¿ãªã³ã°ãªã
ãããããããé€ããŠããšã³ãžã³ã¯ãã¬ãããéåžžã«å·§åŠã«äœ¿çšããŠé©ãã¹ãä»äºãããããšãã§ããŸãããããã«ã€ããŠã¯åŸã§èª¬æããŸãã
- ã«ã©ãŒã°ã©ããŒã·ã§ã³ã®ã¯ã€ãã¯éžæïŒ64å€ïŒã
- ãã¹ããšãã§ã¯ãã®ãã«ã¹ã¯ãªãŒã³ã«ã©ãŒããã·ã³ã°ã
- ãã¯ã»ã«ããšã®åéææ§ã
ãŸããQuake2ãã¬ãããPAKã¢ãŒã«ã€ããã¡ã€ã«ããããŒããããŸã
pics/colormap.pcx
ã
泚ïŒé»ã®å€ã¯0ãçœã¯15ãç·ã¯208ãèµ€ã¯240ïŒå·Šäžé ïŒãéæã¯255ã§ãã
æåã®ããšã¯ããããã«åŸã£ãŠ256è²ãåé 眮ããããšã§ã
pics/colormap.pcx
ïŒ
ãã®256x320ã¹ããŒã ã¯ã«ãã¯ã¢ããããŒãã«ãšããŠäœ¿çšãããå€ãã®èå³æ·±ãæ©èœãæäŸãããããç°åžžã«ã¹ããŒãã§ãã
- 64 : 256 «» . 63 , 255 . :
- [0,255] ( ).
- x*256, x [0,63] ( ).
64 256 . 256 . çŽ æŽãããã - ç»åã®æ®ãã®éšåã¯16x16ã®æ£æ¹åœ¢ããäœæãããããããã¬ããã«åºã¥ããŠãã¯ã»ã«ãã¬ã³ãã£ã³ã°ã䜿çšã§ããŸãããã¹ãŠã®æ£æ¹åœ¢ããœãŒã¹è²ãæçµè²ãããã³äžéè²ããäœæãããŠããããšãã¯ã£ãããšããããŸããããããã²ãŒã ã§æ°Žã®éææ§ãå®çŸããæ¹æ³ã§ããããšãã°ãå·Šäžã®æ£æ¹åœ¢ã«é»ãšçœãæ··åšããŠããŸãã
èå³æ·±ãäºå®ïŒ Quake2ãœãããŠã§ã¢ã¬ã³ãã©ãŒã¯ãåœåMMXãã¯ãããžãŒã®ãããã§ããã®ãããªã§ã®Quake1ã®ãªãªãŒã¹åŸã«ãžã§ã³ã«ãŒããã¯ãèšã£ãããã¬ããã§ã¯ãªãRGBã«åºã¥ããŠããã¯ãã§ããïŒ10å17ç§ïŒïŒ
MMXã¯SIMDãã¯ãããžãŒã§ããã1ã€ã®ãã£ã³ãã«ã®ã³ã¹ãã§3ã€ã®RGBãã£ã³ãã«ãã¹ãŠãæäœã§ããããã蚱容å¯èœãªCPUæ¶è²»ã§ããã·ã³ã°ãæäŸã§ããŸãã次ã®çç±ã§æŸæ£ããããšæããŸãã
- Pentium MMX 1997 , .
- RGB (16 32 ) (8 ) , .
äž»ãªå¶éïŒãã¬ããïŒã決å®ããããã¬ã³ãã©ãŒã®äžè¬çãªã¢ãŒããã¯ãã£ã«ç§»åã§ããŸãã圌ã®å²åŠã¯ãPentiumã®é·æïŒæµ®åå°æ°ç¹èšç®ïŒã䜿çšããŠã匱ç¹ã®åœ±é¿ã軜æžããŸãããã€ãŸããã¡ã¢ãªãžã®ãã¯ã»ã«ã®æžã蟌ã¿ã«åœ±é¿ãäžãããã¹ã®é床ã§ããã¬ã³ããªã³ã°ãã¹ã®ã»ãšãã©ã¯ããŒãã®åæç»ãå®çŸããããšã«çŠç¹ãåœãŠãŠããŸããæ¬è³ªçã«ããœãããŠã§ã¢ã¬ã³ããªã³ã°ãã¹ã¯Quake 1ãœãããŠã§ã¢ã¬ã³ããªã³ã°æ¹æ³ã«äŒŒãŠããŸãããã®äžã§ãBSPãšPVSïŒè¡šç€ºãããå¯èœæ§ã®ããããªãŽã³ã®ã»ããïŒãç©æ¥µçã«äœ¿çšããŠããããããã€ãã¹ããã¬ã³ããªã³ã°ããå¿ èŠã®ããããªãŽã³ã®ã»ãããååŸããŸãããåãã¬ãŒã ã¯ã3ã€ã®ç°ãªãèŠçŽ ãã¬ã³ããªã³ã°ããŸãã
- ãããïŒBSPã«åºã¥ããã³ããŒã¬ã³ããªè¡ããšã®ç»åæ§ç¯ã®ã¢ã«ãŽãªãºã ã®å©ããåããŠïŒè©³çŽ°ã¯åŸã»ã©ïŒã
- ãšã³ãã£ãã£ïŒãã¹ãã©ã€ããïŒãŠã£ã³ããŠïŒãšããŠããŸãã¯ããªããžã§ã¯ããïŒãã¬ã€ã€ãŒãæµïŒãšããŠãè¡ããšã®ã€ã¡ãŒãžãæ§ç¯ããããã®ç°¡åãªã¢ã«ãŽãªãºã ã䜿çšããŸãã
- ç²åã
泚ïŒãããã®ãå€ããã¢ã«ãŽãªãºã ã«æ £ããŠããªãå Žåã¯ãã³ã³ãã¥ãŒã¿ãŒã°ã©ãã£ãã¯ã¹ã®åå 3.6ããã³15.6ã®James D. Foleyã®ç« ãèªãããšã匷ããå§ãããŸããMichael Abrashã®ã°ã©ãã£ãã¯ã¹ããã°ã©ãã³ã°ãã©ãã¯ããã¯ã® 59ã70 ç« ã«ãå€ãã®æ å ±ããããŸãã
é«ã¬ãã«ã®æ¬äŒŒã³ãŒãã¯æ¬¡ã®ãšããã§ãã
- å°å³ã®ã¬ã³ããªã³ã°
- ååŠçãããBSPããªãŒããŠã©ãŒã¯ã¹ã«ãŒããŠãçŸåšã®ã¯ã©ã¹ã¿ãŒãç¹å®ããŸãã
- ãã®ç¹å®ã®ã¯ã©ã¹ã¿ãŒã«ã€ããŠPVSããŒã¿ããŒã¹ãç §äŒããŸãïŒPVSãååŸããã³è§£åããŸãã
- PVS: , , .
- BSP. , - . , .
- :
- BSP, :
- : .
- (=+ ) .
- ( ).
- . . Z-.
- BSP, :
- , Z- .
- .
- .
- ( ).
ç»é¢ã®èŠèŠåïŒãã¬ããã€ã³ããã¯ã¹ã¯ãªãã¹ã¯ãªãŒã³ãããã¡ã«æžã蟌ãŸããŸããã¢ãŒãïŒãã«ã¹ã¯ãªãŒã³/ãŠã£ã³ããŠïŒã«å¿ããŠãDirectDrawãŸãã¯GDIã䜿çšãããŸãããã¬ãŒã ããšã®ãã¬ãŒã ãããã¡ãŒãå®äºãããšããŸãã¯ã®ããããã䜿çšããŠããããªã«ãŒãã¹ã¯ãªãŒã³ãããã¡ãŒïŒGDI =>
rw_dib.c
DirectDraw =>
rw_ddraw.c
ïŒã«è»¢éãããŸãã
BitBlt
WinGDI.h
BltFast
ddraw.h
DirectDrawãŸãã¯GDI
ããã°ã©ããŒã1997幎ã«çŽé¢ããªããã°ãªããªãã£ããããã®åé¡ã¯ãåã«æ鬱ãªãã®ã§ããããžã§ã³ã«ãŒããã¯ã¯ããœãŒã¹ã³ãŒãã«é¢çœãã³ã¡ã³ããæ®ããŸããã
// DIB
Quake2ãDirectDrawã䜿çšããŠãã«ã¹ã¯ãªãŒã³ã¢ãŒãã§åäœããå Žåããªãã¹ã¯ãªãŒã³ãããã¡ãŒãäžããäžã«æç»ããå¿ èŠããããŸããããããã¹ã¯ãªãŒã³äžã«è¡šç€ºãããæ¹æ³ã§ããããããGDIã䜿çšããŠãŠã£ã³ããŠã¢ãŒãã§å®è¡ãããå Žåããããªã«ãŒãã¡ãŒã«ãŒã®ã»ãšãã©ã®ãã©ã€ããŒãåå°ã¢ãŒãã§RAMãããããªã¡ã¢ãªã«DIBã€ã¡ãŒãžã転éãããããDIBãããã¡ãŒã«ãªãã¹ã¯ãªãŒã³ãããã¡ãŒãåçŽã«åæ ããå¿ èŠããããŸããïŒæ¬åœã«è³ªåãã䟡å€ã¯ãããŸããïŒç¥èªã§ã¯ãGDIã¯ãç¬ç«ããè¡šããŸãïŒã
ãããã£ãŠããã¬ãŒã ããšã®ãããã¡ãä»ããé·ç§»ã¯æœè±¡çã§ãããšæ³å®ãããŠããŸãããå¿ èŠãªã®ã¯ããããã®éãããæœè±¡åããããã«ç°ãªãæ¹æ³ã§åæåãããæ§é ãšå€ã§ããããã¯ãCã§ããªã¢ãŒãã£ãºã ãå®è£ ããåå§çãªæ¹æ³ã§ãã
typedef struct { pixel_t *buffer; // pixel_t *colormap; // : 256 * VID_GRADES pixel_t *alphamap; // : 256 * 256 int rowbytes; // , // DIB int width; int height; } viddef_t; viddef_t vid ;
ãã¬ãŒã ãããã¡ãŒã®æç»ã«å¿ èŠãªæ¹æ³ã«å¿ããŠ
vid.buffer
ãæåã®ãã¯ã»ã«ãšããŠåæåãããŸããã
- directdrawã®æåã®è¡
- WinGDI / DBIã®æåŸã®è¡
äžäžã«ç§»åããã«ã¯ããŸãã¯
vid.rowbytes
ãšããŠåæåã
vid.width
ãŸã
-vid.width
ã
ãã©ã³ãžã·ã§ã³ã§ã¯ãã¬ã³ããªã³ã°ãã©ã®ããã«å®è¡ããããã¯åé¡ã§ã¯ãããŸãããéåžžã®åå°ã§ãåçŽåå°ã§ãïŒ
// byte* pixel = vid.buffer + vid.rowbytes * 0; // pixel = vid.buffer + vid.rowbytes * (vid.height-1); // i ( 0) pixel = vid.buffer + vid.rowbytes * i; // memset(vid.buffer,0,vid.height*vid.height) ; // <-- DirectDraw // !
ãã®ããªãã¯ã«ãããèŠèŠåãã€ãã©ã€ã³ã¯ãäžäœã¬ãã«ã§ã®è»¢éã®å®è¡æ¹æ³ã«ã€ããŠå¿é ããå¿ èŠããªããªããããã¯éåžžã«æ³šç®ã«å€ãããšæããŸãã
ã«ãŒãã®ååŠç
ã³ãŒããããã«æãäžããåã«ããããã®ååŠçäžã«çæããã2ã€ã®éèŠãªããŒã¿ããŒã¹ãç解ããå¿ èŠããããŸãã
- ãã€ããªç©ºéåå²ïŒBSPïŒ/æœåšçã«å¯èŠã®ããªãŽã³ã»ããïŒPVSïŒã
- æŸå°ç·ããŒã¹ã®ç §æãããã®ãã¯ã¹ãã£ã
BSPåæãPVSçæ
ãã€ããªç©ºéããŒãã£ã·ã§ã³ã®ããæ·±ãç 究ããå§ãããŸãïŒ
- ãŠã£ãããã£ã¢ïŒãã·ã¢èªïŒã
- æ¡BSPæšã®ã¢ã€ãã¢ãã€ã±ã«ã»ã¢ãã©ãã·ã¥ã
- Michael Abrashã«ããBSP Treesã«ããç·šéèšäºã
- ASCIIã¹ã¿ã€ã«ã®èšäºãå€ãèæžã
Quake1ãšåæ§ã«ãQuake2ã«ãŒãã¯æ·±å»ãªäºååŠçãåããŸãããã®ããªã¥ãŒã ã¯ãäžå³ã®ããã«ååž°çã«ã«ãããããŸãã
æçµçã«ããããã¯å®å šã«åž3Dã¹ããŒã¹ïŒã¯ã©ã¹ã¿ãŒãšåŒã°ããïŒã«ã«ãããããŸããDoakeãšQuake1ã®ããã«ããããã䜿çšããŠãã¹ãŠã®ããªãŽã³ãåé¢ããèé¢ãèé¢ããåé¢ã«äžŠã¹æ¿ããããšãã§ããŸãã
ãã°ãããè¿œå ã¯ãããããã¯ãã«ã®ã»ããïŒã¯ã©ã¹ã¿ãŒããšã«1ã€ïŒã§ããPVSã§ããä»»æã®ã¯ã©ã¹ã¿ãŒãã衚瀺ãããå¯èœæ§ã®ããã¯ã©ã¹ã¿ãŒãç §äŒããã³ååŸã§ããããŒã¿ããŒã¹ãšèããŠãã ããããã®ããŒã¿ããŒã¹ã¯å·šå€§ïŒ5 MBïŒã§ãããå¹æçã«æ°çŸãããã€ãã«å§çž®ãããRAMã«åãŸããŸãã
æ³šïŒ PVSå§çž®ã§ã¯ã0x00ã®å€ã®ã¿ãæž¡ãå§çž®ã䜿çšãããŸãããã®ããã»ã¹ã«ã€ããŠã¯ä»¥äžã§èª¬æããŸãã
æŸå°ç·
Quake1ãšåæ§ã«ãã¬ãã«ç §æã®å¹æã¯äºåã«èšç®ãããç §æããããšåŒã°ãããã¯ã¹ãã£ã«ä¿åãããŸãããã ããQuake1ãšã¯ç°ãªããQuake2ã¯äºåèšç®ã§æŸå°ãšè²ç §æã䜿çšããŸãããã®åŸãç §æãããã¯ã¢ãŒã«ã€ãã«ä¿å
PAK
ãããã²ãŒã äžã«äœ¿çšãã
ãŸããäœæè ã®1人ããã®2ã3ã®èšèïŒãããã°ã©ãã³ã°ã®ãã©ãã¯ããã¯ãã®ãã€ã±ã«ã¢ãã©ãã·ã¥ïŒãQuakeïŒäºåŸåæãšæªæ¥ãžã®å±æãã®ç« ïŒïŒ
ã°ã©ãã£ãã¯ã«å¯Ÿããæãèå³æ·±ãå€æŽã¯äºåçãªèšç®ã«ãããããã§ã¯ãžã§ã³ãæŸå°å ã®ãµããŒããè¿œå ããŸãã...
Quake 2ã¬ãã«ã®åŠçã«ã¯æ倧1æéããããŸããã
ïŒãã ããBSPã®äœæãPVSããã³æŸå°å ã®èšç®ãå«ãŸããŠããããšã¯æ³šç®ã«å€ããŸããããã«ã€ããŠã¯åŸã§èª¬æããŸããïŒ
æŸå°ç §æã«ã€ããŠç¥ãããå Žåã¯ããã®é©ãã»ã©ãã説æãããŠããèšäºïŒãã©ãŒïŒãèªãã§ãã ãããããã¯åãªãåäœã§ãã
æŸå°ç·ãã¯ã¹ãã£ãŒãéãåãããæåã®ã¬ãã«ã¯æ¬¡ã®ãšããã§ããæ®å¿µãªããšã«ããœãããŠã§ã¢ã¬ã³ãã©ãŒã®ã°ã¬ãŒã¹ã±ãŒã«ã§èŠäºãªRGBã«ã©ãŒããµã³ããªã³ã°ããå¿ èŠããããŸããïŒè©³çŽ°ã¯åŸã»ã©ïŒã
ã©ã€ãã£ã³ã°ãããã®äœè§£å床ã¯ããã§ã¯é©ãã¹ããã®ã§ããããã€ãªãã¢ãã£ã«ã¿ãªã³ã°ïŒãœãããŠã§ã¢ã¬ã³ãã©ãŒã§ãïŒãè¡ããããããæçµçµæã¯ã«ã©ãŒãã¯ã¹ãã£ãšéåžžã«è¯å¥œã§ãã
èå³æ·±ãäºå®ïŒç §æãããã¯ã2x2ãã17x17ã®ä»»æã®ãµã€ãºã«ããããšãã§ããŸãïŒããªããã³ãŒãã®èšäºã§å®£èšãããŠããæ倧ãµã€ãºã®16ã«ããããããïŒãã©ãŒ ïŒïŒãããŠæ£æ¹åœ¢ã§ããå¿ èŠã¯ãããŸããã
ã³ãŒãã¢ãŒããã¯ãã£
ã»ãšãã©ã®ãœãããŠã§ã¢ã¬ã³ãã©ãŒã³ãŒãã¯ã¡ãœããã«ãã
R_RenderFrame
ãŸããããã«ç°¡åãªèª¬æããããŸããããã詳现ãªåæã¯ç§ã®äºåããŒãã«ãããŸãã
-
R_SetupFrame
ïŒBSPããã€ãã¹ããŠçŸåšã®èŠç¹ãååŸãïŒåŒã³åºãMod_PointInLeaf
ïŒãèŠç¹ã®clusterIDãã«ä¿åãr_viewcluster
ãŸãã -
R_MarkLeaves
ïŒçŸåšã®ãã©ãŠãºã¯ã©ã¹ã¿ãŒïŒr_viewcluster
ïŒãPVSãåä¿¡ããŠââ解åããŸããPVSã䜿çšããŠãç®ã«èŠããé¡ãããŒã¯ããŸãã -
R_PushDlights
ïŒBSPãå床䜿çšããŠãé¢ãåé¢ããèé¢ã«ç§»åããŸããé¡ãå¯èŠãšããŠããŒã¯ãããŠããå Žåãã©ã€ãããã®é¡ã«åœ±é¿ãäžãããã©ããã確èªããŸãã -
R_EdgeDrawing
ïŒã¬ãã«ã®èŠèŠåã
-
R_RenderWorld
ïŒåé¢ããèé¢ãžã®BSPãã€ãã¹
- 衚瀺ãããŠãããã¹ãŠã®ããªãŽã³ãã¹ã¯ãªãŒã³ã¹ããŒã¹ã«æ圱ããïŒã°ããŒãã«ãšããžããŒãã«ãæ§ç¯ããŸãã
- ( ).
-
R_ScanEdges
: , . :
-
R_InsertNewEdges
: , . -
(*pdrawfunc)()
: , . . . -
D_DrawSurfaces
: , .
-
-
-
R_DrawEntitiesOnList
: , BModel (BModel â ). (, , )... -
R_DrawAlphaSurfaces
: -
R_CalcPalette
ïŒãã¹ããšãã§ã¯ãã®èšç®ãããšãã°ãè²ã®æ··åïŒæå·ãåãããšããã¢ã€ãã ãæŸã£ããšããªã©ïŒ
R_RenderFrame { R_SetupFrame // pdrawfunc , : GDI DirectDraw { Mod_PointInLeaf // , ( BSP-) r_viewcluster } R_MarkLeaves // (r_viewcluster) // PVS R_PushDlights // , , dlight_t* r_newrefdef.dlights. // R_EdgeDrawing // { R_BeginEdgeFrame // pdrawfunc, R_RenderWorld // // (surf_max - ) R_DrawBEntitiesOnList// , . R_ScanEdges // : // Z- ( ) { for (iv=r_refdef.vrect.y ; iv<bottom ; iv++) { R_InsertNewEdges // AET GET (*pdrawfunc)(); // D_DrawSurfaces // } // R_InsertNewEdges // AET GET (*pdrawfunc)(); // D_DrawSurfaces // } } R_DrawEntitiesOnList // , .... // Z- . R_DrawParticles // ! R_DrawAlphaSurfaces // <code>pics/colormap.pcx</code>. R_SetLightLevel // ( !) R_CalcPalette // ( ), }
R_SetupFrameïŒBSPã³ã³ãããŒã«
ãã€ããªã¹ããŒã¹ããŒãã£ã·ã§ã³ããªãŒãã©ããŒãµã«ã¯ãã³ãŒãå šäœã§å®è¡ãããŸããããã¯ãå®å®ããé床ã®åŒ·åãªã¡ã«ããºã ã§ãããããªãŽã³ãåé¢ããèé¢ãŸãã¯èé¢ããåé¢ã«äžŠã¹æ¿ããããšãã§ããŸãããããç解ããã«ã¯ãæ§é ãç解ããå¿ èŠããããŸã
cplane_t
ïŒ
typedef struct cplane_s { vec3_t normal; float dist; } cplane_t;
ããŒãã®å²ç·å¹³é¢ããã®è·é¢ãŸãã¯ãã€ã³ããèšç®ããã«ã¯ããã®åº§æšãå¹³é¢ã®æ¹çšåŒã«æ¿å ¥ããã ãã§ãã
int d = DotProduct (p,plane->normal) - plane->dist;
ãµã€ã³ã®ãããã§
d
ãé£è¡æ©ã®åã«ããã®ãåŸãã«ããã®ãããããã䞊ã¹æ¿ããã§ããŸãããã®ããã»ã¹ã¯ãDoomããQuake3ãŸã§ã®ãšã³ãžã³ã§äœ¿çšãããŠããŸãã
R_MarkLeavesïŒPVSãã«ã¯è§£å
Quake 1ãœãŒã¹ã³ãŒãã®åæ㧠PVSã®è§£åãç解ããæ¹æ³ã¯å®å šã«ééã£ãŠããŸããããšã³ã³ãŒããããã®ã¯ããã1éã®è·é¢ã§ã¯ãªãã0x00ã«æžã蟌ãŸãããã€ãæ°ã ãã§ããPVSã§ã¯ãã°ã«ãŒãå§çž®0x00ã®ã¿ãå®è¡ãããŸãïŒå§çž®ã¹ããªãŒã ã®èªã¿åãæïŒ
- å§çž®ãããPVSãããŒã以å€ã®ãã€ããèªã¿åããããšã解åãããããŒãžã§ã³ã«æžã蟌ãŸããŸãã
- ãã€ã0x00ãå§çž®PVSããèªã¿åãããå Žåã次ã®ãã€ãã¯ã¹ããããããã€ãæ°ã瀺ããŸãã
æåã®ã±ãŒã¹ã§ã¯ãäœãå§çž®ãããŸãããã°ã«ãŒãå§çž®ã¯ã2çªç®ã®å Žåã«ã®ã¿å®è¡ãããŸãã
byte *Mod_DecompressVis (byte *in, model_t *model) { static byte decompressed[MAX_MAP_LEAFS/8]; // = 1 , 65536 / 8 = 8 192 // PVS. int c; byte *out; int row; row = (model->vis->numclusters+7)>>3; out = decompressed; do { if (*in) // , . { *out++ = *in++; continue; } c = in[1]; // "", : (in[1]) in += 2; // PVS. while (c) { *out++ = 0; c--; } } while (out - decompressed < row); return decompressed; }
å¿ èŠã«å¿ããŠãæ倧255ãã€ãïŒ255 * 8ãªãŒãïŒãŸã§ã¹ãããã§ããŸãããã®åŸã次ã®255ãã€ãã®ããã«ã¹ãããããæ°å€ã§ãŒããå床远å ããå¿ èŠããããŸããã€ãŸãã511ãã€ãïŒ511 * 8ãªãŒãïŒã®ãã¹ã«ã¯4ãã€ããå¿ èŠã§ãïŒ0-255-0-255
äŸïŒ
// 80 , 10 : =1, =0 PVS 0000 0000 0000 0000 0000 0000 0000 0000 0011 1100 1011 1111 0000 0000 0000 0000 0000 0000 0000 0000 PVS 0x00 0x00 0x00 0x00 0x39 0xBF 0x00 0x00 0x00 0x00 // !! !! PVS 0000 0000 0000 1000 0011 1100 1011 1111 0000 0000 0000 1000 PVS 0x00 0x04 0x39 0xBF 0x00 0x04
çŸåšã®ã¯ã©ã¹ã¿ãŒã®PVSã解åãããšãPVSã§è¡šç€ºãããŠãããšèŠãªãããã¯ã©ã¹ã¿ãŒã«å±ããåã ã®é¡ã衚瀺ãããŸãïŒ
QïŒ
i
解åãããPVSã䜿çšããŠç¹å®ã®èå¥åãæã€ã¯ã©ã¹ã¿ãŒã®è¡šç€ºã確èªããã«ã¯ã©ãããã°ããã§ããïŒ
OïŒãã€ãi / 8 PVSãš1 <<ïŒiïŒ 8ïŒã®éã®ãããAND
char isVisible(byte* pvs, int i) { // i>>3 = i/8 // i&7 = i%8 return pvs[i>>3] & (1<<(i&7)) }
Quake1ã®å Žåãšåæ§ã«ãããªãŽã³ãå¯èŠãšããŠããŒã¯ããããã«äœ¿çšããåªããããªãã¯ããããŸãããã©ã°ã䜿çšããŠåãã¬ãŒã ã®éå§æã«ãããããªã»ãããã代ããã«ãé©çšãã
int
ãŸããåãã¬ãŒã ã®éå§æã«ããã¬ãŒã ã«ãŠã³ã¿ãŒã¯
r_visframecount
1ãã€å¢å ã
R_MarkLeaves
ãŸããPVSã解åããåŸã
visframe
çŸåšã®å€ããã£ãŒã«ãã«å²ãåœãŠãããšã«ããããã¹ãŠã®ãŸãŒã³ãå¯èŠãšããŠããŒã¯ãããŸã
r_visframecount
ã
ã³ãŒãã®åŸåã§ãããŒã/ã¯ã©ã¹ã¿ãŒã®å¯èŠæ§ã¯åžžã«æ¬¡ã®æ¹æ³ã§ãã§ãã¯ãããŸãã
if (node->visframe == r_visframecount) { // }
R_PushDlightsïŒåçç §æ
ã¢ã¯ãã£ããªåçå æºã®ålightIDã«ã€ããŠãBSPã¯å æºã®äœçœ®ããååž°çã«èµ°æ»ãããŸããå æºãšã¯ã©ã¹ã¿ãŒéã®è·é¢ãèšç®ãããå ã®åŒ·åºŠãã¯ã©ã¹ã¿ãŒããã®è·é¢ããã倧ããå Žåãã¯ã©ã¹ã¿ãŒå ã®ãã¹ãŠã®ãµãŒãã§ã¹ããã®å æºèå¥åã®åœ±é¿ãåãããšããŒã¯ãããŸãã
泚ïŒãµãŒãã§ã¹ã«ã¯2ã€ã®ãã£ãŒã«ããããŒã¯ãããŠããŸãã
-
dlightframe
-ããã¯ãint
ã¯ã©ã¹ã¿ãŒã®å¯èŠæ§ãããŒã¯ããå Žåãšåãæ¹æ³ã§äœ¿çšããããã©ã°ã§ãïŒåãã¬ãŒã ã®ãã¹ãŠã®ãã©ã°ããªã»ãããã代ããã«ãã°ããŒãã«å€æ°ãå¢å ãr_dlightframecount
ãŸããã©ã€ããåäœããããã«r_dlightframecount
ã¯ãçãããªããã°ãªããŸããsurf.dlightframe
ã -
dlightbits
int
ãã®é¢ã«åœ±é¿ãäžããå æºã®ããŸããŸãªé åã®ã€ã³ããã¯ã¹ãæ ŒçŽããããã«äœ¿çšãããããããã¯ãã«ã§ãã
R_EdgeDrawingïŒã¬ãã«ã®èŠèŠå
R_EdgeDrawing
-ããã¯ãœãããŠã§ã¢ã¬ã³ãã©ãŒã®ã¢ã³ã¹ã¿ãŒã§ãããæãç解ãã«ãããã®ã§ããããã«å¯ŸåŠããã«ã¯ãã¡ã€ã³ã®ããŒã¿æ§é ãèŠãå¿ èŠããããŸãïŒ
ã¹ã¿ãã¯
surf_t
ïŒãããã·ãšããŠåäœ
m_surface_t
ïŒã¯CPUã¹ã¿ãã¯ã«é 眮ãããŸãã
// surf_t *surfaces ; // surf_t *surface_p ; // surf_t *surf_max ; // // bsp- " ", // , // surfaces[1] , Note: surfaces - Note: surfaces -
ãã®ã¹ã¿ãã¯ã¯ãBSPãåé¢ããèé¢ãžç§»åãããšãã«èªã¿èŸŒãŸããŸãã衚瀺ãããŠããåããªãŽã³ã¯ããããã·ãµãŒãã§ã¹ãšããŠã¹ã¿ãã¯ã«ããã·ã¥ãããŸããåŸã§ãã¢ã¯ãã£ããªãšããžã®ããŒãã«ãåã£ãŠç»é¢ã®è¡ãçæãããšãã«ãã¡ã¢ãªå ã®ã¢ãã¬ã¹ãæ¯èŒããã ãã§ãä»ã®ãã¹ãŠã®ããªãŽã³ã®åã«ããããªãŽã³ãéåžžã«ãã°ãã確èªã§ããŸãïŒã¹ã¿ãã¯ãäœãã»ã©ãèŠç¹ã«è¿ãïŒãããããã©ã€ã³ããšã®ç»åæ§ç¯ã®å€æã¢ã«ãŽãªãºã ã«ãæ¥ç¶æ§ããå®è£ ããæ¹æ³ã§ãã
泚ïŒã¹ã¿ãã¯ã®åèŠçŽ ã«ã¯ãã€ã³ã¿ãŒãã«ãããã¡ã¹ã¿ãã¯ã®èŠçŽ ãæããã€ã³ã¿ãŒã®ãªã¹ãïŒãã¯ã¹ãã£ãã§ãŒã³ãšåŒã°ããïŒããããŸãïŒä»¥äžã§èª¬æããŸãïŒãééã¯ãããã¡ã«æ ŒçŽããããã¯ã¹ãã£ãã§ãŒã³ããæç»ãããŠééããã¯ã¹ãã£ã°ã«ãŒãåããCPUããªãã£ãã·ã¥ãããã¡ãæ倧åããŸãã
ã¹ã¿ãã¯ã¯æåã«åæåãããŸã
R_EdgeDrawing
ïŒ
void R_EdgeDrawing (void) { // : 64 surf_t lsurfs[NUMSTACKSURFACES +((CACHE_SIZE - 1) / sizeof(surf_t)) + 1]; surfaces = (surf_t *) (((long)&lsurfs[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1)); surf_max = &surfaces[r_cnumsurfs]; // 0 ; , 0 // , , surfaces--; R_SurfacePatch (); R_BeginEdgeFrame (); // surface_p = &surfaces[2]; // - 1, // 0 - R_RenderWorld { R_RenderFace } R_DrawBEntitiesOnList R_ScanEdges // Z- ( ) { for (iv=r_refdef.vrect.y ; iv<bottom ; iv++) { R_InsertNewEdges // AET GET (*pdrawfunc)(); // D_DrawSurfaces // } // R_InsertNewEdges // AET GET (*pdrawfunc)(); // D_DrawSurfaces // } }
詳现ã¯æ¬¡ã®ãšããã§ãã
-
R_BeginEdgeFrame
ïŒæåŸã®ãã¬ãŒã ããã°ããŒãã«ãšããžããŒãã«ãã¯ãªã¢ããŸãã -
R_RenderWorld
ïŒBSPãã€ãã¹ïŒç»é¢ã«ã¯äœã衚瀺ããªãããšã«æ³šæããŠãã ããïŒïŒ
- å¯èŠãšèŠãªãããåè¡šé¢ã¯ããããã·ã¹ã¿ãã¯ã«ããã·ã¥ãããŸã
surf_t
ã - ãã¹ãŠã®ããªãŽã³ã®é ç¹ãã¹ã¯ãªãŒã³ã¹ããŒã¹ã«æ圱ããã°ããŒãã«ãšããžããŒãã«ã«å ¥åããŸãã
- ãŸãããã¹ãŠã®é ç¹ã«å¯ŸããŠ1 / Zå€ãçæããŠãééã§Zãããã¡ãŒãçæã§ããããã«ããŸãã
- å¯èŠãšèŠãªãããåè¡šé¢ã¯ããããã·ã¹ã¿ãã¯ã«ããã·ã¥ãããŸã
-
R_DrawBEntitiesOnList
ïŒãã®ãã©ã°ã¡ã³ããäœãããã®ãåãããŸããã -
R_ScanEdges
ïŒã¬ãã«ã¬ã³ããªã³ã°çšã«çŸåšåä¿¡ããŠãããã¹ãŠã®æ å ±ãçµåããŸãã
- ã¢ã¯ãã£ããªãšããžã®ããŒãã«ã®åæåã
- ééãããã¡ãŒïŒã¹ã¿ãã¯ïŒã®åæåïŒ
// espan_t *span_p; // espan_t *max_span_p; // . span_p , // : (basespans) void R_ScanEdges (void) { int iv, bottom; byte basespans[MAXSPANS*sizeof(espan_t)+CACHE_SIZE]; ... }
- ç»é¢ã®äžéšããäžéšãžã®ç»åã®ããã°ã¬ãã·ãæ§ç¯ã®ã¢ã«ãŽãªãºã ãèµ·åããŸãã
- è¡ããšã«ïŒ
- ã°ããŒãã«ãšããžããŒãã«ããã¢ã¯ãã£ããšããžã®ããŒãã«ãæŽæ°ããŸãã
- è¡å
šäœã®ã¢ã¯ãã£ããšããžã®ããŒãã«ãå®è¡ããïŒ
- ãµãŒãã§ã¹ã¹ã¿ãã¯å ã®ã¢ãã¬ã¹ã䜿çšããŠå¯èŠããªãŽã³ãå®çŸ©ããŸãã
- ééãééãããã¡ãŒã«æž¡ãã
- ééãããã¡ãŒããã£ã±ãã®å ŽåïŒãã¹ãŠã®ééãæç»ããééã¹ã¿ãã¯ããªã»ããããŸãã
- ãããã¡å ã®æ®ãã®ééã確èªããŸããäœããæ®ã£ãŠããå ŽåïŒãã¹ãŠã®ééãæç»ããééã¹ã¿ãã¯ããªã»ããããŸãã
ãããªäœåR_EdgeDrawing
以äžã®ãããªã§ã¯ããšã³ãžã³ã¯1024x768ã®è§£å床ã§åäœããŸãããŸããç¹æ®ãªcvarã䜿çšãããšé床ãäœäžããŸã
sw_drawflat 1
ãããã«ããããã¯ã¹ãã£ãªãã§å€è§åœ¢ãç°ãªãè²ã§ã¬ã³ããªã³ã°ã§ããŸãã
ãã®ãããªã§ã¯ãå€ãã®èå³æ·±ãããšãããããŸãã
- ç»é¢ã¯äžããäžã«çæãããŸããããã¯ããã°ã¬ãã·ãã€ã¡ãŒãžã³ã°ã®äžè¬çãªã¢ã«ãŽãªãºã ã§ãã
- , . Pentium: textureId , « ». . , .
- , .
- , : , .
- 40% , 10%. , , .
- OMG, .
:
ïŒã6ãããã°ã¬ãŒã¹ã±ãŒã«ïŒRãGãBã®æãããã£ãã«ã«1ã€ïŒãåãµã³ããªã³ã°ããå¶çŽãã¬ãããæºããããã«å¿ èŠæ®å¿µãªãããçŸãã24ãããã®ç¹ç¯ã«ãŒãRGB
ã¢ãŒã«ã€ãã«ä¿åãããŠãããã®
PAK
ïŒ24ãããïŒ
ãšè² è·åŸãã£ã¹ã¯ãšæ倧6ãããã®ãªãµã³ããªã³ã°ïŒ
ãããŠããã¹ãŠäžç·ã«ïŒé¡ã®ãã¯ã¹ãã£ã¯[0.255]ã®ç¯å²ã®è²ãäžããŸãããã®å€ã¯ããã¬ããã®è²ã®ã€ã³ããã¯ã¹ãäœæããŸã
pics/colormap.pcx
ã
ç §æãããã¯ãã£ã«ã¿ãŒãããŸãããã®çµæãç¯å²[0.63]ã®å€ãååŸããŸãã
ããã§ã
pics/colormap.pcx
ãšã³ãžã³ã¯äžéšã䜿çšããŠããã¬ããã®åžæã®äœçœ®ãéžæã§ããŸããæçµçµæãååŸããããã«ã圌ã¯ãã¯ã¹ãã£ã®å ¥åå€ãX座æšãšããŠäœ¿çšããã€ã«ãããŒã·ã§ã³* 63ãY座æšãšããŠäœ¿çšããŸã
ã
å人çã«ã¯ãæé«ã ãšæããŸãïŒ256è²ã®64ã®ã°ã©ããŒã·ã§ã³ãæš¡å£ããŠ...åèš256è²ïŒ
è¡šé¢ãµãã·ã¹ãã
åã®ã¹ã¯ãªãŒã³ã·ã§ããããããµãŒãã§ã¹çæãCPUã«ãšã£ãŠQuake2ã®æãèŠæ±ã®å³ããéšåã§ããããšãæããã§ãïŒããã¯ã以äžã®ãããã¡ã€ã©ãŒã®çµæã«ãã£ãŠç¢ºèªãããŸãïŒãé床ãšã¡ã¢ãªæ¶è²»ã«é¢ããŠèš±å®¹ã§ãããµãŒãã§ã¹çæã¯ã次ã®2ã€ã®ã¡ã«ããºã ã«ãã£ãŠæäŸãããŸãã
- MIPãã¯ã¹ãã£ãªã³ã°ïŒããããããã³ã°ïŒ
- ãã£ãã·ã³ã°
Surfaceãµãã·ã¹ãã ïŒMIPãã¯ã¹ãã£ãªã³ã°
ããªãŽã³ãã¹ã¯ãªãŒã³ç©ºéã«æ圱ãããšããã®è·é¢ã®1 / ZãçæãããŸããæãè¿ãé ç¹ã¯ã䜿çšããMIPãã¯ã¹ãã£ã®ã¬ãã«ã決å®ããããã«äœ¿çšãããŸããã©ã€ãã£ã³ã°ãããã®äŸãšãMIPãã¯ã¹ãã£ã®ã¬ãã«ã«å¿ããŠãã£ã«ã¿ãªã³ã°ãããæ¹æ³ã®äŸã瀺ããŸãã
ã©ã³ãã ã€ã¡ãŒãžã§ã®Quake2ãã€ãªãã¢ãã£ã«ã¿ãªã³ã°ã®å質ããã¹ãããããã«åãçµãã ãããããžã§ã¯ãïŒarchiveã§ãã
以äžã¯ã13x15ãã¯ã»ã«ç §æãããã«å¯ŸããŠå®è¡ããããã¹ãã®çµæã§ãã
ã¬ãã«3 MIPãã¯ã¹ãã£ïŒãããã¯ã¯2x2ãã¯ã»ã«ã§ãã
ã¬ãã«2ã®MIPãã¯ã¹ãã£ïŒãããã¯ã¯4x4ãã¯ã»ã«ã§ãã
ã¬ãã«1 MIPãã¯ã¹ãã£ïŒãããã¯ã®ãµã€ãºã¯8x8ãã¯ã»ã«ã§ãã
ã¬ãã«0 MIPãã¯ã¹ãã£ïŒãããã¯ã®ãµã€ãºã¯16x16ãã¯ã»ã«ã§ãã
ãã£ã«ã¿ãªã³ã°ãç解ããããã®éµã¯ããã¹ãŠãã¯ãŒã«ã空éã®ããªãŽã³ã®ãµã€ãºã«åºã¥ããŠããããšã§ãïŒå¹ ãšé«ãã¯ãšåŒã°ããŸã
extent
ïŒïŒ
- Quake2ããªããã»ããµã¯ãããªãŽã³ïŒXãŸãã¯YïŒã256以äžã§ããã16ã®åæ°ã§ããããšãä¿èšŒããŸãã
- äžçã®ç©ºéã«ãããå€è§åœ¢ã®æ¬¡å
ããã以äžãæšæž¬ã§ããŸãã
- ã©ã€ãã£ã³ã°ããããµã€ãºïŒãã¯ã»ã«åäœïŒïŒLmpDim = PolyDim / 16 + 1
- è¡šé¢ãµã€ãºïŒãããã¯åäœïŒïŒSurDim = LmpDim -1 = PolyDim / 16
次ã®å³ã§ã¯ãããªãŽã³ã®å¯žæ³ã¯ïŒ3.4ïŒãç §æãããã¯ïŒ4.5ïŒãã¯ã»ã«ã§ãããçž®éãããµãŒãã§ã¹ã®ãµã€ãºã¯åžžã«ãããã¯ã®ãµã€ãºïŒ3.4ïŒã§ãã MIPãã¯ã¹ãã£ã®ã¬ãã«ã¯ããã¯ã»ã«åäœã®ãããã¯ãµã€ãºã決å®ããããããã¯ã»ã«åäœã®ç·è¡šé¢ãµã€ãºã決å®ããŸãã
ããã¯ãã¹ãŠã§è¡ãã
R_DrawSurface
ãŸãã MIPãã¯ã¹ãã£ã®ã¬ãã«ã¯
surfmiptable
ãç®çã®ã©ã¹ã¿ã©ã€ãºé¢æ°ãéžæããé¢æ°ãã€ã³ã¿ãŒã®é åïŒïŒã䜿çšããŠéžæãããŸãã
static void (*surfmiptable[4])(void) = { R_DrawSurfaceBlock8_mip0, R_DrawSurfaceBlock8_mip1, R_DrawSurfaceBlock8_mip2, R_DrawSurfaceBlock8_mip3 }; R_DrawSurface { pblockdrawer = surfmiptable[r_drawsurf.surfmip]; for (u=0 ; u<r_numhblocks; u++) (*pblockdrawer)(); }
以äžã®å€æŽããããšã³ãžã³ã§ã¯ã3ã€ã®ã¬ãã«ã®MIPãã¯ã¹ãã£ãèŠãããšãã§ããŸãïŒ0-ã°ã¬ãŒã1-é»è²ã2-èµ€ïŒ
ãã£ã«ã¿ãŒã¯ãµãŒãã§ã¹ã®ãããã¯[i] [j]ãçæãããšãã«ãããã¯ã«ãã£ãŠå®è¡ããããã£ã«ã¿ãŒã¯ã©ã€ãã£ã³ã°ãããã®å€ã䜿çšããŸãïŒlightmap [i] [ j]ãã©ã€ãããã[i + 1] [j]ãã©ã€ãããã[i] [j + 1]ããã³ã©ã€ãããã[i + 1] [j + 1]ïŒæ¬è³ªçã«ã座æšã«çŽæ¥4ã€ã®ãã¯ã»ã«ã䜿çšããå³äžã«3ã€ãããã¯ããŠã§ã€ãè£éã§ã¯ãªããçæãããå€ã«ãã£ãŠæåã«åçŽæ¹åã«ã次ã«æ°Žå¹³æ¹åã«ç·åœ¢è£éã«ãã£ãŠè¡ãããããšã«æ³šæããŠãã ãããèŠããã«ãããã¯ãŠã£ãããã£ã¢ã®åç·åœ¢ãã£ã«ã¿ãªã³ã°ã«é¢ããèšäºãšãŸã£ããåãããã«æ©èœããŸãã
ãããŠä»ããã¹ãŠäžç·ã«ïŒ
ãªãªãžãã«ã®ç §æãããã13x15ãã¯ã»ã«ã
ãã£ã«ã¿ãªã³ã°ãã¬ãã«0 MIPãã¯ã¹ãã£ïŒ16x16ãããã¯ïŒ= 192x224ãã¯ã»ã«ã
çµæïŒ
Surfaceãµãã·ã¹ãã ïŒãã£ãã·ã³ã°
ã§ãããšã³ãžã³ãç©æ¥µçã«ã¡ã¢ãªã管çããããã«äœ¿çšãããŠãããšããäºå®ã«ããããããã
malloc
ãš
free
圌ã¯ãŸã è¡šé¢ããã£ãã·ã¥ããããã®ç¬èªã®ã¡ã¢ãªãããŒãžã£ã䜿çšããŠããŸããã¡ã¢ãªãããã¯ã¯ãèŠèŠåã®è§£å床ãå€æããçŽåŸã«åæåãããŸãã
size = SURFCACHE_SIZE_AT_320X240; pix = vid.width*vid.height; if (pix > 64000) size += (pix-64000)*3; size = (size + 8191) & ~8191; sc_base = (surfcache_t *)malloc(size); sc_rover = sc_base;
æåã®ããŒããŒ
sc_rover
ã¯ãããžãŒç¶æ ã远跡ããããã«ãããã¯ã«é 眮ãããŠããŸããããŒããŒãã¡ã¢ãªã®æåŸã«å°éãããšãæãç³ãŸããæ¬è³ªçã«å€ãè¡šé¢ã眮ãæããŸããäºçŽãããã¡ã¢ãªã®éã¯ãã°ã©ãã§ç¢ºèªã§ããŸãã
ãããã¯ããæ°ããã¡ã¢ãªãå²ãåœãŠãããæ¹æ³ã¯æ¬¡ã®ãšããã§ãã
memLoc = (int)&((surfcache_t *)0)->data[size]; // + . memLoc = (memLoc + 3) & ~3; // FCS: , 4 sc_rover = (surfcache_t *)( (byte *)new + size);
泚ïŒé«éãã£ãã·ã¥å²ãåœãŠã®ããªãã¯ïŒã¡ã¢ãªã·ã¹ãã ã«ç§»åã§ããŸãïŒ
泚ïŒããããŒã¯ãèŠæ±ãããã¡ã¢ãªãµã€ãºã®äžã«é 眮ãããŸããNULLïŒ
((surfcache_t *)0)
ïŒãã€ã³ã¿ãŒã䜿çšããéåžžã«å¥åŠãªè¡ïŒãã ããé 延ããªãããããã¹ãŠæ£åžžã§ãïŒã
貧ãã人ã ã®ããã®éèŠæ圱ïŒ
ããŸããŸãªã€ã³ã¿ãŒãããã®èšäºã¯ãQuake2ãåçŽãªåŒã§ãå質ã®åº§æšãŸãã¯è¡åïŒä»¥äžããã®ã³ãŒã
R_ClipAndDrawPoly
ïŒãªãã§ã貧ãã人ã ã®ããã®éèŠæ圱ãã䜿çšããããšã瀺åããŠããŸã
XscreenSpace = X / Z * XScale YscreenSpace = Y / Z * YScale
XScaleãšYScaleã¯ãèŠéãšã¢ã¹ãã¯ãæ¯ã«ãã£ãŠæ±ºãŸããŸãã
ãã®ãããªéèŠå³æ³ã¯ãGL_PROJECTION + Wé€ç®ã¹ãããäžã«OpenGLã§å®éã«çºçãããã®ã«äŒŒãŠããŸãã
: ======================= | X | Y | Z | 1 -------------------------------------------------- | | XScale 0 0 0 | XClip 0 YScale 0 0 | YClip 0 0 V1 V2 | ZClip 0 0 -1 0 | WClip : ================ XClip = X * XScale YClip = Y * YScale ZClip = / WClip = -Z NDC W: ========= XNDC = XClip/WClip = X * XScale / -Z YNDC = YClip/WClip = Y * YScale / -Z
æåã®çŽ æŽãªèšŒæ ïŒãªãŒããŒã¬ã€ã¹ã¯ãªãŒã³ã·ã§ãããæ¯èŒããŸããã³ãŒããèŠããšïŒè²§ãã人ã ãžã®æ圱ïŒããïŒ
R_DrawEntitiesOnListïŒã¹ãã©ã€ããšãªããžã§ã¯ã
èŠèŠåããã»ã¹ã®ãã®æ®µéã§ã¯ãã¬ãã«ã¯ãã§ã«ç»é¢ã«ã¬ã³ããªã³ã°ãããŠããŸãïŒ
ãšã³ãžã³ã¯16ãããã®zãããã¡ãŒãçæããŸããïŒèšé²ãããŸãããããŸã èªã¿åãããŠããŸããïŒïŒ
泚ïŒå€ãè¿ãã»ã©ããæãããïŒOpenGLã«å¯ŸããŠïŒè¿ãã»ã©ãæããïŒãããã¯ã1 / ZãZã§ã¯ãªãZãããã¡ãŒã«æ ŒçŽãããããã§ãã
ãã€ã³ã¿ããå§ãŸã16ãããã®zãããã¡ãä¿åãããŸã
d_pzbuffer
ã
short *d_pzbuffer;
äžèšã®ããã«ãMichael Abrashã®èšäºã代æ¿æ¡ã®æ€èšïŒQuakeã®é é¢æ¶å»ãã§èª¬æãããŠããåŒãçŽæ¥é©çšããããšã«ããã1 / Zãä¿åãããŸãã
ããã¯ãã«äœçœ®ããŠããŸã
D_DrawZSpans
ïŒ
zi = d_ziorigin + dv*d_zistepv + du*d_zistepu;
1 / Zãå®éã«è£éã§ããæ°åŠçãªèšŒæã«èå³ãããå Žåã¯ãKok-Lim Lowã®èšäºPDFãã芧ãã ããã
ã¬ãã«ã®èŠèŠåã®æ®µéã§æšå®ãããZãããã¡ãããšã³ãã£ãã£ã®æ£ããããªãã³ã°ã®å ¥åãšããŠäœ¿çšãããããã«ãªããŸããã
ã¢ãã¡ãŒã·ã§ã³åããããšã³ãã£ãã£ïŒãã¬ã€ã€ãŒãšæµïŒã«ã€ããŠå°ãïŒ
- Quake1ã¯ããŒãã¬ãŒã ã®ã¿ãã¬ã³ããªã³ã°ããŸããããçŸåšã§ã¯ãã¹ãŠã®é ç¹ã
R_AliasSetUpLerpData
ã¹ã ãŒãºãªã¢ãã¡ãŒã·ã§ã³ã®ããã«LERPïŒïŒãåããŸãã - ã¬ã³ããªã³ã°ã®ããã®Quake1ã¯ããšã³ãã£ãã£ãBLOBãšããŠè¡šç€ºããŸãããããã¯äžæ£ç¢ºã§ãããéåžžã«é«éãªã¬ã³ããªã³ã°æ¹æ³ã§ããQuake2ã¯ãããæŸæ£ããBoundingBoxããã¹ããããã¯ã¿ãŒè£œåã§åé¢ããã¹ãããåŸããšã³ãã£ãã£ãéåžžã«ã¬ã³ããªã³ã°ããŸããã
ç §æã«é¢ããŠïŒ
- ãã¹ãŠã®åœ±ãæãããããã§ã¯ãããŸããã
- ããªãŽã³ã«ã¯ãç
§æã®æ¹åãå³å¯ã«å®çŸ©ãããã°ãŒããŒã·ã§ãŒãã£ã³ã°ããããŸãïŒ
{-1, 0, 0}
fromR_AliasSetupLighting
ïŒã - å ã®åŒ·åºŠã¯ããããåããããé¢å æºã®åŒ·åºŠã«åºã¥ããŠããŸãã
R_DrawAlphaSurfacesã®åéææ§
ãã¬ããã€ã³ããã¯ã¹ã䜿çšããŠåéææ§ãå®è¡ããå¿ èŠããããŸããèšäºã§ã¯10åãããç¹°ãè¿ããŠãããšæããŸããããããç§ã«ãšã£ãŠé©ãã»ã©çŽ æŽãããããšãè¡šçŸã§ããå¯äžã®æ¹æ³ã§ãã
ééããªãŽã³ã¯æ¬¡ã®ããã«ã¬ã³ããªã³ã°ãããŸãã
- ãã¹ãŠã®é ç¹ãç»é¢ç©ºéã«æ圱ããŸãã
- 巊端ãšå³ç«¯ã®å®çŸ©ã
- è¡šé¢ãæªãã§ããªãå ŽåïŒã¢ãã¡ãŒã·ã§ã³ã®æ°ŽïŒãRAMã®ãã£ãã·ã¥ã·ã¹ãã ã§èŠèŠåãå®è¡ãããŸãã
ãã®åŸãè¡šé¢ãå®å šã«äžéæã§ãªãå Žåã¯ããªãã¹ã¯ãªãŒã³ãã¬ãŒã ãããã¡ãŒãšæ··åããå¿ èŠããããŸãã
ããªãã¯ã¯ãã€ã¡ãŒãžã®2çªç®ã®éšåã䜿çšããŠå®è¡
pics/colormap.pcx
ãããŸããããã¯ããµãŒãã§ã¹ãã£ãã·ã¥ã®ãœãŒã¹ãã¯ã»ã«ãšã¿ãŒã²ãããã¯ã»ã«ïŒãã¬ãŒã ããšã®ãããã¡ãŒå ïŒãæ··åããããã®ã«ãã¯ã¢ããããŒãã«ãšããŠäœ¿çšãããŸãã
ã
以äžã®ã¢ãã¡ãŒã·ã§ã³ã¯ããã¬ããã®ãã¯ã»ã«ããšã®æ··åã®ååŸã®ãã¬ãŒã ã瀺ããŠããŸãã
R_CalcPaletteïŒãã¹ããšãã§ã¯ãæäœãšã¬ã³ãè£æ£
ãšã³ãžã³ã¯ãããã¬ããã®ãã¯ã»ã«åäœã®æ··åããšããã¬ããã«åºã¥ããè²ã®ã°ã©ããŒã·ã§ã³ã®éžæããå®è¡ã§ããã ãã§ãªããå¥åº·ç¶æ ã®äœäžãã¢ã€ãã ã®åéã«é¢ããæ å ±ãéä¿¡ããããã«ãã¬ããå šäœãå€æŽããããšãã§ããŸãïŒ
ã²ãŒã ã®ãµãŒããŒåŽDLLã®ãã¢ãã©ã€ã¶ãŒããè²ãæ··åããå¿ èŠãããå ŽåèŠèŠåããã»ã¹ã®æåŸã«ã圌
float player_state_t.blend[4]
ã¯ã²ãŒã å ã®ãã¹ãŠã®ãã¬ãŒã€ãŒã®RGBAå€æ°ã®å€ãèšå®ããå¿ èŠããããŸããããã®å€ã¯ãããã¯ãŒã¯ãä»ããŠéä¿¡ãããã«ã³ããŒããã
refdef.blend[4]
åŸãã¬ã³ãã©ãŒDLLãæž¡ãããŸãïŒæ è¡ã§ãïŒïŒãæ€åºããããšããã¬ããã€ã³ããã¯ã¹ã®256 RGBèŠçŽ ããšã«æ··åãããŸããã¬ã³ãè£æ£åŸããã¬ãããåã³ãããªã«ãŒãã«ããŒããããŸãã
R_CalcPalette
ã§
r_main.c
ïŒ
// newcolor = color * alpha + blend * (1 - alpha) alpha = r_newrefdef.blend[3]; premult[0] = r_newrefdef.blend[0]*alpha*255; premult[1] = r_newrefdef.blend[1]*alpha*255; premult[2] = r_newrefdef.blend[2]*alpha*255; one_minus_alpha = (1.0 - alpha); in = (byte *)d_8to24table; out = palette[0]; for (i=0 ; i<256 ; i++, in+=4, out+=4) for (j=0 ; j<3 ; j++) v = premult[j] + one_minus_alpha * in[j];
èå³æ·±ãäºå®ïŒäžèšã®æ¹æ³ã§ãã¬ãããå€æŽããåŸãããã«å¯ŸããŠã¬ã³ãè£æ£ãå®è¡ããå¿ èŠããããŸãïŒc
R_GammaCorrectAndSetPalette
ïŒïŒ
ã¬ã³ãè£æ£ã¯ãåŒã³åºã
pow
ãšé€ç®ãå«ããªãœãŒã¹éçŽåã®æäœã§ã...ããã«ãåãã£ãã«RãGããã³Bã«ã©ãŒå€ïŒ
int newValue = 255 * pow ( (value+0.5)/255.5 , gammaFactor ) + 0.5;
åèšã§3ã€ã®åŒã³åºãããã
pow
ãããã¯- ã3ã€ã®æäœéšéããã¬ããã®256ã€ã³ããã¯ã¹å€ã®ããããã«ã€ããŠã3ã®åãšä¹ç®ã®6ã€ã®æäœã¯éåžžã«å€ãã¯ã
ãã ããå ¥åã¯ãã£ãã«ããšã«8ãããã«å¶éãããŠãããããäºåã«å®å šãªè£æ£ãèšç®ãã256èŠçŽ ã®å°ããªé åã«ãã£ãã·ã¥ã§ããŸãã
void Draw_BuildGammaTable (void) { int i, inf; float g; g = vid_gamma->value; if (g == 1.0) { for (i=0 ; i<256 ; i++) sw_state.gammatable[i] = i; return; } for (i=0 ; i<256 ; i++) { inf = 255 * pow ( (i+0.5)/255.5 , g ) + 0.5; if (inf < 0) inf = 0; if (inf > 255) inf = 255; sw_state.gammatable[i] = inf; } }
ãããã£ãŠããã®ããªãã¯ã«
sw_state.gammatable
ã¯æ€çŽ¢ããŒãã«ïŒïŒã䜿çšãããã¬ã³ãè£æ£ããã»ã¹ãå€§å¹ ã«å éãããŸãã
void R_GammaCorrectAndSetPalette( const unsigned char *palette ) { int i; for ( i = 0; i < 256; i++ ) { sw_state.currentpalette[i*4+0] = sw_state.gammatable[palette[i*4+0]]; sw_state.currentpalette[i*4+1] = sw_state.gammatable[palette[i*4+1]]; sw_state.currentpalette[i*4+2] = sw_state.gammatable[palette[i*4+2]]; } SWimp_SetPalette( sw_state.currentpalette ); }
æ³šïŒ LCDã«ã¯CRTã®ãããªã¬ã³ãã®åé¡ã¯ãªããšå€æãããããããŸãã...ãã ããéåžžã¯CRTç»é¢ã®åäœãæš¡å£ããŸãïŒ
ã³ãŒãçµ±èš
ãœãããŠã§ã¢ã¬ã³ãã©ãŒã®ãããã¯ãéããããã®Clocã³ãŒãã®å°ãã®åæïŒãã®ã¢ãžã¥ãŒã«ã«ã¯14,874è¡ãããŸããããã¯å šäœã®10ïŒ ãå°ãäžåã£ãŠããŸããããã®ã¹ããŒã ãéžæããåã«ä»ã®ããã€ãã®ãã¹ããè¡ââããããããæè³ãããåãçµã¿ã«ã€ããŠã¯ããããŸããã
$ cloc ref_soft/ 39 text files. 38 unique files. 4 files ignored. http://cloc.sourceforge.net v 1.53 T=0.5 s (68.0 files/s, 44420.0 lines/s) ------------------------------------------------------------------------------- Language files blank comment code ------------------------------------------------------------------------------- C 17 2459 2341 8976 Assembly 9 1020 880 3849 C/C++ Header 7 343 293 2047 Teamcenter def 1 0 0 2 ------------------------------------------------------------------------------- SUM: 34 3822 3514 14874 -------------------------------------------------------------------------------
9ã€ã®ãã¡ã€ã«ã§ã®ã¢ã»ã³ãã©ãŒã®æé©åã«
r_*.asm
ã¯ãã³ãŒãããŒã¹å šäœã®25ïŒ ãå«ãŸããŠãããããã¯éåžžã«å°è±¡çãªæ¯çã§ãããœãããŠã§ã¢ã¬ã³ãã©ãŒã«è²»ããããåŽåã®éãéåžžã«æ確ã«ç€ºããŠãããšæããŸããã»ãšãã©ã®ã©ã¹ã¿ã©ã€ãŒãŒã·ã§ã³æé ã¯ãMichael Abrashã«ãã£ãŠx86ããã»ããµçšã«æåã§æé©åãããŠããŸãã圌ã®Graphics Programming Black Bookã§èª¬æãããŠããPentiumæé©åã®ã»ãšãã©ã¯ããããã®ãã¡ã€ã«ã§äœ¿çšãããŠããŸãã
èå³æ·±ãäºå®ïŒæ¬ãšQuake2ã³ãŒãã®ã¡ãœããã®ååã®äžéšã¯åãã§ãïŒäŸïŒïŒ
ScanEdges
ã
ãããã¡ã€ãªã³ã°
ããŸããŸãªãããã¡ã€ã©ãŒã䜿çšããŠã¿ãŸãããããããã¯ãã¹ãŠVisual Studio 2008ã«çµ±åãããŠããŸãã
- AMDã³ãŒãåæ
- Intel VTune Amplifier XE 2011
- Visual Studio Team Profiler
ã¿ã€ã ãµã³ããªã³ã°ãžã®ã¹ãããã¯ãéåžžã«ç°ãªãçµæã瀺ããŸãããããšãã°ãVtuneã¯RAMãããããªã¡ã¢ãªãžã®è»¢éã³ã¹ãïŒ
BitBlit
ïŒãèæ ®ããŸããããä»ã®ãããã¡ã€ã©ãŒã¯ããããéããŸããã
IntelãšAMDã®ãããã¡ã€ã©ãŒã¯æ©åšã®ãã§ãã¯ã«å€±æããŸããïŒãããŠããªããããèµ·ãã£ãã®ããç¥ãã»ã©èªèçã§ã¯ãããŸããïŒããVS 2008 Teamãããã¡ã€ã©ãŒã¯ãããè¡ããŸãã...ç§ã¯ãå§ãããŸããããã²ãŒã ã¯æ¯ç§3ãã¬ãŒã ã®é »åºŠã§åäœããåæã®ããã«20 -2çªç®ã®ã²ãŒã ã«ã¯1æéããããŸããïŒ
ãããã¡ã€ãªã³ã°VS 2008ããŒã ãšãã£ã·ã§ã³ïŒ
çµæã¯æ¬¡ã®ãšããã§ãã
- ãœãããŠã§ã¢ã¬ã³ããªã³ã°ã®ã³ã¹ãã¯èšå€§ã§ãã89ïŒ ã®æéãDLLã«è²»ããããŠããŸãã
- ã²ãŒã ããžãã¯ã¯ã»ãšãã©ç®ç«ããªãïŒ0ïŒ ã
- é©ãã¹ãããšã«ãDirectXãªãŒãã£ãªDLLã«ã¯å€ãã®æéãããããŸãã
libc
quake.exeã³ã¢ãããå€ãã®æéãè²»ãããŸããã
ref_soft.dllã«è²»ãããæéã詳ããèŠãŠã¿ãŸãããã
- åè¿°ããããã«ãã¡ã¢ãªãžã®ãã€ãã®æžã蟌ã¿ã¯éåžžã«é«äŸ¡ã§ãã
- 巚倧ãªã³ã¹ãïŒ33ïŒ
ïŒã¯ãZãããã¡ãŒã®æ§ç¯ã«é¢é£ããŠã
D_DrawZSpans
ãŸãïŒïŒã - èšå€§ãªã³ã¹ãïŒ22ïŒ
ïŒã¯ããªãã¹ã¯ãªãŒã³ãããã¡ãŒã®èšé²ééïŒïŒã«é¢é£ä»ããããŠããŸã
D_DrawZSpans16
ã - ãã£ãã·ã¥ã¹ããããµãŒãã§ã¹ã®çæã«é¢é£ããè«å€§ãªã³ã¹ãïŒ13ïŒ ïŒã
- 巚倧ãªã³ã¹ãïŒ33ïŒ
ïŒã¯ãZãããã¡ãŒã®æ§ç¯ã«é¢é£ããŠã
- è¡ããšã®ç»åæ§ç¯ã¢ã«ãŽãªãºã ã®ã³ã¹ãã¯æããã§ãã
-
R_LeadingEdge
-
R_GenerateSpans
-
R_TrailingEdge
-
Intel VTuneã®ãããã¡ã€ãªã³ã°ïŒ
以äžãé¡èã§ãã
- 18ïŒ
ã®æéã¯ããœãããŠã§ã¢ã¬ã³ãã©ãŒã®æšæºçãªåé¡ãã€ãŸãã¬ã³ããªã³ã°ãããã€ã¡ãŒãžãRAMãããããªã¡ã¢ãªã«è»¢éããã³ã¹ãïŒ
BitBlit
ïŒã«è²»ããããŠããŸãã - æéã®34ïŒ
ã¯ããµãŒãã§ã¹ã®ã¬ã³ããªã³ã°ãšãã£ãã·ã¥ã«è²»ããããŠããŸãïŒ
D_DrawSurfaces
ïŒã - 8ïŒ
ã¯ããã¬ã€ã€ãŒ/æµãã¢ãã¡ãŒã·ã§ã³åããããã®LERPé ç¹å°çš
R_AliasPreparePoints
ã§ãïŒïŒã
ãããŠãVTuneã䜿çšããref_sof Quake2ã®ãã詳现ãªãããã¡ã€ãªã³ã°ã以äžã«ç€ºããŸãã
AMDã³ãŒãåæãããã¡ã€ãªã³ã°
ã³ã¢ã¯ãã¡ããref_sofã¯ãã¡ãã§ãã
ãã¯ã¹ãã£ãã£ã«ã¿ãªã³ã°
ãã¯ã¹ãã£ãã£ã«ã¿ãªã³ã°ãæ¹åããæ¹æ³ã«ã€ããŠå€ãã®è³ªåããããŸããïŒUnrealïŒãã©ãŒïŒã§äœ¿çšãããŠããã®ãšåæ§ã®ãã€ãªãã¢ãã£ã«ã¿ãªã³ã°ãŸãã¯ãã£ã¶ãªã³ã°ã«é²ã¿ãŸãïŒããã®åŽé¢ãè©ŠããŠã¿ããå Žåã¯ã以äžãæ€èš
D_DrawSpans16
ããŠ
ref_soft/r_scan.c
ãã ãã
ãç»é¢ã¹ããŒã¹ã®åæ座æšïŒXãYïŒã¯
pspan->u
ããã³
pspan->v
ã§ããã
spancount
ã©ã®ã¿ãŒã²ããç»é¢ãã¯ã»ã«ãçæãããããèšç®ããããã®ééå¹ ããããŸãã
ãã¯ã¹ãã£åº§æšã«é¢ããŠïŒ
s
ãš
t
ãã¯ã¹ãã£ãšå¢å ïŒããããïŒäžã®å ã®åº§æšã§INITIALIZE
sstep
ãš
tstep
ãã¯ã¹ãã£ãµã³ããªã³ã°ãå¶åŸ¡ããŸãã
äŸãã°ãSzilard Biroã¯ãUnreal Iãã£ã¶ãªã³ã°ãã¯ããã¯ã䜿çšããŠéåžžã«è¯ãçµæãåŸ
ãŸããããã£ã¶ãªã³ã°ã¬ã³ãã©ãŒã®ãœãŒã¹ã³ãŒãã¯ãgithubã®Quake2ã®ãã©ãŒã¯ã«ãããŸãããã£ã¶ãªã³ã°ãæå¹ã«ããã«ã¯ãcvar sw_texfiltã1ã«èšå®ããŸããUnreal1
ãœãããŠã§ã¢ã¬ã³ãã©ãŒããã®æåã®ãã£ã¶ãªã³ã°ïŒ
OpenGLã¬ã³ãã©ãŒ
Quake2ã¯ããã€ãã£ãã®ããŒããŠã§ã¢ã¢ã¯ã»ã©ã¬ãŒã·ã§ã³ã¬ã³ããªã³ã°ãµããŒãã§ãªãªãŒã¹ãããæåã®ãšã³ãžã³ã§ãã圌ã¯ããã¯ã¹ãã£ã®ãã€ãªãã¢ãã£ã«ã¿ãªã³ã°ããã«ããã¯ã¹ãã£ãªã³ã°ã®å¢å ãããã³24ãããã«ã©ãŒããã·ã³ã°ã«ããééãã®ãªãæ¹åã瀺ããŸããããŠãŒã¶ãŒã®èŠ³ç¹
ãããããŒããŠã§ã¢ã¢ã¯ã»ã©ã¬ãŒã·ã§ã³ããŒãžã§ã³ã¯æ¬¡ã®æ¹åãæäŸããŸããã
- ãã€ãªãã¢ãã£ã«ã¿ãªã³ã°
- ã«ã©ãŒç §æ
- é«è§£å床ã§30ïŒ é«ããã¬ãŒã ã¬ãŒã
ãžã§ã³ã»ãã¡ããæåã«è²ã®ã€ããç §æãèŠãæ¹æ³ã«ã€ããŠããã¹ã¿ãŒãºã»ãªãã»ãã¥ãŒã ããåŒçšãããããããŸãããtranslãïŒQuake 2ã®ä»äºãå§ããåã«ã圌ã¯ãã§ã«id Softwareãå»ããèªåã®äŒç€ŸIon StormãäœæããŠããŸãã]ïŒ
id [...].
, Quake II. , : ! , . , , . , . , Softdisk, Dangerous Dave in Copyright Infringement [. .: 1990 PC ] .
« », â . .
ãã®æ©èœã¯ã倧åã®éçºã«å€§ããªåœ±é¿ãäžããŸããã
以äžããã®ã³ãŒãã®èŠç¹ïŒããŒãžã®æåŸã»ã³ãããInsightsã®ã³ãŒããïŒã50ïŒ ä»¥äžã®ãœãããŠã§ã¢ã¬ã³ãã©ä»¥å€ã®ã¬ã³ãã©ãããã¯ãéçºè ãå¿ èŠãšããäœæ¥ãå°ãªãããšãæå³ããŸããããŸãããã®ãããªå®è£ ã¯ããœãããŠã§ã¢/ã¢ã»ã³ããªã«æé©åãããããŒãžã§ã³ãããã¯ããã«ã·ã³ãã«ã§ãšã¬ã¬ã³ãã§ããã
- Zãããã¡ãŒã«ãããã¢ã¯ãã£ããªããªãŽã³ã®ã¹ã¿ãã¯ãåãé€ãããšãã§ããŸããïŒãã®é«éZãããã¡ãŒãžã®äŸåã¯ãV2200çšã®VQuakeã®éçºæã«åé¡ãåŒãèµ·ãããŸããã
- Zãããã¡ã®RAMé床ãšçµã¿åãããã©ã¹ã¿ã©ã€ã¶ãããã®é«éåã«ããããŒãåæç»ã®ã¿ã¹ã¯ãäžèŠã«ãªããŸããã
- è¡ããšã®ã€ã¡ãŒãžæ§ç¯ã®çµã¿èŸŒã¿æé ã«ããããšããžã®ã°ããŒãã«ããŒãã«ãšã¢ã¯ãã£ããšããžã®ããŒãã«ãäžèŠã«ãªããŸããã
- ç §æã«ãŒãã¯ãããªããã»ããµïŒããã³ã°ã¬ãŒã¹ã±ãŒã«ã®ä»£ããã«RGBïŒã§ãã£ã«ã¿ãŒåŠçãããŸããããããã®èšç®ã¯CPUã«ã¯ãŸã£ããå ¥ããŸããã§ããã
æçµçã«ãOpenGLã¬ã³ãã©ãŒã¯ã¬ã³ãã©ãŒãšããããããªãœãŒã¹ãããŒãžã£ãŒã§ããé ç¹ãæž¡ããç §æãããã®ã¢ãã©ã¹ããã®å Žã§ããŒããããã¯ã¹ãã£ç¶æ ãå²ãåœãŠãŸãã
èå³æ·±ãäºå®ïŒ Quake2ãã¬ãŒã ã«ã¯éåžž600ã900ã®ããªãŽã³ãå«ãŸããŠããŸããããã¯ãçŸä»£ã®ãšã³ãžã³ã®äœçŸäžãã®ããªãŽã³ãšã®é¡èãªéãã§ãã
ã°ããŒãã«ã³ãŒãã¢ãŒããã¯ãã£
ã¬ã³ããªã³ã°ãã§ãŒãºã¯éåžžã«åçŽã§ããããœãããŠã§ã¢ã¬ã³ããªã³ã°ãšã»ãšãã©åãã§ããããã詳现ã«æ€èšããŸããã
R_RenderView { R_PushDlights // , R_SetupFrame R_SetFrustum R_SetupGL // GL_MODELVIEW GL_PROJECTION R_MarkLeaves // PVS R_DrawWorld // , BoundingBox { } R_DrawEntitiesOnList // R_RenderDlights // R_DrawParticles // R_DrawAlphaSurfaces // - R_Flash // ( ....) }
ãã¹ãŠã®ã¹ããŒãžããããªã«æ確ã«ç€ºãããŠããããšã³ãžã³ããã¹ããŒããŠã³ããããŠããŸãã
èŠèŠåã®é åºïŒ
- äžçã
- ãšã³ãã£ãã£ïŒQuake2ã§ã¯ããšã€ãªã¢ã¹ããšåŒã°ããŸãïŒã
- ç²åã
- åéæã®è¡šé¢ã
- ãã«ã¹ã¯ãªãŒã³ãã¹ããšãã§ã¯ãã
ã³ãŒãã®äž»ãªè€éãã¯ããããªã«ãŒãããã«ããã¯ã¹ãã£ãªã³ã°ããµããŒãããŠãããã©ãããããã³ã°ã«ãŒãé ç¹ã¬ã³ããªã³ã°ãæå¹ã«ãªã£ãŠãããã©ããã«ãã£ãŠç°ãªããã¹ããçºçããŸããäŸãã°ããã«ããã¯ã¹ãã£ãªã³ã°ããµããŒããããŠããå Žåã
DrawTextureChains
ããã³ã¯ã
R_BlendLightmaps
以äžã®ã³ãŒãã§äœãããŠããããã³ãŒããèªããšãã ãæ··ä¹±ããŸãïŒ
R_DrawWorld { // , 100% () R_RecursiveWorldNode // , { // PVS BBox/ // ! // : GL_RenderLightmappedPoly { if ( is_dynamic ) { } else { } } } // ( ) DrawTextureChains // , bindTexture. { for ( i = 0, image=gltextures ; i<numgltextures ; i++,image++) for ( ; s ; s=s->texturechain) R_RenderBrushPoly (s) { } } // ( : ) R_BlendLightmaps { // // if ( gl_dynamic->value ) { LM_InitBlock GL_Bind for ( surf = gl_lms.lightmap_surfaces[0]; surf != 0; surf = surf->lightmapchain ) { // . , , } } } R_DrawSkyBox R_DrawTriangleOutlines }
äžçã®å¯èŠå
ã¬ãã«ã¬ã³ããªã³ã°ã¯ã§è¡ãã
R_DrawWorld
ãŸããé ç¹ã«ã¯5ã€ã®å±æ§ããããŸãã
- äœçœ®ã
- ã«ã©ãŒãã¯ã¹ãã£ã®èå¥åã
- ã«ã©ãŒãã¯ã¹ãã£ã®åº§æšã
- éçç §æãããã®ãã¯ã¹ãã£èå¥åã
- éçãªç §æãããã®ãã¯ã¹ãã£ã®åº§æšã
OpenGLã¬ã³ãã©ãŒã«ã¯ãè¡šé¢ãã¯ãããŸãããè²ãšç §æãããã¯ãªã³ã¶ãã©ã€ã§çµåããããã£ãã·ã¥ãããããšã¯ãããŸããããããªã«ãŒãããã«ããã¯ã¹ãã£ãªã³ã°ããµããŒãããŠããå Žåãå¿ èŠãªãã¹ã¯1ã€ã ãã§ããã¯ã¹ãã£ã®èå¥åãšãã®åº§æšã瀺ããŸãã
- ã«ã©ãŒãã¯ã¹ãã£ã¯OpenGL GL_TEXTURE0ç¶æ ã«ãã€ã³ãããŸãã
- ã©ã€ããããã®ãã¯ã¹ãã£ã¯ãOpenGL GL_TEXTURE1ç¶æ ã«ããããããŸãã
- ã«ã©ãŒãã¯ã¹ãã£ã®åº§æšãšã©ã€ãã£ã³ã°ãããã®ãã¯ã¹ãã£ã®ããŒã¯ãéä¿¡ãããŸãã
ãããªã«ãŒãããã«ããã¯ã¹ãã£ãªã³ã°ããµããŒãããŠããªãå Žåã2ã€ã®ãã¹ãå®è¡ãããŸãã
- ããã·ã³ã°ã¯ãªãã«ãªããŸãã
- ã«ã©ãŒãã¯ã¹ãã£ã¯OpenGL GL_TEXTURE0ç¶æ ã«ãã€ã³ãããŸãã
- é ç¹ã¯ãã«ã©ãŒãã¯ã¹ãã£ã®åº§æšãšãšãã«éä¿¡ãããŸãã
- ããã·ã³ã°ã¯ãªã³ã§ãã
- ã©ã€ããããã®ãã¯ã¹ãã£ã¯ãOpenGL GL_TEXTURE0ç¶æ ã«ããããããŸãã
- ç §æãããã®ãã¯ã¹ãã£ã®åº§æšãæã€ããŒã¯ãéä¿¡ãããŸãã
ãã¯ã¹ãã£ç®¡ç
ãã¹ãŠã®ã©ã¹ã¿ã©ã€ãºã¯ãããªããã»ããµã§å®è¡ããããããã¬ãã«ã®éå§æã«ããã¹ãŠã®ãã¯ã¹ãã£ããããªã¡ã¢ãªã«ããŒãããå¿ èŠããããŸãã
- ã«ã©ãŒãã¯ã¹ãã£
- äºåã«èšç®ãããã©ã€ãããããã¯ã¹ãã£
OpenGLãããã¬gDEBuggerã䜿çšãããšããããªããã»ããµã®ã¡ã¢ãªãç°¡åã«æãäžããŠçµ±èšæ å ±ãååŸ
ã§ããŸããã芧ã®ãšãããåã«ã©ãŒãã¯ã¹ãã£ã«ã¯ç¬èªã®ãã¯ã¹ãã£èå¥åïŒtextureIDïŒããããŸããéçã©ã€ããããã¯ã次ã®ããã«ãã¯ã¹ãã£ã¢ãã©ã¹ïŒquake2ã§ã¯ããããã¯ããšåŒã°ããŸãïŒãšããŠããŒããããŸãã
ã©ã€ããããããã¯ã¹ãã£ã¢ãã©ã¹ã«ã¢ã»ã³ãã«ãããŠããå Žåãã«ã©ãŒãã¯ã¹ãã£ãå¥ã®ãã¯ã¹ãã£ã«ããã®ã¯ãªãã§ããïŒ
çç±ã®åãã¯ã¹ãã£ãã§ãŒã³ã®æé©åïŒ
ããªãããããªã§äœæ¥ããå Žåãããªãã®çç£æ§ãåäžãããå Žåã¯ã圌ã¯ã§ããã ã圌ã®ç¶æ ãå€æŽããããšã®ããã«åªåããå¿ èŠããããŸããããã¯ããã¯ã¹ãã£ãã€ã³ãã£ã³ã°ïŒ
glBindTexture
ïŒã«ç¹ã«åœãŠã¯ãŸããŸããæªãäŸã¯æ¬¡ã®ãšããã§ãã
for(i=0 ; i < polys.num ; i++) { glBindTexture(polys[i].textureColorID , GL_TEXTURE0); glBindTexture(polys[i].textureLightMapID , GL_TEXTURE1); RenderPoly(polys[i].vertices); }
åããªãŽã³ã«ã«ã©ãŒãã¯ã¹ãã£ãšã©ã€ããããã®ãã¯ã¹ãã£ãããå Žåãã»ãšãã©å®è¡ã§ããŸããããQuake2ã¯ã¢ãã©ã¹ã§ã©ã€ãããããåéããŸããããã¯èå¥åã§ç°¡åã«ã°ã«ãŒãåã§ããŸãããããã£ãŠãããªãŽã³ã¯BSPããè¿ãããé åºã§ã¬ã³ããªã³ã°ãããŸããã代ããã«ããããã¯ãããããè¡šããã¯ã¹ãã£ãããã®ã¢ãã©ã¹ã«åºã¥ããŠããã¯ã¹ãã£ã®ãã§ãŒã³ã«ã°ã«ãŒãåãããŸãã
glBindTexture(polys[textureChain[0]].textureLightMapID , GL_TEXTURE1); for(i=0 ; i < textureChain.num ; i++) { glBindTexture(polys[textureChain[i]].textureColorID , GL_TEXTURE0); RenderPoly(polys[textureChain[i]].vertices); }
以äžã®ãããªã¯ãããã¯ã¹ãã£ãã§ãŒã³ãã®èŠèŠåããã»ã¹ã瀺ããŠããŸããããªãŽã³ã¯ãè·é¢ã§ã¯ãªããé¢é£ããã©ã€ãã£ã³ã°ãããã®ãããã¯ã«åºã¥ããŠã¬ã³ããªã³ã°ãããŸãã
泚ïŒäžå®ã®åéææ§ãå®çŸããããã«ãå®å šã«äžéæãªããªãŽã³ã®ã¿ããã¯ã¹ãã£ãã§ãŒã³ã«åé¡ãããåéæã®ããªãŽã³ã¯åŒãç¶ãåé¢ããèé¢ã«ã¬ã³ããªã³ã°ãããŸãã
ãã€ãããã¯ã©ã€ãã£ã³ã°
èŠèŠåãã§ãŒãºã®æåã®æ®µéã§ããã¹ãŠã®ããªãŽã³ã«ããŒã¯ãä»ããããåçãªç §æã®åœ±é¿ãåããŠããããšã瀺ãã
R_PushDlights
ãŸãïŒïŒããããã£ãŠãäºåã«èšç®ãããéçç §æãããã¯äœ¿çšãããŸããã代ããã«ãéçãªç §æããããšããªãŽã³ãã¬ãŒã³ã«æ圱ãããå ã®è¿œå ïŒ
R_BuildLightMap
ïŒãçµã¿åãããæ°ããç §æããããçæãããŸãã
ã©ã€ãã£ã³ã°ãããã®æ倧ãµã€ãºã¯17x17ã§ããããããã€ãããã¯ã©ã€ãã£ã³ã°ãããã®çæãã§ãŒãºã¯ããã»ã©é«äŸ¡ã§ã¯ãããŸããããããã䜿çšããŠãããªããã»ããµã«å€æŽãããŠã³ããŒãããã®ã¯
qglTexSubImage2D
éåžžã«é ãã§ãã
ãã¹ãŠã®åçãªç §æããããä¿åããããã«ããµã€ãº128x128ã®ç §æãããã®ãããã¯ã䜿çšãããŸãããã®IDã¯1024ã§ãããã¯ã¹ãã£ã¢ãã©ã¹ã§ãã¹ãŠã®ãã€ãããã¯ã©ã€ãã£ã³ã°ãããããã®å Žã§çµã¿åãããæ¹æ³ã®èª¬æã«ã€ããŠã¯ããã©ã€ãã£ã³ã°ãããã®ç®¡çããåç §ããŠãã ããã
1.åçç §æãŠãããã®åæç¶æ ã2.æåã®ãã¬ãŒã ã®åŸã3. 10ãã¬ãŒã åŸã
泚ïŒåçã©ã€ããããããã£ã±ãã®å Žåããããã¬ã³ããªã³ã°ãå®è¡ãããŸããããŒããŒã¯ãå²ãåœãŠãããã¹ããŒã¹ãã¯ãªã¢ããããã©ããã远跡ããåçã©ã€ããããã®çæãåéããŸãã
ç §æã«ãŒãã管çãã
åè¿°ããããã«ãOpenGLããŒãžã§ã³ã®ã¬ã³ãã©ãŒã«ã¯ãè¡šé¢ãã®æŠå¿µããããŸãããã©ã€ãããããšã«ã©ãŒãã¯ã¹ãã£ã¯ãªã³ã¶ãã©ã€ã§çµåããããã£ãã·ã¥ãããŸããã
éçç §æãããã¯ãããªã¡ã¢ãªã«èªã¿èŸŒãŸããŸãããRAMã«ä¿åãããŸããåçç §æãããªãŽã³ã«åœ±é¿ãäžããå Žåãéçç §æããããšããã«æ圱ãããå ãçµã¿åãããæ°ããç §æããããçæãããŸãã次ã«ããã€ãããã¯ã©ã€ãã£ã³ã°ããããtextureId = 1024ã«ããŒãããããã¯ã¹ãã£ãªã³ã°ã«äœ¿çšãããŸãã
ãã¯ã¹ãã£ã¢ãã©ã¹ã¯ãQuake2ã§ã¯ããããã¯ããšåŒã°ãã128x128ãã¯ã»ã«ã§æ§æããã3ã€ã®æ©èœã«ãã£ãŠå¶åŸ¡ãããŸãã
-
LM_InitBlock
ïŒãããã¯ã¡ã¢ãªæ¶è²»ã®è¿œè·¡ããªã»ããããŸãã -
LM_UploadBlock
ïŒãã¯ã¹ãã£ã³ã³ãã³ããããŠã³ããŒããŸãã¯æŽæ°ããŸãã -
LM_AllocBlock
ïŒç §æããããä¿åããã®ã«é©ããå ŽæãèŠã€ããŸãã
以äžã®ãããªã¯ãç §æãããããããã¯ã§ã©ã®ããã«æ¥ç¶ãããŠãããã瀺ããŠããŸããããã§ããšã³ãžã³ã¯ãããªã¹ãåçããŸããå·Šããå³ã«ã¹ãã£ã³ããç §æããããç»åã®æé«åº§æšã®ã©ãã«å®å šã«åãŸãããèšæ¶ããŸãã
ã¢ã«ãŽãªãºã ã«æ³šæãæãå¿ èŠããããŸããããŒããŒïŒ
int gl_lms.allocated[BLOCK_WIDTH]
ïŒã¯ããã¯ã»ã«ã®ååãå ããé«ããå¹ å šäœã«æ²¿ã£ãŠè¿œè·¡ããŸãã
// "best" "bestHeight" // "best2" "tentativeHeight" static qboolean LM_AllocBlock (int w, int h, int *x, int *y) { int i, j; int best, best2; //FCS: best = BLOCK_HEIGHT; for (i=0 ; i<BLOCK_WIDTH-w ; i++) { best2 = 0; for (j=0 ; j<w ; j++) { if (gl_lms.allocated[i+j] >= best) break; if (gl_lms.allocated[i+j] > best2) best2 = gl_lms.allocated[i+j]; } if (j == w) { // *x = i; *y = best = best2; } } if (best + h > BLOCK_HEIGHT) return false; for (i=0 ; i<w ; i++) gl_lms.allocated[*x + i] = best + h; return true; }
泚ïŒãããŒããŒããã¶ã€ã³ãã¿ãŒã³ã¯éåžžã«ãšã¬ã¬ã³ãã§ããœãããŠã§ã¢ã¬ã³ãã©ãŒã®ãµãŒãã§ã¹ããã£ãã·ã¥ããããã®ã¡ã¢ãªã·ã¹ãã ã§ã䜿çšãããŸãã
ãã¯ã»ã«ãã£ã«ã¬ãŒããšã¬ã³ããªã³ã°ãã¹
次ã®ãããªãããããããã«ãåæç»ã¯éåžžã«éèŠã§ãã
ææªã®å Žåããã¯ã»ã«ã¯3ã4åäžæžããããŸãïŒåæç»ã¯ã«ãŠã³ããããŸããïŒã
- ã¯ãŒã«ãïŒ1-2ãã¹ïŒãã«ããã¯ã¹ãã£ãªã³ã°ã®ãµããŒãã«ããïŒã
- ç²åã®æ··åïŒ1ãã¹ã
- ãã¹ããšãã§ã¯ãã®ããã·ã³ã°ïŒ1ãã¹ã
GL_LINEAR
ãã€ãªãã¢ãã£ã«ã¿ãªã³ã°ã¯ã«ã©ãŒãã¯ã¹ãã£ã§ããŸãæ©èœããŸããããã©ã€ããããããã£ã«ã¿ãªã³ã°ãããšæ¬åœã«è±éããŸãã
ããã¯ïŒ
次ã®ããã«ãªããŸããïŒ
ãããŠä»ããã¹ãŠäžç·ã«ïŒ
1.ãã¯ã¹ãã£ïŒåç/éçç §æãããã
2.ãã¯ã¹ãã£ïŒè²ã
3.æ··åã®çµæïŒ1ã€ãŸãã¯2ã€ã®ãã¹ã
ãšã³ãã£ãã£ã®å¯èŠå
ãšã³ãã£ãã£ã¯ã°ã«ãŒãã§ã¬ã³ããªã³ã°ãããŸããé ç¹ããã¯ã¹ãã£åº§æšãããã³ã«ã©ãŒé åãã€ã³ã¿ãŒã¯ãã䜿çšããŠåéããéä¿¡ãã
glArrayElement
ãŸãã
ã¬ã³ããªã³ã°ã®åã«ãã¢ãã¡ãŒã·ã§ã³ãã¹ã ãŒãºã«ããããã«ããã¹ãŠã®ãšã³ãã£ãã£ã®é ç¹ã«å¯ŸããŠLERPãå®è¡ãããŸãïŒQuake1ã§ã¯ããŒãã¬ãŒã ã®ã¿ã䜿çšãããŸããïŒã
Gouroã®ç §æã¢ãã«ã䜿çšãããŸãïŒQuake2ã¯ãç §æå€ãæ ŒçŽããããã«è²ã®é åãã€ã³ã¿ãŒã»ããããŸããèŠèŠåã®åã«ãåé ç¹ã«ã€ããŠãç §æå€ãèšç®ãããè²ã®é åã«ä¿åãããŸãããã®é åã®å€ã¯ãããªããã»ããµã§è£éãããGouroã©ã€ãã£ã³ã°ã§è¯å¥œãªçµæãåŸãããŸãã
R_DrawEntitiesOnList { if (!r_drawentities->value) return; // for (i=0 ; i < r_newrefdef.num_entities ; i++) { R_DrawAliasModel { R_LightPoint /// GL_Bind(skin->texnum); // GL_DrawAliasFrameLerp() // { GL_LerpVerts // LERP // , colorArray for ( i = 0; i < paliashdr->num_xyz; i++ ) { } qglLockArraysEXT qglArrayElement // ! qglUnlockArraysEXT } } } // for (i=0 ; i < r_newrefdef.num_entities ; i++) { R_DrawAliasModel { [...] } } }
èé¢ã®ã¯ãªããã¯ãããªããã»ããµã§è¡ãããŸãïŒãŸãããã®æç¹ã§CPUã§ããã»ã¬ãŒã·ã§ã³ãšã©ã€ãã£ã³ã°ãè¡ãããŠããããããã©ã€ããŒã®æ®µéã§è¡ããããšèšããŸãïŒã
泚ïŒèšç®ãé«éåããããã«ãå ã®æ¹åã¯åžžã«åãïŒ
{-1, 0, 0}
ïŒã§ãããšæ³å®ãããŠããŸããããããã¯ãšã³ãžã³ã«ã¯åæ ãããŸãããç §æã®è²ã¯æ£ç¢ºã§ããšã³ãã£ãã£ã®ããŒã¹ãšãªã£ãŠããçŸåšã®ããªãŽã³ã«å¿ããŠéžæãããŸãã
ããã¯ãå æºã®å®çŸ©ãééã£ãŠããã«ãããããããå ãšåœ±ã®æ¹åãåãã§ããäžã®ã¹ã¯ãªãŒã³ã·ã§ããã§éåžžã«ã¯ã£ãããšèŠããŸãã
泚ïŒãã¡ããããã®ã·ã¹ãã ã¯å¿ ãããå®å šã§ã¯ãªãã圱ããã€ãã«æ圱ãããé¡ãäºãã«äžæžãããŠãããŸããŸãªã¬ãã«ã®åœ±ã«ãªããŸãããããã¯1997幎ã§ãéåžžã«å°è±¡çã§ãã
圱ã®è©³çŽ°ïŒ
å€ãã®äººã¯ãQuake2ããšã³ãã£ãã£ã®ããããã®åœ±ãèšç®ã§ããããšãç¥ããŸããããã®æ©èœã¯ããã©ã«ãã§ç¡å¹ã«ãªã£ãŠããŸãããã³ãã³ãã§æå¹ã«ã§ããŸã
gl_shadows 1
ã
圱ã¯åžžã«äžæ¹åã«åãããïŒæãè¿ãå æºã«äŸåããŸããïŒãé¢ã¯ãšã³ãã£ãã£ã¬ãã«ã®å¹³é¢ã«æ圱ãããŸãããã®ã³ãŒã
R_DrawAliasModel
ã¯ããšã³ãã£ãã£ã¬ãã«ã®å¹³é¢ã«é¢ãæ圱ããããã«
shadevector
䜿çšããããã¯ãã«ãçæã
GL_DrawAliasShadow
ãŸãã
ãšã³ãã£ãã£å¯èŠåç §æïŒãµã³ããªã³ã°ããªãã¯
ã¢ãã«å ã®ããªãŽã³ã®æ°ãå°ãªããããæ³ç·ãšã¹ã«ã©ãŒã®æ³ç·/å ã®ç©ããªã¢ã«ã¿ã€ã ã§èšç®ã§ãããšå€æã§ããŸãããããã§ã¯ãããŸããããã¹ãŠã®ã¹ã«ã©ãŒç©ã¯äºåã«èšç®ãã
float r_avertexnormal_dots[SHADEDOT_QUANT][256]
ãã«ä¿åãã
SHADEDOT_QUANT
ãŸããããã§= 16ã§ãã
é¢æ£åã䜿çšãããŸããå ã®æ¹åã¯åžžã«åãã§ãïŒ{-1,0,0}ã
Y軞ã«æ²¿ã£ãã¢ãã«ã®æ¹åã«å¿ããŠã16ã®ç°ãªãæ³ç·ã®1ã€ã®ã¿ãèšç®ãããŸã
.16ã®æ¹åã®ãããããéžæãããšã256ã®ç°ãªãæ³ç·ã®ã¹ã«ã©ãŒç©ãäºåã«èšç®ãããŸãã MD2ã¢ãã«åœ¢åŒã®æšæºã¯ãåžžã«äºåã«èšç®ãããé åã®ã€ã³ããã¯ã¹ã§ãã XãYãZæ³ç·ã®ä»»æã®çµã¿åããã¯ã256æ¹åã®ããããã«åé¡ãããŸãã
ããããã¹ãŠã®å¶éã®ããããã¹ãŠã®ã¹ã«ã©ãŒç©ã¯
r_avertexnormal_dots
16x256ãµã€ãºãæ³ç·ã€ã³ããã¯ã¹ã¯ã¢ãã¡ãŒã·ã§ã³äžã«è£éã§ããªããããããŒãã¬ãŒã ã«ã¯æãè¿ãæ³ç·ã€ã³ããã¯ã¹ã䜿çšãããŸãã
ããã«ã€ããŠã®è©³çŽ°ïŒhttp : //www.quake-1.com/docs/quakesrc.org/97.htmlïŒmirrorïŒã
å€ãè¯ãOpenGL ...
glGenTexturesã¯ã©ãã«ãããŸããïŒïŒïŒ
ä»æ¥ãopenGLéçºè ã¯ãä»ããŠãããªããã»ããµããtextureIDãèŠæ±ããŠã
glGenTextures
ãŸãã Quake2ã¯ãããæ°ã«ãããç¬èªã«èå¥åãéžæããŸããããããã£ãŠãã«ã©ãŒãã¯ã¹ãã£ã¯0ããå§ãŸããåçã©ã€ããããã®ãã¯ã¹ãã£ã¯åžžã«1024ã®èå¥åãæã¡ãéçã©ã€ããããã¯1025ãã1036ãŸã§ã§ããã
æªåé«ãã€ããã£ãšã€ãã¢ãŒãïŒ
é ç¹ããŒã¿ã¯ã€ããã£ãšãŒãã¢ãŒãã䜿çšããŠãããªã«ãŒãã«è»¢éãããŸãããããïŒãžã®2ã€ã®é¢æ°åŒã³åºã
glVertex3fv
ãš
glTexCoord2f
äžçã®ã¬ã³ããªã³ã°çšïŒïŒããªãŽã³ãåå¥ã«åæããŠãã°ã«ãŒãã«ããããéããããšãã§ããŸããã§ããïŒã
ã䜿çšããŠã¢ãã«ïŒæµããã¬ã€ã€ãŒïŒã®ã°ã«ãŒãã®èŠèŠåãå®è¡ããŸãã
glEnableClientState (GL_VERTEX_ARRAY)
ãéä¿¡ãããã¹
glVertexPointer
ãš
glColorPointer
CPUã«ãã£ãŠèšç®ãããç §æå€ãéä¿¡ããããã«äœ¿çšãããŸããã
ãã«ããã¯ã¹ãã£ãªã³ã°ïŒ
æ°ãããã¯ãããžããµããŒããã/ãµããŒãããªãæ©åšã«é©å¿ããããšãããããã³ãŒãã¯è€éã§ã...ãã«ããã¯ã¹ãã£ãªã³ã°ã
䜿çšããªã
GL_LIGHTING
ïŒ
ãã¹ãŠã®èšç®ã¯CPUïŒã¯ãŒã«ãã®ãã¯ã¹ãã£çæãšãšã³ãã£ãã£ã®é ç¹ã€ã«ãããŒã·ã§ã³ã®å€ïŒã§å®è¡ããããããã³ãŒãã«ã¯ãã¬ãŒã¹ããããŸãã
GL_LIGHTING
ã
OpenGL 1.0ã¯ãPhongã·ã§ãŒãã£ã³ã°ïŒæ³ç·ãå®éã®ããã¯ã»ã«åäœã®ã€ã«ãããŒã·ã§ã³ãã§è£éãããïŒã§ã¯ãªããGouraudã·ã§ãŒãã£ã³ã°ïŒé ç¹éã®è²ã®è£éïŒãå®è¡
GL_LIGHTING
ããããããã®å Žã§é ç¹ãäœæããå¿ èŠããããããäžçã§ã¯èŠãç®ãæªããªããŸãã
ãšã³ãã£ãã£ã«é©çšã§ããŸãããé ç¹æ³ç·ãã¯ãã«ãéä¿¡ããå¿ èŠããããŸããããã¯äžé©åãšæããããããã©ã€ãã£ã³ã°å€ã®èšç®ã¯CPUã§è¡ãããŸããç §æå€ã¯è²ã®é åããéä¿¡ãããå€ã¯CPUã«è£éãããŠã°ãŒããŒã·ã§ãŒãã£ã³ã°ãååŸããŸãã
ãã«ã¹ã¯ãªãŒã³ãã¹ããšãã§ã¯ã
ãã¬ããããŒã¹ã®ãœãããŠã§ã¢ã¬ã³ãã©ãŒã¯ãã«ãã¯ã¢ããããŒãã«ã䜿çšããŠããšã¬ã¬ã³ãã§å®å šãªãã¬ããã«ã©ãŒããã·ã³ã°ãšè¿œå ã®ã¬ã³ãè£æ£ãå®è¡ããŸãããããããOpenGLããŒãžã§ã³ã¯ãããå¿ èŠãšããŸãããããã¯ã次ã®ããã«ãŒããã©ãŒã¹ãã¡ãœããã®äŸã§èŠãããšãã§ããŸã
R_Flash
ïŒ
åé¡ïŒç»é¢ãããå°ãèµ€ãããå¿ èŠããããŸããïŒ
解決çïŒç»é¢å šäœã«ãã¢ã«ãã¡ãã£ãã«ããã·ã³ã°ããªã³ã«ããŠå·šå€§ãªèµ€ãé·æ¹åœ¢GL_QUADãæç»ããã ãã§ããã§ãã
泚ïŒãµãŒããŒã¯ããœãããŠã§ã¢ã¬ã³ãã©ãŒãšåãæ¹æ³ã§ã¯ã©ã€ã¢ã³ããå¶åŸ¡ããŸããããµãŒããŒããã¹ããšãã§ã¯ãã®ããã«ãã«ã¹ã¯ãªãŒã³ã«ã©ãŒããã·ã³ã°ãå®è¡ããå¿ èŠãããå Žåã¯ãåã«
float player_state_t.blend[4]
RGBA å€æ°ã«å€ãå²ãåœãŠãŸãããå€æ°ã®å€ã¯ããããã¯ãŒã¯ãä»ããŠquake2ã³ã¢ã®ãããã§éä¿¡ãããã¬ã³ãã©ãŒDLLã«éä¿¡ãããŸããã
ãããã¡ã€ãªã³ã°
Visual Studio 2008 Teamãããã¡ã€ã©ãŒã¯çŽ æŽãããã§ãããããOpenGL Quake2ã§å€æããããšã§ããåœç¶ã§ã
ãã»ãšãã©ã®æéã¯OpenGLãã©ã€ããŒNVidiaãšWin32ïŒ
nvoglv32.dll
ããã³
opengl32.dll
ïŒã«è²»ããããŠãããçŽ30ïŒ ãããããŸãããèŠèŠåã¯ãããªããã»ããµã§å®è¡ãããŸãããRAMãããããªã¡ã¢ãªãžã®ããŒã¿ã®ã³ããŒã ãã§ãªããã€ããã£ãšã€ãã¢ãŒãã¡ãœããã®è€æ°ã®åŒã³åºãã«å€ãã®æéãè²»ããããŸãã
次ã¯ã¬ã³ãã©ãŒã¢ãžã¥ãŒã«ïŒ
ref_gl.dll
23ïŒ ïŒãšquake2ã³ã¢ïŒ
quake2.exe
15ïŒ ïŒã§ãã
ãšã³ãžã³ã¯ç©æ¥µçã«mallocã䜿çšããŸãããã»ãšãã©æéãè²»ãããªãããšãããããŸãïŒ
MSVCR90D.dll
ããã³
msvcrt.dll
ïŒããŸããã²ãŒã ããžãã¯ïŒ
gamex86.dll
ïŒã«è²»ããããæéã¯éèŠã§ã¯ãããŸããã
directXïŒ
dsound.dll
ïŒãµãŠã³ãã©ã€ãã©ãªã§äºæ³å€ã®æéãç¡é§ã«ãªããŸãïŒåèšæéã®12ïŒ ã
OpenGL Quake2 dllã¬ã³ãã©ãŒã詳ããèŠãŠã¿ãŸãããã
- ã»ãšãã©ã®æéã¯äžçã®ã¬ã³ããªã³ã°ã«è²»ããããŠããŸãïŒ
R_RecurseiveWorldNode
ïŒã - ã»ãŒåãé-æµïŒãšã€ãªã¢ã¹ã¢ãã«ïŒã®ã¬ã³ããªã³ã°ïŒïŒ
GL_DrawAliasFrameLerp
2.5ïŒ ïŒãã¹ã«ã©ãŒç©ãäºåã«èšç®ããããšããäºå®ã«ãããããããã³ã¹ãã¯éåžžã«é«ããªããŸãã - ç
§æãããã®çæïŒåçç
§æã§ã¯ã以åã«èšç®ãããéçç
§æãããã®äœ¿çšãèš±å¯ãããŠããªãå ŽåïŒããæéã®2.5ïŒ
ãèŠããŸãïŒ
GL_RenderLightMappedPoly
ïŒã
å šäœãšããŠãOpenGL dllã¯ãã©ã³ã¹ããããæãããªããã«ããã¯ã¯ãããŸããã
ã³ãŒãçµ±èš
Clocã³ãŒããåæãããšãåèš7,265è¡ã®ã³ãŒããããããšãããããŸãã
$ cloc ref_gl 17 text files. 17 unique files. 1 file ignored. http://cloc.sourceforge.net v 1.53 T=1.0 s (16.0 files/s, 10602.0 lines/s) ------------------------------------------------------------------------------- Language files blank comment code ------------------------------------------------------------------------------- C 9 1522 1403 6201 C/C++ Header 6 237 175 1062 Teamcenter def 1 0 0 2 ------------------------------------------------------------------------------- SUM: 16 1759 1578 7265 -------------------------------------------------------------------------------
ãœãããŠã§ã¢ã¬ã³ãã©ãŒãšæ¯èŒãããšãéãã¯é¡èã§ããã¢ã»ã³ãã©ãŒã®æé©åãªãã§ã³ãŒãã50ïŒ æžå°ããŸãããé床ã¯30ïŒ é«ããªããã«ã©ãŒç §æãšãã€ãªãã¢ãã£ã«ã¿ãªã³ã°ããããŸããid SoftwareãQuake3ã®ãœãããŠã§ã¢ã¬ã³ãã©ãŒãæ°ã«ããªãã£ãçç±ã¯ç°¡åã«ããããŸãã