WHDXGraphic.h
上传用户:cydong117
上传日期:2009-11-10
资源大小:638k
文件大小:13k
- #ifndef _WINDHORN_DXGRAPHIC
- #define _WINDHORN_DXGRAPHIC
- /******************************************************************************************************************
- CWHDXGraphicWindow Class Declaration
- *******************************************************************************************************************/
- typedef struct tagDXG_DISPLAYINFO
- {
- WORD wWidth;
- WORD wHeight;
- WORD wBPP;
- }DXG_DISPLAYINFO, *LPDXG_DISPLAYINFO;
- typedef struct DXG_ENUM_DEVICEINFO
- {
- // 3D 叼官捞胶 沥焊.
- TCHAR szDeviceDesc[256];
- GUID* pDeviceGUID;
- D3DDEVICEDESC7 ddDeviceDesc;
- BOOL f3DHardware;
- // 靛肺快 靛扼捞滚 沥焊.
- TCHAR szDriverDesc[256];
- GUID* pDriverGUID;
- DDCAPS ddDriverCaps;
- DDCAPS ddHELCaps;
- GUID guidDevice;
- GUID guidDriver;
- DDSURFACEDESC2* pddsdModes;
- DWORD dwNumModes;
- }DXG_ENUM_DEVICEINFO, *LPDXG_ENUM_DEVICEINFO;
- typedef struct tagDXG_MASKINFO
- {
- BYTE bRCnt;
- BYTE bGCnt;
- BYTE bBCnt;
- BYTE bRShift;
- BYTE bGShift;
- BYTE bBShift;
- DWORD dwRMask;
- DWORD dwGMask;
- DWORD dwBMask;
- }DXG_MASKINFO, *LPDXG_MASKINFO;
- class CWHDXGraphicWindow : public CWHWindow
- {
- //1: Constuctor/Destructor
- public:
- CWHDXGraphicWindow(WORD wWidth = _SCREEN_WIDTH, WORD wHeight = _SCREEN_HEIGHT, WORD wBpp = _SCREEN_BPP);
- ~CWHDXGraphicWindow();
- //2: Variables
- protected:
- LPDIRECT3D7 m_pD3D;
- LPDIRECTDRAW7 m_pDD;
- LPDIRECT3DDEVICE7 m_pd3dDevice;
- LPDIRECTDRAWSURFACE7 m_pddsFrontBuffer;
- LPDIRECTDRAWSURFACE7 m_pddsBackBuffer;
- LPDIRECTDRAWSURFACE7 m_pddsZBuffer;
- LPDIRECTDRAWCLIPPER m_lpcClipper;
- ///////<---------------------------------------------------------------------------------------------------------------------------
- HFONT m_hDefGameFont;
- ///////<---------------------------------------------------------------------------------------------------------------------------
- BYTE m_bScreenModeFlag;
- BYTE m_bDeviceModeFlag;
- public:
- DWORD m_dwTextureTotal; // 傈眉 荤侩且荐 乐绰 皋葛府.
- DWORD m_dwTextureFree; // 泅犁 巢篮 皋葛府.
- DWORD m_dwVideoTotal; // vram 傈眉 皋葛府.
- DWORD m_dwVideoFree; // 泅犁 巢篮 vram 皋葛府 .
- BOOL m_bIsWindowActive;
- BOOL m_bIsWindowReady;
- RECT m_rcWindow;
- DXG_DISPLAYINFO m_stDisplayInfo;
- DXG_MASKINFO m_stBitsMaskInfo;
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // 橇肺技胶甫 唱穿扁困茄 函荐急攫.
- static CWHDXGraphicWindow* m_pxDXGWnd;
- CWHDefProcess* m_pxDefProcess;
- VOID (*RenderProcess)(int);
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //3: Methods
- protected:
- BYTE FindDriverAndDevice();
- VOID FreeDXGEnumModeResources();
- HRESULT CreateDXG();
- HRESULT CreatePrimarySurface();
- HRESULT CreateZBuffer(GUID* pDeviceGUID);
- HRESULT Init3DDeviceObjects();
- HRESULT DestroyDXGObjects();
- public:
- __inline LPDIRECTDRAW7 GetDirectDraw() { return m_pDD; }
- __inline LPDIRECT3D7 GetDirect3D() { return m_pD3D; }
- __inline LPDIRECT3DDEVICE7 Get3DDevice() { return m_pd3dDevice; }
- __inline LPDIRECTDRAWSURFACE7 GetFrontBuffer() { return m_pddsFrontBuffer; }
- __inline LPDIRECTDRAWSURFACE7 GetBackBuffer() { return m_pddsBackBuffer; }
- __inline BYTE GetDeviceMode() { return m_bDeviceModeFlag; }
- __inline BYTE GetScreenMode() { return m_bScreenModeFlag; }
- DXG_MASKINFO GetRGBMaskInfoIN16Bits(LPDIRECTDRAWSURFACE7 pSurface);
- virtual VOID UpdateBoundsWnd();
- HRESULT ResetDXG(WORD wWidth, WORD wHeight, WORD wBPP, BYTE bScreenModeFlag, BYTE bDeviceModeFlag);
- BOOL Create(HINSTANCE hInst, LPTSTR lpCaption = NULL, CHAR *pszMenuName = NULL, CHAR* pszIconName = NULL, BYTE bScreenModeFlag = _DXG_SCREENMODE_WINDOW, BYTE bDeviceModeFlag = _DXG_DEVICEMODE_PRIMARY);
- ///////<---------------------------------------------------------------------------------------------------------------------------
- HFONT CreateGameFont(LPCSTR szFontName, INT nHeight, INT nWidth = 0, INT nWeight = FW_NORMAL, BOOL bItalic = FALSE, BOOL bULine = FALSE, BOOL bStrikeOut = FALSE, DWORD dwCharSet = HANGEUL_CHARSET);
- VOID CreateDefFont();
- VOID PutsHan(LPDIRECTDRAWSURFACE7 pSurface, INT nX, INT nY, COLORREF foreColor, COLORREF backColor, CHAR* szText, HFONT hFont = NULL);
- VOID PutsHan(LPDIRECTDRAWSURFACE7 pSurface, RECT rc, COLORREF foreColor, COLORREF backColor, CHAR* szText, HFONT hFont = NULL);
- SIZE GetStrLength(LPDIRECTDRAWSURFACE7 pSurface, HFONT hFont, CHAR* szFormat, ...);
- ///////<---------------------------------------------------------------------------------------------------------------------------
- BOOL StringDivide(INT nDivideWidth, INT& nDividedLine, CHAR* szSrc, CHAR* szResult);
- // BOOL StringDivideLen(INT nDivideLen, INT& nDividedLine, CHAR* szSrc, CDLList<CHAR*>* m_pxpStr);
- VOID StringPlus(CHAR* szResult, CHAR* szSrc, ...);
- CHAR* IntToStr(INT nNum);
- VOID UsedAndFreeMemoryCheck();
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- WORD ConvertColor24To16(COLORREF dwColor);
- // 坊歹傅 窃荐葛澜.
- // 1. GDI侩 弊府扁 窃荐.(急, 荤阿屈殿阑 归辑乔胶俊 弊赴促.)
- HRESULT DrawWithGDI(RECT rc, LPDIRECTDRAWSURFACE7 pSurface, DWORD dwColor, BYTE bKind);
- // 2. WORD屈 单捞鸥 弊府扁 窃荐.(侨伎窜困肺 拿矾虐甫 八荤窍搁辑 归辑乔胶俊 弊赴促.)
- BOOL DrawWithImage(INT nX, INT nY, INT nXSize, INT nYSize, WORD* pwSrc);
- // 3. WORD屈 单捞鸥 弊府扁 窃荐.(扼牢窜困肺 拿矾虐甫 绊妨窍瘤 臼绊 归辑乔胶狼 努府俏 郴何康开俊父 弊赴促.)
- BOOL DrawWithImagePerLineClipRgn(INT nX, INT nY, INT nXSize, INT nYSize, WORD* pwSrc, WORD wClipWidth, WORD wClipHeight);
- // 4. Surface屈 单捞鸥 弊府扁 窃荐.(家胶狼 拿矾虐甫 绊妨窍搁辑 归辑乔胶俊 弊赴促.)
- BOOL DrawWithSurface(INT nX, INT nY, INT nXSize, INT nYSize, LPDIRECTDRAWSURFACE7 pddsSrc);
- // wChooseColor1篮 堪祸渴(0xC2)俊 措秦辑, wChooseColor2(0xC3)绰 赣府殿(漠, 扁鸥 函窍绰祸)狼 堪祸栏肺 敬促.
- // 5. 拘绵(0锅)棺 堪祸等 WORD屈 单捞鸥 弊府扁 窃荐.(归辑乔胶俊 弊赴促.)
- BOOL DrawWithImageForComp(INT nX, INT nY, RECT rcSrc, WORD* pwSrc, WORD wChooseColor1 = 0XFFFF, WORD wChooseColor2 = 0XFFFF);
- BOOL DrawWithImageForComp(INT nX, INT nY, INT nXSize, INT nYSize, WORD* pwSrc, WORD wChooseColor1 = 0XFFFF, WORD wChooseColor2 = 0XFFFF);
- // 6. 拘绵(0锅)棺 堪祸等 WORD屈 单捞鸥 弊府扁 窃荐.(归辑乔胶狼 努府俏 郴何康开俊父 弊赴促.)
- BOOL DrawWithImageForCompClipRgnBase(INT nX, INT nY, INT nXSize, INT nYSize, WORD* pwSrc, WORD wClipWidth, WORD wClipHeight, WORD wChooseColor1 = 0XFFFF, WORD wChooseColor2 = 0XFFFF);
- __inline VOID DrawWithImageForCompClipRgn(INT nX, INT nY, INT nXSize, INT nYSize, WORD* pwSrc, WORD wClipWidth, WORD wClipHeight, WORD wChooseColor1 = 0XFFFF, WORD wChooseColor2 = 0XFFFF, BOOL bLighted = FALSE)
- {
- if ( bLighted ) DrawWithABlendCompDataWithLightedColor(nX, nY, nXSize, nYSize, pwSrc, wClipWidth, wClipHeight, wChooseColor1, wChooseColor2);
- else DrawWithImageForCompClipRgnBase(nX, nY, nXSize, nYSize, pwSrc, wClipWidth, wClipHeight, wChooseColor1, wChooseColor2);
- }
- // 7. 拘绵(0锅)棺 堪祸等 WORD屈 单捞鸥 弊府扁 窃荐.(家胶皋葛府狼 康开俊辑 单胶飘康开皋葛府肺 弊赴促.)
- BOOL DrawWithImageForCompMemToMem(INT nX, INT nY, INT nXSize, INT nYSize, WORD* pwSrc, INT nDstXSize, INT nDstYSize, WORD* pwDst, WORD wChooseColor1 = 0XFFFF, WORD wChooseColor2 = 0XFFFF);
- // 8. 拘绵(0锅)棺 堪祸等 WORD屈 单捞鸥 弊府扁 窃荐.(拘绵等 单捞鸥狼 家胶皋葛府狼 康开俊辑 老何泛飘康开父阑 单胶飘康开皋葛府肺 弊赴促.)
- BOOL DrawWithImageForCompToMem(RECT rcWanted, WORD* pwSrc, WORD wChooseColor1, WORD wChooseColor2, WORD* pwDst);
- BOOL DrawWithImageForCompColorToMem(RECT rcWanted, WORD* pwSrc, WORD wColor, WORD* pwDst);
- // 9. 拘绵(0锅)棺 堪祸等 WORD屈 单捞鸥 弊府扁 窃荐.(拘绵等 单捞鸥狼 家胶康开苞 单胶飘康开狼 背瞒泛飘甫 舅颇喉坊爹秦辑 归辑乔胶俊弊赴促.)
- BOOL DrawWithABlendForIntersectCompData(INT nSrcX, INT nSrcY,
- INT nSrcXSize, INT nSrcYSize, WORD* pwSrc,
- INT nDstX, INT nDstY,
- INT nDstXSize, INT nDstYSize, WORD* pwDst,
- WORD wClipWidth, WORD wClipHeight,
- BYTE bOpa = 50, BOOL bFocused = FALSE,
- WORD wSrcChooseColor1 = 0XFFFF, WORD wSrcChooseColor2 = 0XFFFF,
- WORD wDstChooseColor1 = 0XFFFF, WORD wDstChooseColor2 = 0XFFFF,
- WORD wSrcColor = 0XFFFF, WORD wDstColor = 0XFFFF);
- // 10. 拘绵(0锅)棺 堪祸等 WORD屈 单捞鸥 弊府扁 窃荐.(拘绵等 单捞鸥狼 家胶康开阑 归辑乔胶客 舅颇喉坊爹茄促.)
- BOOL DrawWithABlendCompDataWithBackBuffer(INT nX, INT nY,
- INT nXSize, INT nYSize, WORD* pwSrc,
- WORD wClipWidth, WORD wClipHeight,
- WORD wChooseColor1 = 0XFFFF, WORD wChooseColor2 = 0XFFFF, BYTE bOpa = 50);
- // 11. 拘绵(0锅)棺 堪祸等 WORD屈 单捞鸥 弊府扁 窃荐.(拘绵等 单捞鸥狼 家胶康开阑 盔窍绰 拿矾肺 扼捞泼 惑怕肺(灌霸) 归辑乔胶俊 弊赴促.)
- BOOL DrawWithABlendCompDataWithLightedColor(INT nX, INT nY,
- INT nXSize, INT nYSize, WORD* pwSrc,
- WORD wClipWidth, WORD wClipHeight,
- WORD wChooseColor1 = 0XFFFF, WORD wChooseColor2 = 0XFFFF);
- // 弊覆磊 弊府扁 窃荐.
- // 12. 拘绵(0锅)棺 堪祸等 WORD屈 单捞鸥 弊府扁 窃荐.(拘绵等 单捞鸥狼 家胶康开狼 弊覆磊甫 归辑乔胶俊 舅颇喉坊爹茄促. 弊覆磊绰 臭捞啊 例馆栏肺 临绢甸绊 承捞绰 YSize父怒 疵绢唱辑 扁匡咯 归辑乔胶俊 嘛腮促.)
- BOOL DrawWithShadowABlend(INT nX, INT nY,
- INT nXSize, INT nYSize, WORD* pwSrc,
- WORD wClipWidth, WORD wClipHeight, WORD* pwShadowClrSrc,
- BOOL bBlend = FALSE, BYTE bShadowType = 48, BYTE bOpa = 50);
- VOID DrawWithShadowABlend(INT nX, INT nY, INT nXSize, INT nYSize,
- INT nPX, INT nPY, WORD* pwSrc, WORD wClipWidth, WORD wClipHeight, WORD* pwShadowClrSrc,
- BOOL bBlend = FALSE, BYTE bOpa = 50);
- // 拿矾贸府.
- // 13.
- BOOL DrawWithImageForCompClipRgnColor(INT nX, INT nY, INT nXSize, INT nYSize, WORD* pwSrc, WORD wClipWidth, WORD wClipHeight, WORD wColor, BOOL bFocused = FALSE, BOOL bBlend = FALSE);
- BOOL DrawWithImageForCompClipRgnColor(INT nX, INT nY, INT nXSize, INT nYSize, WORD* pwSrc, WORD wClipWidth, WORD wClipHeight, WORD wColor, WORD wChooseColor1 = 0XFFFF, WORD wChooseColor2 = 0XFFFF);
- // 14.
- BOOL DrawWithImageForCompClipRgnGray(INT nX, INT nY, INT nXSize, INT nYSize, WORD* pwSrc , WORD wClipWidth, WORD wClipHeight, WORD wChooseColor1 = 0XFFFF, WORD wChooseColor2 = 0XFFFF);
- // 孺归贸府.
- // 15.
- VOID DrawWithGrayBackBuffer();
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- HRESULT Present();
- HRESULT RestoreSurfaces();
- //4: Message Map
- public:
- virtual LRESULT MainWndProcDXG(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
- virtual LRESULT OnSize(WPARAM wParam, LPARAM lParam);
- virtual LRESULT OnMove(WPARAM wParam, LPARAM lParam);
- virtual LRESULT OnSysKeyDown(WPARAM wParam, LPARAM lParam);
- virtual LRESULT OnGetMinMaxInfo(WPARAM wParam, LPARAM lParam);
- protected:
- __inline virtual LRESULT MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- if ( m_pxDefProcess ) return m_pxDefProcess->DefMainWndProc(hWnd, uMsg, wParam, lParam);
- else return MainWndProcDXG(hWnd, uMsg, wParam, lParam);
- }
- virtual LRESULT OnDestroy();
- virtual LRESULT OnSetCursor();
- };
- CWHDXGraphicWindow* GetDXGWindowPtr();
- #endif //_WINDHORN_DXGRAPHIC