Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 244 | chris | 1 | #ifndef __DDINTERFACE_H__ |
| 2 | #define __DDINTERFACE_H__ |
||
| 3 | |||
| 4 | #include "Common.h" |
||
| 5 | #include "CritSect.h" |
||
| 6 | #include "NativeDisplay.h" |
||
| 7 | #include "Rect.h" |
||
| 8 | #include "Ratio.h" |
||
| 9 | |||
| 10 | #include <ddraw.h> |
||
| 11 | |||
| 12 | namespace Sexy |
||
| 13 | { |
||
| 14 | |||
| 15 | class SexyAppBase; |
||
| 16 | class DDImage; |
||
| 17 | class Image; |
||
| 18 | class MemoryImage; |
||
| 19 | class D3DInterface; |
||
| 20 | class D3DTester; |
||
| 21 | |||
| 22 | typedef std::set<DDImage*> DDImageSet; |
||
| 23 | |||
| 24 | class DDInterface : public NativeDisplay |
||
| 25 | { |
||
| 26 | public: |
||
| 27 | enum |
||
| 28 | { |
||
| 29 | RESULT_OK = 0, |
||
| 30 | RESULT_FAIL = 1, |
||
| 31 | RESULT_DD_CREATE_FAIL = 2, |
||
| 32 | RESULT_SURFACE_FAIL = 3, |
||
| 33 | RESULT_EXCLUSIVE_FAIL = 4, |
||
| 34 | RESULT_DISPCHANGE_FAIL = 5, |
||
| 35 | RESULT_INVALID_COLORDEPTH = 6, |
||
| 36 | RESULT_3D_FAIL = 7 |
||
| 37 | }; |
||
| 38 | |||
| 39 | SexyAppBase* mApp; |
||
| 40 | D3DInterface* mD3DInterface; |
||
| 41 | D3DTester* mD3DTester; |
||
| 42 | bool mIs3D; |
||
| 43 | |||
| 44 | CritSect mCritSect; |
||
| 45 | bool mInRedraw; |
||
| 46 | LPDIRECTDRAW mDD; |
||
| 47 | LPDIRECTDRAW7 mDD7; |
||
| 48 | LPDIRECTDRAWSURFACE mPrimarySurface; |
||
| 49 | LPDIRECTDRAWSURFACE mSecondarySurface; |
||
| 50 | LPDIRECTDRAWSURFACE mDrawSurface; |
||
| 51 | int mWidth; |
||
| 52 | int mHeight; |
||
| 53 | Ratio mAspect; |
||
| 54 | int mDesktopWidth; |
||
| 55 | int mDesktopHeight; |
||
| 56 | Ratio mDesktopAspect; |
||
| 57 | bool mIsWidescreen; |
||
| 58 | int mDisplayWidth; |
||
| 59 | int mDisplayHeight; |
||
| 60 | Ratio mDisplayAspect; |
||
| 61 | |||
| 62 | Rect mPresentationRect; |
||
| 63 | int mFullscreenBits; |
||
| 64 | DWORD mRefreshRate; |
||
| 65 | DWORD mMillisecondsPerFrame; |
||
| 66 | int mScanLineFailCount; |
||
| 67 | |||
| 68 | int* mRedAddTable; |
||
| 69 | int* mGreenAddTable; |
||
| 70 | int* mBlueAddTable; |
||
| 71 | |||
| 72 | ulong mRedConvTable[256]; |
||
| 73 | ulong mGreenConvTable[256]; |
||
| 74 | ulong mBlueConvTable[256]; |
||
| 75 | |||
| 76 | bool mInitialized; |
||
| 77 | HWND mHWnd; |
||
| 78 | bool mIsWindowed; |
||
| 79 | DDImage* mScreenImage; |
||
| 80 | DDImageSet mDDImageSet; |
||
| 81 | bool mVideoOnlyDraw; |
||
| 82 | ulong mInitCount; |
||
| 83 | |||
| 84 | int mCursorWidth; |
||
| 85 | int mCursorHeight; |
||
| 86 | int mNextCursorX; |
||
| 87 | int mNextCursorY; |
||
| 88 | int mCursorX; |
||
| 89 | int mCursorY; |
||
| 90 | Image* mCursorImage; |
||
| 91 | bool mHasOldCursorArea; |
||
| 92 | LPDIRECTDRAWSURFACE mOldCursorArea; |
||
| 93 | LPDIRECTDRAWSURFACE mNewCursorArea; |
||
| 94 | DDImage* mOldCursorAreaImage; |
||
| 95 | DDImage* mNewCursorAreaImage; |
||
| 96 | |||
| 97 | std::string mErrorString; |
||
| 98 | |||
| 99 | public: |
||
| 100 | bool CopyBitmap(LPDIRECTDRAWSURFACE theSurface, HBITMAP TheBitmap, int theX, int theY, int theWidth, int theHeight); |
||
| 101 | ulong GetColorRef(ulong theRGB); |
||
| 102 | void AddDDImage(DDImage* theDDImage); |
||
| 103 | void RemoveDDImage(DDImage* theDDImage); |
||
| 104 | void Remove3DData(MemoryImage* theImage); // for 3d texture cleanup |
||
| 105 | |||
| 106 | void Cleanup(); |
||
| 107 | bool GotDXError(HRESULT theResult, const char *theContext = ""); |
||
| 108 | |||
| 109 | void RestoreOldCursorAreaFrom(LPDIRECTDRAWSURFACE theSurface, bool adjust); |
||
| 110 | void DrawCursorTo(LPDIRECTDRAWSURFACE theSurface, bool adjust); |
||
| 111 | void MoveCursorTo(LPDIRECTDRAWSURFACE theSurface, bool adjust, int theNewCursorX, int theNewCursorY); |
||
| 112 | |||
| 113 | HRESULT CreateSurface(DDSURFACEDESC2 *theDesc, LPDIRECTDRAWSURFACE *theSurface, void*); |
||
| 114 | void ClearSurface(LPDIRECTDRAWSURFACE theSurface); |
||
| 115 | bool Do3DTest(HWND theHWND); |
||
| 116 | |||
| 117 | public: |
||
| 118 | DDInterface(SexyAppBase* theApp); |
||
| 119 | virtual ~DDInterface(); |
||
| 120 | |||
| 121 | static std::string ResultToString(int theResult); |
||
| 122 | |||
| 123 | DDImage* GetScreenImage(); |
||
| 124 | int Init(HWND theWindow, bool IsWindowed); |
||
| 125 | bool Redraw(Rect* theClipRect = NULL); |
||
| 126 | void SetVideoOnlyDraw(bool videoOnly); |
||
| 127 | void RemapMouse(int& theX, int& theY); |
||
| 128 | |||
| 129 | bool SetCursorImage(Image* theImage); |
||
| 130 | void SetCursorPos(int theCursorX, int theCursorY); |
||
| 131 | }; |
||
| 132 | |||
| 133 | } |
||
| 134 | |||
| 135 | #endif //__DDINTERFACE_H__ |
||
| 136 |