@ 2004-06-16 @
1 ±âŸ #
¢¹ ƯÁ¤ °ÔÀÓ¿¡¼ ÇÑ±Û ÀÔ·ÂÀÇ ¹®Á¦
-. Windows 7 (64 ºñÆ®) ¼³Ä¡½Ã ¼³Á¤µÈ 'Microsoft office IME 2007'¿¡¼ ¹®Á¦°¡ ¹ß»ýÇÏÁö ¾ÊÀ½
#define DEG2RAD 0.01745f-. º°µµ·Î ¹Þ¾Æ¼ ¼³Ä¡ÇÑ 'ÇѱÛÀԷ½ýºÅÛ(MS-IME2002)'¿¡¼´Â ÇÑ/¿µ º¯È¯Å°°¡ ÀÛµ¿ÇÏÁö ¾Ê°í, ÇѱÛÀÌ ÀԷµÇÁö ¾Ê´Â Çö»ó ¹ß°ß #pragma once
//-----------------------------------------------------------------------------
// Miscellaneous helper functions //----------------------------------------------------------------------------- #define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } } #define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } } #define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
//-----------------------------------------------------------------------------
// General purpose utilities //----------------------------------------------------------------------------- d3dx9math.h #define D3DX_PI ((float) 3.141592654f) #define D3DX_1BYPI ((float) 0.318309886f)
#define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f))
#define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI))
* D3DXCreateTextureFromFileEx() µîÀÇ ÇÔ¼ö¸¦ »ç¿ëÇÒ¶§
FormatÀ» D3DFMT_UNKNOWN À¸·Î ÁöÁ¤ÇÏ¸é ·Îµù ¼Óµµ°¡ ´À·ÁÁö´Â °æ¿ìµµ ÀÖ´Ù.
* D3D ¸ÅÅ©·Î ÀÌ¿ë
/// ´ÜÃàÇü ¸ÅÅ©·Î
* BOOL Á¤ÀÇ#define RS m_pd3dDevice->SetRenderState #define TSS m_pd3dDevice->SetTextureStageState #define SAMP m_pd3dDevice->SetSamplerState /// ·»´õ¸µ »óÅ ¼³Á¤ RS( D3DRS_DITHERENABLE, FALSE ); RS( D3DRS_SPECULARENABLE, FALSE ); RS( D3DRS_ZENABLE, TRUE ); RS( D3DRS_AMBIENT, 0x000F0F0F ); /// ÅؽºÃ³¿¡ °üÇÑ ¼³Á¤ TSS( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); TSS( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); TSS( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
// Standard constants
* ·»´õ¸µ »óÅ°ª Á¶Á¤
#define FALSE 0
// Success codes#define TRUE 1 #define NULL 0
#define S_OK ((HRESULT)0x00000000L)
#define S_FALSE ((HRESULT)0x00000001L)
Device->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_GOURAUD );
* ÇÔ¼ö...Device->SetRenderState( D3DRS_SPECULARENABLE, true ); // µðÆúÆ®´Â ²¨Á®ÀÖÀ½ Device->SetRenderState( D3DRS_NORMALIZENORMALS, true ); // ³ë¸»°ªÀÌ ¿Ö°îµÇ´Â Çö»óÀ» ¹æÁöÇϱâ À§ÇØ, Direct3D°¡ ¸ðµç ³ë¸»°ªÀ» ´Ù½Ã Á¤¸®Çϵµ·Ï ÇÑ´Ù.
#.D3DXPlaneFromPoints(D3DXPLANE * pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3);
¼¼ Á¡À¸·ÎºÎÅÍ Æò¸éÀÇ ¹æÁ¤½ÄÀ» ±¸ÇÏ´Â ÇÔ¼ö
#.D3DXVec3TransformCoord ÇÔ¼ö; ÁöÁ¤µÈ Çà·Ä¿¡ ÀÇÇØ 3D º¤Å͸¦ º¯È¯ ÇØ, ±× °á°ú¸¦ w = 1 ¿¡ Åõ¿µ ÇÑ´Ù.
pOut - ¿¬»ê °á°úÀÎ D3DXVECTOR3 ±¸Á¶Ã¼ÀÇ Æ÷ÀÎÅÍ.
#.D3DXVec3Transform ÇÔ¼ö; ÁöÁ¤µÈ Çà·Ä¿¡ ÀÇÇØ º¤ÅÍ (x, y, z, 1)¸¦ º¯È¯ ÇÑ´Ù. pV - ó¸®ÀÇ ±âº»À¸·Î µÇ´Â D3DXVECTOR3 ±¸Á¶Ã¼ÀÇ Æ÷ÀÎÅÍ.
pOut - ¿¬»ê °á°úÀÎ D3DXVECTOR4 ±¸Á¶Ã¼ÀÇ Æ÷ÀÎÅÍ.
#.D3DXVec4Transform ÇÔ¼ö; ÁöÁ¤µÈ Çà·Ä¿¡ ÀÇÇØ 4D º¤Å͸¦ º¯È¯ ÇÑ´Ù. pV - ó¸®ÀÇ ±âº»À¸·Î µÇ´Â D3DXVECTOR3 ±¸Á¶Ã¼ÀÇ Æ÷ÀÎÅÍ. 2 DirectX #¢¹ D3DXMatrixRotationYawPitchRoll ÇÔ¼ö´Â ȸÀüÀ¸·Î Çà·ÄÀ» ¸¸µé ¶§,
Roll (Z) * Pitch(X) * Yaw(Y) ¼ø¼·Î °è»ê
¢¹ ¿À¸¥¼Õ ÁÂÇ¥°è¿¡¼´Â
Yaw´Â ZÃà¿¡ ´ëÇÑ ¹Ý½Ã°è¹æÇâ ȸÀü
¢¹ SetRenderState( D3DRS_DEPTHBIAS , value ); Pitch´Â YÃà¿¡ ´ëÇÑ ¹Ý½Ã°è¹æÇâ ȸÀü RollÀº XÃà¿¡ ´ëÇÑ ¹Ý½Ã°è¹æÇâ ȸÀü °í·Î, Z * Y * X ¼øÀ¸·Î °öÇÏ¿© ȸÀü Çà·Ä½ÄÀ» ¸¸µç´Ù.
DEPTHBIAS(z-bias)´Â °°Àº ±íÀÌ¿¡ ÀÖ´Â µÎ Æú¸®°ï »çÀÌ¿¡¼ ÀϾ´Â Z-fightingÀ» ¸·±âÀ§ÇØ
ÀÎÀ§ÀûÀ¸·Î DEPTH(z)°ªÀ» Á¶Á¤ÇØÁÖ´Â ¼öÄ¡·Î,
ÁöÇü±×¸±¶§ 0°ªÀ» ¼ÂÆÃÇÏ°í µ¥Ä® ±×¸±¶§ 1·Î ¼ÂÆÃÇؼ ÀÎÀ§ÀûÀ¸·Î °ãÄ¡´Â ºÎºÐÀÌ ÁöÀúºÐÇØ Áö´Â °ÍÀ» ¹æÁöÇÑ´Ù. 2.1 ¿ùµåÁÂÇ¥°èÀÇ ÇÁ·¯½ºÅÒ(Frustum) ÁÂÇ¥ ±¸Çϱâ #1.·»´õ¸µ ÆÄÀÌÇÁ¶óÀÎÀ» Åë°úÇÏ´Â ÃÖÁ¾ ¹öÅؽºÀÇ º¯È¯Àº
Vertex_end = Vertex_local * Matrix_world * Matrix_view * Matrix_Proj ÀÌ´Ù.
2.±¸ÇÏ°íÀÚ ÇÏ´Â ÃÖÁ¾°á°ú°¡ Vertex_world À̹ǷÎ
¡ñ Vertex_world = Vertex_local * Matrix_world
Vertex_end = Vertex_world * Matrix_view * Matrix_Proj
¡ñ Matrix_ViewProj = Matrix_view * Matrix_Proj
Vertex_end = Vertex_world * Matrix_ViewProj
Vertex_world = Vertex_end * Matrix_ViewProj^-1(Matrix_view * Matrix_ProjÀÇ ¿ªÇà·Ä)
3.ÀýµÎü(Frustum)ÀÇ Vertex_end°ªÀº (-1,-1,0) ~ (1,1,1)»çÀÌÀÇ °ªÀÓÀ¸·Î
D3DXMATRIXA16 MatrixViewProj = Matrix_view * Matrix_Proj;
D3DXMATRIXA16 MatrixViewProj_Inv = D3DXMatrixInverse(&MatrixViewProj_Inv, NULL, MatrixViewProj); ÀýµÎüÀÇ Vertex_world = D3DXVec3TransformCoord( &Vertex_world, &Vertex_end, &MatrixViewProj_Inv); 2.2 VS2005, DirectX SDK »ç¿ëÀ» À§ÇÑ ¼³Á¤ #Microsoft DirectX SDK (February 2007)À» ¼³Ä¡Çϸé ȯ°æº¯¼ö¿¡ ´ÙÀ½ Ç׸ñÀÌ Ãß°¡µÈ´Ù.(¹æ¹ý 1) Visual Studeo 2005ÀÇ VC++¿¡ ´ëÇؼ ¼³Á¤Çϱâ 1. Tools | Options ´ÙÀ̾ó·Î±× âÀ» ¿¬´Ù. 2. Projects and Solutions | VC++ Directories | Win32, Include files¿¡ ´ÙÀ½ Ç׸ñÀ» Ãß°¡ÇÑ´Ù.
$(DXSDK_DIR)include
3. Projects and Solutions | VC++ Directories | Win32, Library files¿¡ ´ÙÀ½ Ç׸ñÀ» Ãß°¡ÇÑ´Ù.
$(DXSDK_DIR)lib\x86 or $(DXSDK_DIR)lib\x64
(¹æ¹ý 2) Projectº°·Î ¼³Á¤Çϱâ1. Project¸¦ ¼±ÅÃÇÏ°í ¿ìÃø ¸¶¿ì½º ¹öÆ°À» Ŭ¸¯ÇÑ ÈÄ Properties ´ÙÀ̾ó·Î±× âÀ» ¿¬´Ù. 2. C/C++ | General | Additional Include Directories¿¡ ´ÙÀ½ Ç׸ñÀ» Ãß°¡ÇÑ´Ù.
$(DXSDK_DIR)include
3. Linker | General | Additional Library Directories¿¡ ´ÙÀ½ Ç׸ñÀ» Ãß°¡ÇÑ´Ù.
$(DXSDK_DIR)lib\x86 or $(DXSDK_DIR)lib\x64
(ÁÖÀÇ) release¿Í debug¿¡ ´ëÇØ ¸ðµÎ ÇØ ÁÖ¾î¾ß ÇÑ´Ù.2.3 DirectX ¹öÀüº° dll #
3 ¸Þ¸ð¸® °ü·Ã #3.1 AGP ¸Þ¸ð¸®¿Í ºñµð¿À ¸Þ¸ð¸® #1.AGP(Accelerated Graphics Port)1-1.»ç¿ëÀÚ´Â CMOS¿¡¼ AGP Apecture »çÀÌÁ Á÷Á¢ ÁöÁ¤ÇÒ ¼ö°¡ Àִµ¥, ¸¸¾à ÀÚ½ÅÀÇ Àüü ·¥ÀÌ 512MB¶ó¸é 128MB~256MB Á¤µµ·Î ¼³Á¤ÇÏ°í 256MB¶ó¸é 64~128MB·Î ¼³Á¤Çؼ »ç¿ëÇÏ±æ ¹Ù¶õ´Ù(AGP »çÀÌÁ Å©°Ô ÇÒ¼ö·Ï ¸¹Àº ¸®¼Ò½º¸¦ »ç¿ëÇÏ´Â 3D °ÔÀÓµéÀÌ ¿øÈ°ÇÏ°Ô µ¹¾Æ°£´Ù). ÀÌó·³ AGP ¸Þ¸ð¸®¶ó°í Çؼ µû·Î ÀÖ´Â °ÍÀÌ ¾Æ´Ï¶ó ±×³É ÀÏ¹Ý ·¥Àε¥ Ưº°È÷ ¿µ¿ªÀ» ÁöÁ¤ÇØÁÖ´Â °ÍÀÌ´Ù. 1-2. ´ÜÁö OS°¡ AGP ¸Þ¸ð¸®¸¦ Ưº°ÇÏ°Ô Ã³¸®Çϴµ¥ ¼Óµµ¸¦ À§Çؼ Ưº°È÷ Àß °ü¿©ÇÏÁö ¾Ê´Â´Ù°í º¸¸é µÈ´Ù. OS´Â ¾ÈÁ¤¼ºÀÌ ¿ì¼±À̱⠶§¹®¿¡ ÀÏ¹Ý ¸Þ¸ð¸®ÀÇ °æ¿ì ÆäÀÌ¡ 󸮺ÎÅÍ °¡»ó¸Þ¸ð¸® ó¸® ¹× OS ÅëÁ¦°¡ ½ÉÇÏÁö¸¸ AGP´Â 3D Ä«µå°¡ Á÷Á¢ ÀÐÀ» ¼ö ÀÖµµ·Ï CPU°¡ »¡¸® ¾µ ¼ö ÀÖµµ·Ï ¼³°èµÇ¾î ÀÖ´Ù. 1-3. AGPÀÇ Æ¯¼º
• CPU°¡ ÀдÂ(Read) ¼Óµµ´Â ¸Å¿ì ´À¸®°í ¾²´Â °ÍÀº ºü¸£´Ù.
ÀÌ¿Í °°Àº Ư¼ºÀ¸·Î ÀÎÇØ Ãæµ¹°Ë»ç¸¦ ÇÑ´Ù°í ¹öÅؽº ¹öÆÛ¿¡ ¶ô(Lock)À» °É¾î¼ Àд´ٰųª ÇÏ´Â °æ¿ì°¡ ¾ø¾î¾ß ÇÒ °ÍÀÌ´Ù(¹öÅؽº Á¤º¸¸¦ ½Ã½ºÅÛ ¸Þ¸ð¸®¿¡ °°ÀÌ °¡Áö°í Àֵ簡 ÇØ¾ß µÈ´Ù).• 3D Ä«µå¿¡¼ ½Ã½ºÅÛ ¸Þ¸ð¸®¸¦ Àд °ÍÀº ¸Å¿ì ´À¸®°í AGP ¸Þ¸ð¸®¸¦ Àд °ÍÀÌ ÈξÀ ºü¸£´Ù. • »ç½Ç»ó ¹°¸®Àû(Physical) ¸Þ¸ð¸®¿¡ ÀâÈù´Ù. ¹°¸®Àû ¸Þ¸ð¸®¿¡ ÀâÈù´Ù´Â °ÍÀº ¼Óµµ»ó ¸¹Àº À̵æÀÌ ÀÖ´Ù. • AGP ¸Þ¸ð¸®´Â OS°¡ °ü¸®ÇØ Áֱ⠶§¹®¿¡ ¸¹Àº ¾çÀÇ ¸Þ¸ð¸®¸¦ »ç¿ëÇÏ´õ¶óµµ ±× ÀÌ»óÀÇ ¸Þ¸ð¸®¸¦ ¼ö¿ëÇÒ ¼ö°¡ ÀÖ´Ù. ´Ù¸¸ ¿ë·®ÀÇ ÇÑ°è¿¡ µµ´ÞÇßÀ» ¶§ ½Ã½ºÅÛ ¸Þ¸ð¸®¿Í AGP ¸Þ¸ð¸®°£ÀÇ Àü¼ÛÀÌ ÀϾ ȸéÀÇ ²÷±è Çö»óÀÌ »ý±â°Ô µÈ´Ù.
2. ºñµð¿À ¸Þ¸ð¸® = AGP ¸Þ¸ð¸® + 3D Ä«µå ¸Þ¸ð¸®(¿¹Àü¿¡ ÅؽºÃ³ ¸Þ¸ð¸®¶ó ºÒ¸²)
2-1. ¿©±â¼ 3D Ä«µå ¸Þ¸ð¸®´Â ÀϹÝÀûÀ¸·Î 3D Ä«µå ½ºÆå Áß 128MB ¶Ç´Â 64MB¶ó°í À̾߱âÇÏ´Â ¿ë·®À» ¸»ÇÑ´Ù. ºñµð¿À ¸Þ¸ð¸®¿¡´Â ÅؽºÃ³, Z-¹öÆÛ, ¼Îµµ¿ì ¹öÆÛ, ÇÁ·¹ÀÓ ¹öÆÛ, ¹öÅؽº ¹öÆÛ, ½ºÅÙ½Ç ¹öÆÛ µî ¸ðµç 3D Ä«µå°¡ ó¸®ÇÏ´Â °ÍµéÀÌ ¿Ã¶ó°¡°Ô µÈ´Ù. 2-2. °á±¹ Áß¿äÇÑ °ÍÀº AGP ¸Þ¸ð¸®³ª 3D Ä«µåÀÇ ¸Þ¸ð¸®³ª ºñµð¿À ¸Þ¸ð¸®¶ó°í Çصµ 3D Çϵå¿þ¾î¿¡¼´Â °°ÀÌ Ã³¸®µÈ´Ù´Â Á¡ÀÌ´Ù. D3D8 ÀÎÅÍÆäÀ̽º Áß ´ÙÀ½°ú °°Àº API·Î ÇöÀç »ç¿ëÇÒ ¼ö ÀÖ´Â ºñµð¿À ¸Þ¸ð¸® ¾çÀ» ¾Ë¾Æ³¾ ¼ö ÀÖ´Ù.
ÀÌ¿Í °°Àº API·Î ÀÀ¿ë ÇÁ·Î±×·¥ÀÇ ¸®¼Ò½º¸¦ ÀûÀýÇÏ°Ô ºñµð¿À ¸Þ¸ð¸®¿¡ ¿Ã¸± ¼ö ÀÖ´Â µðÅØÆ®(Detect) ±â´ÉÀ» ³Ö¾îÁÖ¸é ÁÁ´Ù.
3.2 ºñµð¿À ¸Þ¸ð¸® ÀÜ·®À» ½Ç½Ã°£À¸·Î ÃøÁ¤(GPGstudy¿¡ ¿Ã·ÁÁø ±Û Á¤¸®) ##.UINT IDirect3DDevice9::GetAvailableTextureMem(VOID);-. Return Values ; »ç¿ë °¡´ÉÇÑ ÅؽºÃ³ ¸Þ¸ð¸®¾çÀÇ ÃßÁ¤°ªÀ» µ¹·ÁÁØ´Ù. -. ÁÖÀÇ ;
µ¹·Á¹Þ´Â °ªÀº, °¡Àå °¡±î¿î MB °ªÀ¸·Î, ƯÁ¤ÀÇ ¸®¼Ò½º¿¡ ÀÇÇÑ ºñµð¿À ¸Þ¸ð¸®ÀÇ ¼Òºñ¿¡ ¿µÇâÀ» ÁÖ´Â alignment³ª ´Ù¸¥ ¹®Á¦¿¡ ÀÇÇØ, ºñµð¿À ¸Þ¸ð¸®ÀÇ ÃßÁ¤°ªÀ» Á¤È®ÇÏ°Ô ¿ä±¸ÇÒ ¼ö°¡ ¾ø±â ¶§¹®ÀÌ´Ù. ¾ÖÇø®ÄÉÀ̼ǿ¡¼´Â, ÀÌ °ªÀ» »ç¿ëÇØ, ÀÌ¿ëÇÒ ¼ö ÀÖ´Â ¸Þ¸ð¸®ÀÇ ´ë·®ÀûÀÎ ¾çÀ» ÃßÁ¤ÇØ, ÇÒ´çÇÏ·Á°í ÇÏ´Â ¹Ó¸ÊÀÇ ·¹º§¼ö¿Í °°Àº ¸®¼Ò½º¿¡ °üÇÑ °Å½ÃÀûÀÎ °áÁ¤À» ³»¸± ¼ö ÀÖÁö¸¸, ´Ù¸¥ ¸®¼Ò½º¸¦ ÇÒ´çÇϴµ¥ ÃæºÐÇÑ ¸Þ¸ð¸®°¡ ³²¾Æ ÀÖ´ÂÁö µî ÀÛÀº ½ºÄÉÀÏÀÇ °áÁ¤¿¡´Â »ç¿ëÇÒ ¼ö ¾ø´Ù.
-. ÇÊ¿ä ; Header: Declared in D3D9.h.(Ãâó; MSDN)(·ç±¤) Windows °ÔÀÓÀº ¹Ýµå½Ã VRAMÀÇ Å©±â¸¦ ÃßÁ¤ÇØ¾ß ÇÑ´Ù. DirectX 4¿¡¼ DirectX 7±îÁö´Â IDirectDrawÀÇ GetAvailableVidMemÀ» ÅëÇؼ VRAM Å©±â¸¦ Á÷Á¢ ¾òÀ» ¼ö ÀÖ¾ú´Ù.
...(Áß·«)....
DirectX 9¿¡¼´Â ÀÌ ÇÔ¼ö°¡ »ç¶óÁ³´Ù. DirectX 9 µµ¿ò¸» »ó¿¡´Â »ç¿ëÇÒ ¼ö ÀÖ´Â ºñµð¿À RAMÀÇ ¾çÀ» ±¸ÇÏ´Â °¡Àå ÁÁÀº ¹æ¹ýÀÌ IDirect3DDevice9 ÀÎÅÍÆäÀ̽ºÀÇ GetAvailableTextureMemÀ» »ç¿ëÇÏ´Â °ÍÀ̶ó°í ³ª¿Í ÀÖ´Ù.
...(Áß·«)....
±×·¯³ª µµ¿ò¸»À» ÀÚ¼¼È÷ º¸¸é, »ç½Ç ÇÔ¼ö À̸§¿¡¼µµ ÁüÀÛÇÒ ¼ö ÀÖÁö¸¸, ÀÌ ÇÔ¼ö´Â »ç¿ë °¡´ÉÇÑ ÅؽºÃ³ ¸Þ¸ð¸®ÀÇ ¿ë·®À» µ¹·ÁÁÙ »ÓÀε¥, ±× °ªÀº VRAMÀÇ ¿ë·®°ú ´Ù¸£´Ù. ±×·¡¼ ³ª´Â DX9 °ÔÀÓÀÌ¶óµµ ÀÌ ºÎºÐ¸¸ÅÀº DX7 API¸¦ »ç¿ëÇÑ´Ù. DX9¿ë °ÔÀÓ¿¡¼µµ ²À ÇÊ¿äÇÏ´Ù¸é DX7, DX6 µîÀ» »ç¿ëÇÒ ¼ö ÀÖ´Ù´Â Á¡Àº ÀÌ¹Ì À̾߱âÇß¾ú´Ù.
´õ ÀÚ¼¼È÷´Â ¾È ³ª¿Í ÀÖÁö¸¸ ±× µÚ ¹®Àåµé·Î À¯ÃßÇغ¸¸é QueryInterface¸¦ ÀÌ¿ëÇؼ DX7 IDirectDraw ÀÎÅÍÆäÀ̽º¸¦ ¾ò¾î¼ ¾î¶»°Ô ÇÒ ¼ö ÀÖ³ª º¾´Ï´Ù...
´ëÃæ ÀÌ·¸³×¿ä.. ÄÚµå:
#include <ddraw.h>
... m_MaxAllocMem = m_pDevice->GetAvailableTextureMem(); ///// LPDIRECTDRAW7 lpDD = NULL; DDSCAPS2 ddsCaps2; DWORD dwTotal; DWORD dwFree; HRESULT hr;
hr = DirectDrawCreateEx(NULL, (VOID**)&lpDD, IID_IDirectDraw7, NULL );
if (FAILED(hr))
return FALSE;
ddsCaps2.dwCaps = DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM;
Âü°í·Î ÀÌ°Ç ½Ã½ºÅÛ ¸Þ¸ð¸®¿¡ °üÇÑ°Å.. hr = lpDD->GetAvailableVidMem(&ddsCaps2, &dwTotal, &dwFree); if (FAILED(hr))
return FALSE;
if(lpDD)
lpDD->Release();
ÄÚµå: // get video memory long nStartVideoMemory = g_pDirect3DDevice->GetAvailableTextureMem();
if( nStartVideoMemory <= 50000000 ) // tiny Video Memory => 16(Video) + 32(AGP)
g_byVideoMemoryType = eVIDEOMEM_TINY;
else
if( nStartVideoMemory <= 97000000 ) // Small Video Memory => 32(Video) + 64(AGP)
g_byVideoMemoryType = eVIDEOMEM_SMALL;
3.3 Windows ÀÛ¾÷ °ü¸®ÀÚ ##.ÀÛ¾÷°ü¸®ÀÚ¿¡¼ ÁÖÀ§ ±í°Ô ºÁ¾ßÇÒ Ç׸ñ Áß¿¡ ¸Þ¸ð¸® »ç¿ë°ú VMÅ©±â¶ó´Â °ÍÀÌ ÀÖ´Ù.
¸Þ¸ð¸® »ç¿ë·®Àº ÇØ´ç ÇÁ·Î¼¼½º°¡ ÇöÀç »ç¿ëÁßÀÎ ¹°¸®Àû ¸Þ¸ð¸®ÀÇ ¾çÀÌ´Ù.
VM Å©±â´Â ÇØ´ç ÇÁ·Î¼¼½º¿¡ ÇÒ´çµÈ ÃÑ °¡»ó ¸Þ¸ð¸®ÀÌ´Ù. 4 D3DX ÇÔ¼ö #4.1 ȸé Å©±â ±¸ÇÏ´Â ¹ý #1. GetDesktopWindow(), GetWindowRect()- Desktopµµ ÇϳªÀÇ À©µµ¿ìÀ̹ǷÎ, DesktopÀÇ À©µµ¿ì ÇÚµéÀ» ¾ò¾î âũ±â¸¦ ±¸ÇÏ´Â ¹æ½Ä
int width = rcDesktop.right - rcDesktop.left;
int height = rcDesktop.bottom - rcDesktop.top;
3. GetDeviceCaps()
- HDC¸¦ ¾î¶»°Ô ±¸ÇϳĿ¡ µû¶ó¼ µà¾ó ¸ð´ÏÅÍ »ç¿ë½Ã °¢°¢ÀÇ ¸ð´ÏÅÍ¿¡¼ Çػ󵵸¦ ±¸ÇØ¿Ã ¼ö ÀÖ´Ù´Â°Ô ÀåÁ¡
HDC hDC = GetDC();
int width = GetDeviceCaps(hDC, HORZRES); int height = GetDeviceCaps(hDC, VERTRES); cf.
4.1.1 ½Ã½ºÅÛ Á¤º¸¸¦ Ãâ·ÂÇÏ´Â ¹æ¹ý ; µà¾ó¸ð´ÏÅÍÀÇ ¸ð´ÏÅÍ »çÀÌÁî #
-. Syntax
int WINAPI GetSystemMetrics(
_In_ int nIndex
);nIndex : Á¶»çÇÏ°íÀÚ ÇÏ´Â ¼³Á¤ Á¤º¸. º¸Åë SM_CX, SM_CY·Î ½ÃÀÛÇϴµ¥ °¢°¢ XÃà ¼³Á¤°ª°ú YÃà ¼³Á¤°ªÀ¸·Î ±¸¼º
-. Parameters
SM_CLEANBOOT - ½Ã½ºÅÛÀÌ ¾î¶»°Ô ºÎÆõǾú´ÂÁö¸¦ Á¶»ç
0ÀÌ¸é º¸Åë ¸ðµå·Î ºÎÆÃ, 1ÀÌ¸é ¼¼ÀÌÇÁ ¸ðµå·Î ºÎÆÃ, 2ÀÌ¸é ³×Æ®¿÷ Áö¿øÀÌ ÀÖ´Â ¼¼ÀÌÇÁ ¸ðµå·Î ºÎÆÃ
SM_CMONITORS - 98, 2000 ÀÌ»ó : µ¥½ºÅ©Å¾ÀÇ ¸ð´ÏÅÍ °³¼öSM_CMOUSEBUTTONS - ¸¶¿ì½ºÀÇ ¹öÆ° °³¼ö.
0ÀÌ¸é ¸¶¿ì½º°¡ ¼³Ä¡µÇ¾î ÀÖÁö ¾ÊÀ½
SM_CXSCREEN, SM_CYSCREEN - ÇÁ¶óÀ̸Ӹ® µð½ºÇ÷¹ÀÌÀÇ È¸é Å©±â
ÀÌ °ªÀº µ¥½ºÅ©Å¾ DC·Î GetDeviceCaps ÇÔ¼ö¸¦ È£ÃâÇÏ¿© HORZRES, VERTRES¸¦ È£ÃâÇÑ °á°ú¿Í µ¿ÀÏ
...
SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN - 98/ME, 2000ÀÌ»ó : °¡»ó ½ºÅ©¸°ÀÇ Æø°ú ³ôÀÌ
ÀÌ Å©±â´Â ¸ðµç µð½ºÇ÷¹ÀÌ ¸ð´ÏÅÍ ¿µ¿ªÀ» µÑ·¯½Î´Â Å©±â
SM_XVIRTUALSCREEN, SM_YVIRTUALSCREEN - 98/MEÀÌ»ó, 2000ÀÌ»ó : °¡»ó ½ºÅ©¸°ÀÇ ¿ÞÂÊ À§ÀÇ ÁÂÇ¥
-. Return value
GetSystemMetrics( SM_ARRANGE );ÀÇ ¸®ÅÏ °ª
; ÃÖ¼ÒÈµÈ À©µµ¿ì¸¦ ¾î¶² ½ÄÀ¸·Î Á¤·ÄÇÒ °ÍÀΰ¡¸¦ ÁöÁ¤ÇÑ´Ù. Á¤·Ä ½ÃÀÛ À§Ä¡¿Í ¹æÇâÀ» ¸®ÅÏÇϴµ¥ ½ÃÀÛ À§Ä¡´Â ´ÙÀ½ Áß Çϳª
/ Á¤·Ä ¹æÇâ ARW_DOWN, ARW_LEFT, ARW_RIGHT, ARW_UP Áß Çϳª°¡ µÈ´Ù.
GetSystemMetrics( SM_DIGITIZER );ÀÇ ¸®ÅÏ °ª - Windows 7 or Windows Server 2008 R2 ÀÌÈÄ ¹öÀü¿¡¼ Áö¿ø
NID_INTEGRATED_TOUCH, NID_EXTERNAL_TOUCH, NID_INTEGRATED_PEN, NID_EXTERNAL_PEN, NID_MULTI_INPUT, NID_READY
-. ½Ì±Û ¸ð´ÏÅÍÀÇ °æ¿ì
left = 0;
-. µà¾ó¸ð´ÏÅÍÀÇ °æ¿ì °¢°¢ÀÇ ¸ð´ÏÅÍ ÁÂÇ¥°¡ ¾Æ´Ñ Àüü µÎ°³ ÀÌ»óÀÇ ¸ð´ÏÅ͸¦ ÇÕÄ£ Àüü ¸ð´ÏÅÍ »çÀÌÁîtop = 0; right = GetSystemMetrics( SM_CXSCREEN ); bottom = GetSystemMetrics( SM_CYSCREEN );
left = GetSystemMetrics( SM_XVIRTUALSCREEN );
¸ð´ÏÅÍÀÇ ¹èÄ¡¿Í ±âº» À§Ä¡¿¡ µû¶ó left, topÀÌ À½¼ö °ªÀÌ µÉ ¼ö Àֱ⠶§¹®¿¡ ÁÖÀÇtop = GetSystemMetrics( SM_YVIRTUALSCREEN ); right = GetSystemMetrics( SM_CXVIRTUALSCREEN ); bottom = GetSystemMetrics( SM_CYVIRTUALSCREEN ); 4.2 D3DX ±âÇϹ°Ã¼ #* D3DX ¶óÀ̺귯¸®´Â ´ÙÀ½ÀÇ 6°¡Áö ¸Þ½¬ »ý¼º ÇÔ¼ö¸¦ Á¦°øÇÑ´Ù.
D3DXCreatBox/ Sphere/ Cylinder/ Teapot/ Polygon/ Torus
* <¼±¾ð> --> <·»´õ¸µ>; ÇÊ¿ä¾øÀ» ¶§´Â ¸®¼Ò½º¸¦ ÇØÁ¦ÇÑ´Ù.* »ç¿ë¿¹
LPD3DXMESH g_sphere = NULL;
HEL(Hardware Emulation Layer, RGB ÀåÄ¡¶ó°íµµ ÇÔ) ; ¼ÒÇÁÆ®¿þ¾îÀûÀ¸·Î ƯÁ¤ÇÑ ±â´ÉÀ» ¿¡¹Ä·¹À̼Ç
// »ý¼º
D3DXCreateSphere(g_pd3dDevice, 1.f, 3, 3, &g_sphere, NULL );D3DXComputeNormals( g_sphere, NULL );
// º¯È¯
D3DXMatrixTranslation(&testMat->g_matWorld, x, y, z);
// ¿ùµå¸ÅÆ®¸¯½º Àû¿ë
g_pd3dDevice->SetTransform( D3DTS_WORLD, &testMat->g_matWorld ); g_sphere->DrawSubset(0); // ·»´õ¸µ
// ¼Ò°Å
if( g_sphere != NULL ) g_sphere->Release();g_sphere = 0; Ç÷¯±×ºí ¼ÒÇÁÆ®¿þ¾î(pluggable software device) ; DirectX 9¿¡¼ ¼ÒÇÁÆ®¿þ¾î °³¹ßÀÚ°¡ ÀÛ¼ºÇÑ
HELÀ» »ç¿ëÇϱâ À§ÇÑ ÀÎÅÍÆäÀ̽º
Win32 ¾îÇø®ÄÉÀÌ¼Ç ¡ê Direct3D API ¡ê HAL µð¹ÙÀ̽º ¡êµð¹ÙÀ̽º µå¶óÀ̹ö ÀÎÅÍÆäÀ̽º(DDI)¡ê±×·¡ÇÈÇϵå¿þ¾îWin32 ¾îÇø®ÄÉÀÌ¼Ç ¡ê GDI ¡êµð¹ÙÀ̽º µå¶óÀ̹ö ÀÎÅÍÆäÀ̽º(DDI)¡ê±×·¡ÇÈÇϵå¿þ¾î
À§¿¡¼ º¸´Â °Íó·³, Direct3D´Â DDI(Device Driver Interface)¸¦ ÅëÇÏ¿© ±×·¡ÇÈ Çϵå¿þ¾î¿¡ Á¢±ÙÇÏ´Â
¼ö´ÜÀ¸·Î HALÀ» »ç¿ëÇÑ´Ù.
HAL(Hardware Abstraction Layer); ÁÖ µð¹ÙÀ̽º ŸÀÔÀÌ°í Çϵå¿þ¾î °¡¼Ó ·¡½ºÅÍÈ ¹× Çϵå¿þ¾î¿Í ¼ÒÇÁÆ®¿þ¾î
¹öÅؽº ÇÁ·Î¼¼½Ì µÎ °¡Áö ¸ðµÎ¸¦ Áö¿øÇÑ´Ù.
-. D3DCREATE_SOFTWARE_VERTEXPROCESSINGµð½ºÇ÷¹ÀÌ ¾î´ðÅÍ°¡ Direct3D¸¦ Áö¿øÇÑ´Ù¸é, HALÀÌ ÄÄÇ»ÅÍ¿¡ Á¸ÀçÇÑ´Ù. DirectX 9.0 ¾îÇø®ÄÉÀ̼ÇÀº ±×·¡ÇÈ Ä«µå µå¶óÀ̹ö°¡ DirectX 7 DDI ÀÌ»óÀ» Áö¿øÇØ¾ß ½ÇÇàÇÑ´Ù. ¿ÏÀüÈ÷ ¼ÒÇÁÆ®¿þ¾îÀûÀ¸·Î ¶Ç´Â ºÎºÐÀûÀ¸·Î ¹öÅؽº ÇÁ·Î¼¼½ÌÀ» ¿¡¹Ä·¹ÀÌ¼Ç ÇÒ ¼ö ÀÖ´Ù.
-. D3DCREATE_HARDWARE_VERTEXPROCESSING
IDirect3D9::RegisterSoftwareDevice; Ç÷¯±×ºí ¼ÒÇÁÆ®¿þ¾î ÀåÄ¡¸¦ µî·ÏÇϱâ À§ÇÑ ÇÔ¼ö-. D3DCREATE_MIXED_VERTEXPROCESSING
_. D3DCREATE_PUREDEVICE ; Direct3D°¡ »óÅ ºí·Ï¿¡ ÀúÀåµÉ ¼ö ÀÖ´Â Get~ ÇüÅÂÀÇ ¾î¶°ÇÑ È£Ãâµµ
Áö¿øÇÏÁö ¾ÊÀ½À» ¼³Á¤ÇÏ°íÀÚ ÇÒ ¶§ »ç¿ë
·¹ÆÛ·±½º ·¡½ºÅͶóÀÌÀú´Â Direct3D 9.0 Àüü ±â´ÉÀ» Áö¿øÇÏ´Â ¹Ý¸é¿¡, Ç÷¯±×ºí ¼ÒÇÁÆ®¿þ¾î ÀåÄ¡´Â ½ÉÁö¾îÅ×½ºÃ³¸µµµ Áö¿øÇÏÁö ¾Ê´Â´Ù.
»ç¿ëÇÏ´Â ÄÄÇ»ÅÍ¿¡ Çϵå¿þ¾î °¡¼Ó ±â´ÉÀÌ ¾ø´Ù¸é HAL ÀåÄ¡ »ý¼º ½Ãµµ´Â ½ÇÆÐÇÏ°Ô µÈ´Ù.
¼ÒÇÁÆ®¿þ¾î ÀåÄ¡µéÀº ¾îÇø®ÄÉÀ̼ǿ¡ ÀÇÇØ ·ÎµåµÇ¾î IDirect3D9 °´Ã¼¸¦ »ç¿ëÇÏ¿© µî·Ï
·¹ÆÛ·±½º ·¡½ºÅͶóÀÌÀúDirectX 9 DDK(Device Driver Kit)¿¡ ´õ ÀÚ¼¼ÇÑ Á¤º¸°¡ ÀÖÀ½
·¹ÆÛ·±½º ÀåÄ¡´Â SDKÀÇ ¼³Ä¡ ½Ã¿¡¸¸ Á¦°øÇϸç, Direct3DÀÇ ¸ðµç ±â´ÉµéÀ» Áö¿ø
COM(Component Object Model) ÄÄÆ÷³ÍÆ®´Â ÀÏ°üµÇ°í Á¤ÀÇµÈ ¹æ¹ýÀ¸·Î Á¢±ÙÇÒ ¼ö ÀÖ´Â ÀϹÝÀûÀÎ ±×·¡ÇÈ Ä«µå°¡ Áö¿øÇÏÁö ¾Ê´Â ±â´ÉµéÀ¸¸® Å×½ºÆ®Çϱâ À§Çؼ¸¸ ·¹ÆÛ·±½º ·¡½ºÅͶóÀÌÀú¸¦ »ç¿ëÇØ¾ß Çϸç, ÀÌ ÀåÄ¡´Â ¼Óµµ¸¦ À§Çؼ°¡ ¾Æ´Ï¶ó, Á¤¹Ðµµ¸¦ À§ÇØ ÃÖÀûÈ Direct3D´Â ±âº»ÀûÀ¸·Î ·¹ÆÛ·±½º ·¡½ºÅͶóÀÌÀú¸¦ ¿¡¹Ä·¹À̼ÇÇÏÁö ¾Ê´Â´Ù.
.DLL(Dynamic Link Library) ÆÄÀϷνá, COM ÀÎÅÍÆäÀ̽ºµéÀº °áÄÚ º¯°æÇÒ ¼ö ¾øÀ¸¸ç ¾ð¾î¿¡ µ¶¸³ÀûÀ¸·Î
v-table; COM °´Ã¼¿¡¼ ±¸ÇöµÈ ÇÔ¼öµéÀ» ÂüÁ¶ÇÏ´Â °¡»ó ÇÔ¼ö Å×À̺í·Î, COM ÇÔ¼öµéÀº Á÷Á¢ÀûÀ¸·Î Á¢±Ù¸øÇÔCOM ÄÄÆ÷³ÍÆ®ÀÇ ÇÔ¼ö¿¡¸¸ ¾×¼¼½ºÇÒ ¼ö ÀÖ½À´Ï´Ù.
¢¹ Syntax
HRESULT D3DXSaveSurfaceToFile(
_In_ LPCTSTR pDestFile,
);_In_ D3DXIMAGE_FILEFORMAT DestFormat, _In_ LPDIRECT3DSURFACE9 pSrcSurface, _In_ const PALETTEENTRY *pSrcPalette, _In_ const RECT *pSrcRect
//¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ
££. D3DXIMAGE_FILEFORMAT enumeration Describes the supported image file formats. See Remarks for descriptions of these formats.
¢¹ Syntax
typedef enum D3DXIMAGE_FILEFORMAT {
D3DXIFF_BMP = 0,
} D3DXIMAGE_FILEFORMAT, *LPD3DXIMAGE_FILEFORMAT;D3DXIFF_JPG = 1, D3DXIFF_TGA = 2, D3DXIFF_PNG = 3, D3DXIFF_DDS = 4, D3DXIFF_PPM = 5, D3DXIFF_DIB = 6, D3DXIFF_HDR = 7, D3DXIFF_PFM = 8, D3DXIFF_FORCE_DWORD = 0x7fffffff
//¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ
££. PALETTEENTRY structure Specifies the color and usage of an entry in a logical palette.
¢¹ Syntax
typedef struct PALETTEENTRY {
BYTE peRed;
} PALETTEENTRY, *LPPALETTEENTRY;BYTE peGreen; BYTE peBlue; BYTE peFlags;
/ BYTE peFlags; - The alpha intensity value for the palette entry. Note that as of DirectX 8, this member is treated differently than documented for Windows.
//¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë // DEFINES //¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ #define SCREENSHOT_FORMAT D3DXIFF_BMP #define SCREENSHOT_COMPRESSED_FORMAT D3DXIFF_JPG #define SCREENSHOT_EXTENSION "bmp" #define SCREENSHOT_COMPRESSED_EXTENSION "jpg" #define SCREENSHOT_PREFIX "Hellgate_" #define SCREENSHOT_PATH "Screenshots\\" #define SCREENSHOT_MIN_TIME_BETWEEN 0.1f //¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ static HRESULT sCaptureScreenshot( ScreenShotInfo * pInfo ) { SPDIRECT3DSURFACE9 pBuffer; ... D3DC_IMAGE_FILE_FORMAT tFormat = pInfo->bCompressed ? SCREENSHOT_COMPRESSED_FORMAT : SCREENSHOT_FORMAT; RECT * pRect = NULL; D3DPRESENT_PARAMETERS tPP = dxC_GetD3DPP(); WINDOWINFO tInfo; if ( tPP.Windowed ) { GetWindowInfo( tPP.hDeviceWindow, &tInfo ); pRect = & tInfo.rcClient; } V_RETURN( OS_PATH_FUNC(D3DXSaveSurfaceToFile)( szFilePath, tFormat, pBuffer, NULL, pRect ) ); ... return S_OK; } //¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ 4.4 D3DXCheckVersion - D3D ¹öÀü È®ÀÎÇϱâ #D3D´Â °°Àº ¹öÀü´ë¶óµµ ºÐ±âº° ¾÷µ¥ÀÌÆ®·Î ÀÎÇØ ³»ºÎ ÇÔ¼ö°¡ º¯°æµÇ°Å³ª ÀÎÀÚ°¡ º¯°æµÇ´Â °æ¿ì°¡ ÀÖ¾î¼ º¸Åë ÇϳªÀÇ ¹öÀüÀ» °íÁ¤½ÃÄÑµÎ°í »ç¿ëÇϴµ¥, À̶§ ÇÁ·ÎÁ§Æ®¿¡¼ ¹öÀü üũ¸¦ À§ÇØ »ç¿ëÇÏ´Â ÇÔ¼ö.#include <d3dx9.h> #include <cstdio> #pragma comment( lib, "d3dx9.lib" ) void main() { #if (D3DX_SDK_VERSION != 42) #error ÀÌ ÇÁ·ÎÁ§Æ®¿¡¼ »ç¿ëµÈ ¹öÀü°ú ´Ù¸¥ Direct3D ¹öÀüÀ» »ç¿ëÇÏ°í °è½Ê´Ï´Ù. #endif if (!D3DXCheckVersion(D3D_SDK_VERSION, /*D3DX_SDK_VERSION*/ 41)) { printf("¹öÀüÀÌ ´Þ¶ó¿ä~ Çغ¸¸®\n"); } } 4.5 OSVERSIONINFOEX Structure (Windows)¸¦ ÀÌ¿ëÇÑ ¹öÀü È®ÀÎ ##. ¹öÀü Á¤º¸ ¾ò±â
OSVERSIONINFOEX version;
#. DirectX ÀÎÅÍÆäÀ̽º »ý¼ºmemset(&version, 0, sizeof(version)); version.dwOSVersionInfoSize = sizeof(version); if(GetVersionEx((OSVERSIONINFO*)&version)) {
printf("Windows %d.%d.%d", version.dwMajorVersion, version.dwMinorVersion, version.dwBuildNumber);
}#. ¿øÇÏ´Â DirectX LoadLibrary ¿©ºÎ È®ÀÎ
string d3dx9_dll = format("d3dx9_%d.dll", D3DX_SDK_VERSION);
Âü°í ÄÚµå(GSUtil.cpp) if(HINSTANCE hDll = LoadLibrary(d3dx9_dll.c_str())) {
FreeLibrary(hDll);
}else {
printf("Cannot find %s\n", d3dx9_dll.c_str());
} 4.6 Rendering °ü·Ã ¼³Á¤, Log ÆÄÀÏ·Î ÀúÀå #///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // m_pd3dDevice->SetRenderState(...), SetSamplerState(...), SetTextureStageState(...); ¼³Á¤À» // Log·Î Ãâ·ÂÇϱâ À§ÇØ ¸ÊÇÎ Çü½ÄÀ¸·Î »ç¿ëÇÑ ¿¹
#define MAX_RENDER_STATE_NUM 256
#define MAX_TEXTURE_STAGE_NUM 8 #define MAX_TEXTURE_STAGESTATE_NUM 29 #define MAX_SAMPLER_STAGE_NUM 8 #define MAX_SAMPLER_STATE_NUM 14
//=============================================================================
//----------------------------------------------------------------------------- class RenderDevice : public D3DDevice {
public:
...
void SetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE type, DWORD Value);
public: void SetTexture(DWORD Stage, IDirect3DBaseTexture9* pTexture ); void SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value); void LogRenderState(); void LogSamplerState(); void LogTextureStageState();
LPDIRECT3DDEVICE9 m_pd3dDevice; // The D3D rendering device
...DWORD m_dwRenderStateListMAX_RENDER_STATE_NUM; // Log¸¦ Ãâ·ÂÇϱâ À§ÇØ ¸ÊÇÎ Çü½ÄÀ¸·Î »ç¿ë DWORD m_dwTextureStageStateListMAX_TEXTURE_STAGE_NUMMAX_TEXTURE_STAGESTATE_NUM; DWORD m_dwSamplerStateListMAX_SAMPLER_STAGE_NUMMAX_SAMPLER_STATE_NUM; };
//=============================================================================
//----------------------------------------------------------------------------- void RenderDevice::SetRenderState(D3DRENDERSTATETYPE State, DWORD Value) { }
void RenderDevice::SetSamplerState(DWORD dwStage, D3DSAMPLERSTATETYPE State, DWORD Value)
{
if(dwStage<0 || dwStage>=MAX_SAMPLER_STAGE_NUM) return;
}if(State<0 || State>=MAX_SAMPLER_STATE_NUM ) return; if(m_dwSamplerStateListdwStageState != Value){ }
void RenderDevice::SetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE type, DWORD Value)
{
if(dwStage<0 || dwStage>=MAX_TEXTURE_STAGE_NUM) return;
}if(type<0 || type>=MAX_TEXTURE_STAGESTATE_NUM ) return; if(m_dwTextureStageStateListdwStagetype != Value){
m_dwTextureStageStateListdwStagetype = Value;
} m_pd3dDevice->SetTextureStageState(dwStage, type, Value);
//-----------------------------------------------------------------------------
void RenderDevice::LogRenderState() {
FILE* fp = fopen("RenderStateLog.txt", "wt");
}if(fp==NULL) return; for(int i=0;i<MAX_RENDER_STATE_NUM;i++){
fprintf(fp, "Index:%d Val=%d\n", i, m_dwRenderStateList[i]);
}fclose(fp);
void RenderDevice::LogSamplerState()
{
FILE* fp = fopen("SamplerStateLog.txt", "wt");
}if(fp==NULL) return; for(int i=0;i<MAX_SAMPLER_STAGE_NUM;i++){
for(int j=0;j<MAX_SAMPLER_STATE_NUM;j++){
}
fprintf(fp, "Stage:%d State:%d Val=%d\n", i,j, m_dwSamplerStateList[i][j]);
}fclose(fp);
void RenderDevice::LogTextureStageState()
{
FILE* fp = fopen("TextureStageStateLog.txt", "wt");
}if(fp==NULL) return; for(int i=0;i<MAX_TEXTURE_STAGE_NUM;i++){
for(int j=0;j<MAX_TEXTURE_STAGESTATE_NUM;j++){
}
fprintf(fp, "Stage:%d State:%d Val=%d\n", i,j, m_dwTextureStageStateList[i][j]);
}fclose(fp); 5 Display #5.1 ¸Ê2ÀåÀ» »ç¿ëÇÑ ¹ý¼± ¸ÊÇÎ #D3DTEXTUREOP ¿°ÅÇü(½ºÅ×ÀÌÁö¸¶´Ù ÅؽºÃ³ È¥ÇÕ Ã³¸®¸¦ Á¤ÀÇ)typedef enum _D3DTEXTUREOP {
D3DTOP_DISABLE = 1,
} D3DTEXTUREOP;... D3DTOP_MULTIPLYADD = 25,: ÀûÈ¿¬»êÀ» ½ÇÇàÇÑ´Ù. ¸¶Áö¸· 2 °³ÀÇ Àμö¸¦ ÃëÇØ, À̰͵éÀ» °ö¼ÀÇØ, ³ª¸ÓÁöÀÇ ÀÔ·Â/¼Ò½º Àμö¿¡ µ¡¼À ÇØ, ÀÌ°ÍÀ» °á°ú¿¡ ¹èÄ¡ÇÑ´Ù. SRGBA= Arg1 + Arg2 * Arg3 ... Âü°í; 3D°ÔÀÓÇÁ·Î±×·¡¹Ö(±è¿ëÁØ Àú) 2ºÎ 5Àå ¹ý¼± ¸ÊÇο¡¼ ÃßÃâ g_pd3dDevice->SetTexture( 0, g_pTexNormal ); // 0¹ø ÅؽºÃÄ ½ºÅ×ÀÌÁö¿¡ ÅؽºÃÄ °íÁ¤(¹ý¼±¸Ê) g_pd3dDevice->SetTexture( 1, g_pTexDiffuse ); // 1¹ø ÅؽºÃÄ ½ºÅ×ÀÌÁö¿¡ ÅؽºÃÄ °íÁ¤(º®¸é¸Ê) g_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 ); g_pd3dDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 0 ); DWORD dwFactor = VectortoRGBA( &g_vLight, 0.0f ); // º¤Å͸¦ RGB·Î g_pd3dDevice->SetRenderState( D3DRS_TEXTUREFACTOR, dwFactor ); // RGB·Î º¯È¯µÈ º¤Å͸¦ TextureFactor°ªÀ¸·Î µî·Ï g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_DOTPRODUCT3 ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_TFACTOR ); g_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_MULTIPLYADD ); // º®¸é¸Ê ÅؽºÃ³¿Í ¹ý¼±¸ÊÀ» ¼¯¾î¼ Ãâ·Â g_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE ); g_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT ); g_pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); g_pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); 5.2 ¾ËÆÄºí·»µù #* D3DÀÇ ¾ËÆÄºí·»µùÀº ¾Æ·¡¿Í °°ÀÌ ÀÌ·ç¾îÁø´Ù.
WriteColor = SrcBlend * SrcColor + DstBlend * DstColor ;
} D3DBLEND;
WriteColor : ȸ鿡 Âï°íÀÚ ÇÏ´Â »ö»ó
SrcBlend¿Í DstBlend¸¦ Àû´çÈ÷ Àß ¸¸µé¾î ÁÖ¸é Àç¹ÌÀÖ´Â È¿°ú¸¦ ¾òÀ»¼ö ÀÖ½À´Ï´Ù. SrcColor : ÅؽºÃÄ ºí·»µù(½¦À̵ù,¸ÖƼÅؽºÃĸµ µûÀ§...)ó¸®µÈ ÅؽºÃÄ»ö»ó DstColor : ÇöÀç ȸ鿡 ÂïÇôÀÖ´Â »ö»ó DBLEND ¿°ÅÇü(Áö¿ø µÇ°í ÀÖ´ÂÈ¥ÇÕ ¸ðµå¸¦ Á¤ÀÇ) typedef enum _D3DBLEND {
D3DBLEND_ZERO = 1,
D3DBLEND_ONE = 2, D3DBLEND_SRCCOLOR = 3, D3DBLEND_INVSRCCOLOR = 4, D3DBLEND_SRCALPHA = 5, D3DBLEND_INVSRCALPHA = 6, D3DBLEND_DESTALPHA = 7, D3DBLEND_INVDESTALPHA = 8, D3DBLEND_DESTCOLOR = 9, D3DBLEND_INVDESTCOLOR = 10, D3DBLEND_SRCALPHASAT = 11, D3DBLEND_BOTHSRCALPHA = 12, D3DBLEND_BOTHINVSRCALPHA = 13, D3DBLEND_BLENDFACTOR = 14, D3DBLEND_INVBLENDFACTOR = 15, D3DBLEND_FORCE_DWORD = 0x7fffffff m_pd3dDevice->SetTexture( 0, m_pWaterTex[0] ); m_pd3dDevice->SetTexture( 1, m_pWaterTex[1] ); //¾ËÆÄºí·»µù Åõ¸í(¹ÝÅõ¸í)ÇÏ°Ô --------------------------------------------- m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE); m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE ); m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_SRCCOLOR ); // Åõ¸í // m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVDESTCOLOR); // ¹ÝÅõ¸í Ãâó : °¨ÀÚ´å³Ý + ±ÔÁø 5.3 Ä¿¼¸¦ ¸¶À½´ë·Î... #
SetCursor( NULL ); // ¸¶¿ì½º¸¦ ³ªÅ¸³ªÁö ¾Ê°Ô ¾Ê´Ù.
LPD3DXFONT m_pStatsFont;
m_pStatsFont = NULL; // ¼±¾ð HRESULT hr; if( FAILED( hr = D3DXCreateFont( g_pd3dDevice, 30, 0, FW_BOLD, 0, FALSE, DEFAULT_CHARSET,OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Arial"), &m_pStatsFont ) ) ) { } // ·»´õ¸µ ½Ã°£Ç¥½Ã ¿¹ fFPS = myTimer.GetFPS(); sprintf(cFPS,"FPS: %4.1f",fFPS); //TextOut(hDC,0,0,str,(int)strlen(str)); //SetWindowText(hWnd,str); RECT rc; SetRect( &rc, 5, 5, 0, 0 ); // DT_NOCLIP : Ŭ¸®ÇÎÇÏÁö ¾Ê°í µå·ÎÀ×ÇÑ´Ù. m_pStatsFont->DrawText( NULL, cFPS, -1, &rc, DT_NOCLIP, D3DXCOLOR( 1.0f, 1.0f, 0.0f, 1.0f ));
·»´õ¸µ surface¿¡¼ depth testingÀÌ ÀϾ ¶§ ¸¸¾à z ȤÀº w°ªÀÌ ÀÌÀüÀÇ °ªº¸´Ù ´õ ÀÛÀº °æ¿ì
Direct3DÀº render Ÿ°ÙÀ» ¾÷µ¥ÀÌÆ® Çϵµ·Ï µÇ¾îÀÖ´Ù. ±×·¯³ª ÇÊ¿äÇÑ °æ¿ì D3DRS_ZFUNCÀÇ °ªÀ» ¼¼ÆÃÇÏ¿© ÀÌ·¯ÇÑ ¿É¼ÇÀ» ¹Ù²Ü¼ö ÀÖ´Ù. typedef enum_D3DCMPFUNC {
D3DCMP_NEVER = 1,: Ç×»ó fail °ªÀ» ÁØ´Ù.
} D3DCMPFUNC;D3DCMP_LESS = 2,: ÀÌÀü °ªº¸´Ù ÀÛÀ¸¸é acceptÇÑ´Ù D3DCMP_EQUAL = 3,: ÀÌÀü °ª°ú °°À¸¸é accept ÇÑ´Ù D3DCMP_LESSEQUAL = 4,: ÀÌÀü °ªº¸´Ù °°°Å³ª ÀÛÀ¸¸é acceptÇÑ´Ù D3DCMP_GREATER = 5,: ÀÌÀü °ªº¸´Ù Å©¸é acceptÇÑ´Ù. D3DCMP_NOTEQUAL = 6,: ÀÌÀü °ªº¸´Ù °°Áö ¾ÊÀ¸¸é acceptÇÑ´Ù. D3DCMP_GREATEREQUAL = 7,: ÀÌÀü °ªº¸´Ù Å©°Å³ª °°À¸¸é acceptÇÑ´Ù D3DCMP_ALWAYS = 8,:Ç×»ó acceptÇÑ´Ù D3DCMP_FORCE_DWORD = 0x7fffffff // D3DCMP_FORCE_DWORD °á°ú¸¦ 32bit »çÀÌÁî·Î ¹Ù²Û´Ù. ÀÌ°ªÀº »ç¿ëµÇÁö ¾Ê´Â´Ù. 5.6 Quaternion #* QuaternionȸÀü* Quaternion»çÀÌÀÇ º¸°£
D3DXQUATERNION *D3DXQuaternionSlerp(
D3DXQUATERNION *pOut, // [in, out] ¿¬»ê °á°úÀÎ D3DXQUATERNION ±¸Á¶Ã¼ÀÇ Æ÷ÀÎÅÍ.
CONST D3DXQUATERNION *pQ1, // in ó¸®ÀÇ ±âº»À¸·Î µÇ´Â D3DXQUATERNION ±¸Á¶Ã¼ÀÇ Æ÷ÀÎÅÍ. CONST D3DXQUATERNION *pQ2, // in ó¸®ÀÇ ±âº»À¸·Î µÇ´Â D3DXQUATERNION ±¸Á¶Ã¼ÀÇ Æ÷ÀÎÅÍ. FLOAT t ); // in º¸°£ ÇÏ´Â ÄõÅʹϿ°£ÀÇ °£°ÝÀ» ³ªÅ¸³»´Â ÆĶó¹ÌÅÍ. ¹Ýȯ°ª; º¸°£ °á°úÀÎ D3DXQUATERNION ±¸Á¶Ã¼ÀÇ Æ÷ÀÎÅÍ. ¸Þ¸ðÀåÀ¸·Î °¡±â |
ÁöÇý´Â °®°í ´Ù´Ï±â¿£ ½±Áö¸¸ ¾ò±â¿£ Èûµç °ÍÀÌ´Ù. ¹Ù¶÷_gems_Localizing edu2015_¹ÚÀçÈñ±³¼ö_ÃáÃß°í»ç HomepageTemplate ¹Ù¶÷06_2013 |