1 | /* $Id: OS2DDRAW.H,v 1.2 2001-03-09 22:48:48 mike Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * DX Draw base class definition
|
---|
5 | *
|
---|
6 | * Copyright 1998 Sander va Leeuwen
|
---|
7 | * Copyright 1999 Markus Montkowski
|
---|
8 | *
|
---|
9 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
10 | *
|
---|
11 | */
|
---|
12 |
|
---|
13 | #ifndef __OS2DDRAW_HPP__
|
---|
14 | #define __OS2DDRAW_HPP__
|
---|
15 |
|
---|
16 | #include <ddraw.h>
|
---|
17 | #include <d3d.h>
|
---|
18 | #undef APIENTRY
|
---|
19 | #define APIENTRY _System
|
---|
20 | #include "divewrap.h"
|
---|
21 | #define mmioFOURCC( ch0, ch1, ch2, ch3 ) \
|
---|
22 | ( (DWORD)(BYTE)(ch0) | ( (DWORD)(BYTE)(ch1) << 8 ) | \
|
---|
23 | ( (DWORD)(BYTE)(ch2) << 16 ) | ( (DWORD)(BYTE)(ch3) << 24 ) )
|
---|
24 | #include <fourcc.h>
|
---|
25 | #undef THIS
|
---|
26 | #define THIS VOID*
|
---|
27 |
|
---|
28 | #define MAX_FOURCC_CODES 3
|
---|
29 |
|
---|
30 | class OS2IDirectDraw
|
---|
31 | {
|
---|
32 | public:
|
---|
33 | //this one has to go first!
|
---|
34 | IDirectDraw4Vtbl *lpVtbl;
|
---|
35 | IDirectDraw4Vtbl *lpVtbl2; // 2nd Vtable pointer An other MS assumtion see below
|
---|
36 | DWORD *pdwUnknownData; // MS DDCAPS (DX6 SDK bin\tools )program makes an assumtion that after the
|
---|
37 | // VTable comes a pointer to some data
|
---|
38 | // to avoid crashes we do it a favor and alloc a buffer
|
---|
39 | // with 255 DWORDS
|
---|
40 | // Known data in the buffer Height(offset 235),
|
---|
41 | // Height (236), Bits (241)
|
---|
42 | // ToDO :
|
---|
43 | // debug into DirectDrawCreate and se what MS is doing !
|
---|
44 | //Use for Direct3D interface (This != this)
|
---|
45 | IDirect3DVtbl *lpVtbl3D;
|
---|
46 | IDirect3DVtbl *lpVtbl3D2;
|
---|
47 | DWORD *pdwUnknownData3D;
|
---|
48 |
|
---|
49 | IDirectDrawVtbl Vtbl;
|
---|
50 | IDirectDraw2Vtbl Vtbl2;
|
---|
51 | // MS did it again with direct/X 6 they changed the behavior of the directdraw component
|
---|
52 | // So we now need 2 Virt. Tables one for the old and one for the new so we return the
|
---|
53 | // right interface if one creates a DX6 directdraw object but wants a DX2,3,5 interface
|
---|
54 | IDirectDraw4Vtbl Vtbl4;
|
---|
55 | IDirect3DVtbl Vtbl3D;
|
---|
56 |
|
---|
57 | OS2IDirectDraw(GUID *lpGUID);
|
---|
58 | ~OS2IDirectDraw();
|
---|
59 | // Simple management for Surfaces should be good enougth for now
|
---|
60 | inline BOOL HasPrimarySurface() { return PrimaryExists;}
|
---|
61 | void SetPrimarySurface(BOOL NewStatus){PrimaryExists = NewStatus;}
|
---|
62 | int Referenced;
|
---|
63 | inline HRESULT GetLastError() { return lastError; }
|
---|
64 | inline HDIVE GetDiveInstance() { return hDive; }
|
---|
65 | inline HDIVE GetCCDiveInstance() { return hDiveColorConv;}
|
---|
66 | inline char * GetFrameBuffer() { return pFrameBuffer; }
|
---|
67 | inline int GetScreenWidth() { return screenwidth; }
|
---|
68 | inline int GetScreenHeight() { return screenheight; }
|
---|
69 | inline int GetScreenBpp() { return screenbpp;}
|
---|
70 | FOURCC GetScreenFourCC();
|
---|
71 | // We should be able to use any mode with less or same bits and same or
|
---|
72 | // smaller size to be able to report all supported mode in the enum
|
---|
73 | // functions we need the physical screen size. Other information is later
|
---|
74 | // also needed so get all the info we can get
|
---|
75 | DIVE_CAPS dCaps;
|
---|
76 | VOID *pPrimSurf;
|
---|
77 |
|
---|
78 | private:
|
---|
79 | VOID SwitchDisplay(HWND hwnd);
|
---|
80 |
|
---|
81 |
|
---|
82 | protected:
|
---|
83 |
|
---|
84 | HRESULT lastError;
|
---|
85 | HDIVE hDive; // Handle to Screen DIVE instance
|
---|
86 | HDIVE hDiveColorConv; // Handle to Offscreen DIVE instance for Color conversion
|
---|
87 | char *pFrameBuffer;
|
---|
88 | HWND hwndClient;
|
---|
89 | DWORD dwCoopMode;
|
---|
90 | int screenwidth, screenheight, screenbpp;
|
---|
91 | BOOL PrimaryExists;
|
---|
92 | BOOL bScale;
|
---|
93 | int oldwidth, oldheight, oldbpp, oldscanlines;
|
---|
94 | BOOL bPMILoaded;
|
---|
95 | BOOL bInFullScreen;
|
---|
96 |
|
---|
97 |
|
---|
98 | // Linked list management
|
---|
99 | OS2IDirectDraw* next; // Next OS2IDirectDraw
|
---|
100 | static OS2IDirectDraw* ddraw; // List of OS2IDirectDraw
|
---|
101 |
|
---|
102 | friend HRESULT __stdcall DrawQueryInterface(THIS, REFIID riid, LPVOID * ppvObj);
|
---|
103 | friend ULONG __stdcall DrawAddRef(THIS);
|
---|
104 | friend ULONG __stdcall DrawRelease(THIS);
|
---|
105 | friend HRESULT __stdcall DrawCompact(THIS);
|
---|
106 | friend HRESULT __stdcall DrawCreateClipper(THIS, DWORD, LPDIRECTDRAWCLIPPER *, IUnknown * );
|
---|
107 | friend HRESULT __stdcall DrawCreatePalette(THIS, DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE *, IUnknown * );
|
---|
108 | friend HRESULT __stdcall DrawCreateSurface(THIS, LPDDSURFACEDESC, LPDIRECTDRAWSURFACE *, IUnknown *);
|
---|
109 | friend HRESULT __stdcall DrawCreateSurface4(THIS, LPDDSURFACEDESC2, LPDIRECTDRAWSURFACE4 *, IUnknown *);
|
---|
110 | friend HRESULT __stdcall DrawDuplicateSurface(THIS, LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE * );
|
---|
111 | friend HRESULT __stdcall DrawDuplicateSurface4(THIS, LPDIRECTDRAWSURFACE4, LPDIRECTDRAWSURFACE4 * );
|
---|
112 | friend HRESULT __stdcall DrawEnumDisplayModes(THIS, DWORD, LPDDSURFACEDESC, LPVOID, LPDDENUMMODESCALLBACK );
|
---|
113 | friend HRESULT __stdcall DrawEnumDisplayModes4(THIS, DWORD, LPDDSURFACEDESC2, LPVOID, LPDDENUMMODESCALLBACK2 );
|
---|
114 | friend HRESULT __stdcall DrawEnumSurfaces(THIS, DWORD, LPDDSURFACEDESC, LPVOID,LPDDENUMSURFACESCALLBACK );
|
---|
115 | friend HRESULT __stdcall DrawEnumSurfaces4(THIS, DWORD, LPDDSURFACEDESC2, LPVOID,LPDDENUMSURFACESCALLBACK2 );
|
---|
116 | friend HRESULT __stdcall DrawFlipToGDISurface(THIS);
|
---|
117 | friend HRESULT __stdcall DrawGetCaps(THIS, LPDDCAPS, LPDDCAPS);
|
---|
118 | friend HRESULT __stdcall DrawGetDisplayMode(THIS, LPDDSURFACEDESC);
|
---|
119 | friend HRESULT __stdcall DrawGetFourCCCodes(THIS, LPDWORD, LPDWORD);
|
---|
120 | friend HRESULT __stdcall DrawGetGDISurface(THIS, LPDIRECTDRAWSURFACE *);
|
---|
121 | friend HRESULT __stdcall DrawGetGDISurface4(THIS, LPDIRECTDRAWSURFACE4 *);
|
---|
122 | friend HRESULT __stdcall DrawGetMonitorFrequency(THIS, LPDWORD);
|
---|
123 | friend HRESULT __stdcall DrawGetScanLine(THIS, LPDWORD);
|
---|
124 | friend HRESULT __stdcall DrawGetVerticalBlankStatus(THIS, LPBOOL);
|
---|
125 | friend HRESULT __stdcall DrawInitialize(THIS, GUID *);
|
---|
126 | friend HRESULT __stdcall DrawRestoreDisplayMode(THIS);
|
---|
127 | friend HRESULT __stdcall DrawSetCooperativeLevel(THIS, HWND, DWORD);
|
---|
128 | friend HRESULT __stdcall DrawSetDisplayMode(THIS, DWORD, DWORD,DWORD);
|
---|
129 | friend HRESULT __stdcall DrawSetDisplayMode2(THIS, DWORD, DWORD,DWORD, DWORD, DWORD);
|
---|
130 | friend HRESULT __stdcall DrawWaitForVerticalBlank(THIS, DWORD, HANDLE);
|
---|
131 | // V2 Interface
|
---|
132 | friend HRESULT __stdcall DrawGetAvailableVidMem(THIS, LPDDSCAPS, LPDWORD, LPDWORD);
|
---|
133 | friend HRESULT __stdcall DrawGetAvailableVidMem4(THIS, LPDDSCAPS2, LPDWORD, LPDWORD);
|
---|
134 | // V4 Interface
|
---|
135 | friend HRESULT __stdcall GetSurfaceFromDC(THIS, HDC, LPDIRECTDRAWSURFACE4 *);
|
---|
136 | friend HRESULT __stdcall RestoreAllSurfaces(THIS) ;
|
---|
137 | friend HRESULT __stdcall TestCooperativeLevel(THIS) ;
|
---|
138 | friend HRESULT __stdcall GetDeviceIdentifier(THIS, LPDDDEVICEIDENTIFIER, DWORD );
|
---|
139 | /*** IDirect3D methods ***/
|
---|
140 | friend HRESULT __stdcall D3DQueryInterface(THIS, REFIID riid, LPVOID * ppvObj);
|
---|
141 | friend ULONG __stdcall D3DAddRef(THIS);
|
---|
142 | friend ULONG __stdcall D3DRelease(THIS);
|
---|
143 | friend HRESULT __stdcall D3DInitialize(THIS, REFIID);
|
---|
144 | friend HRESULT __stdcall D3DEnumDevices(THIS, LPD3DENUMDEVICESCALLBACK, LPVOID);
|
---|
145 | friend HRESULT __stdcall D3DCreateLight(THIS, LPDIRECT3DLIGHT*, IUnknown*);
|
---|
146 | friend HRESULT __stdcall D3DCreateMaterial(THIS, LPDIRECT3DMATERIAL*, IUnknown*);
|
---|
147 | friend HRESULT __stdcall D3DCreateViewport(THIS, LPDIRECT3DVIEWPORT*, IUnknown*);
|
---|
148 | friend HRESULT __stdcall D3DFindDevice(THIS, LPD3DFINDDEVICESEARCH, LPD3DFINDDEVICERESULT);
|
---|
149 |
|
---|
150 | };
|
---|
151 |
|
---|
152 | #define OFFSET_D3DVTABLE (LONG)(&((OS2IDirectDraw *)NULL)->lpVtbl3D)
|
---|
153 | #define DDraw3D_GetThisPtr(a) (OS2IDirectDraw *)((ULONG)a-OFFSET_D3DVTABLE)
|
---|
154 |
|
---|
155 | //******************************************************************************
|
---|
156 | HRESULT __stdcall DrawQueryInterface(THIS, REFIID riid, LPVOID * ppvObj);
|
---|
157 | ULONG __stdcall DrawAddRef(THIS);
|
---|
158 | ULONG __stdcall DrawRelease(THIS);
|
---|
159 | HRESULT __stdcall DrawCompact(THIS);
|
---|
160 | HRESULT __stdcall DrawCreateClipper(THIS, DWORD, LPDIRECTDRAWCLIPPER *, IUnknown * );
|
---|
161 | HRESULT __stdcall DrawCreatePalette(THIS, DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE *, IUnknown * );
|
---|
162 | HRESULT __stdcall DrawCreateSurface(THIS, LPDDSURFACEDESC, LPDIRECTDRAWSURFACE *, IUnknown *);
|
---|
163 | HRESULT __stdcall DrawDuplicateSurface(THIS, LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE * );
|
---|
164 | HRESULT __stdcall DrawEnumDisplayModes(THIS, DWORD, LPDDSURFACEDESC, LPVOID, LPDDENUMMODESCALLBACK );
|
---|
165 | HRESULT __stdcall DrawEnumSurfaces(THIS, DWORD, LPDDSURFACEDESC, LPVOID,LPDDENUMSURFACESCALLBACK );
|
---|
166 | HRESULT __stdcall DrawFlipToGDISurface(THIS);
|
---|
167 | HRESULT __stdcall DrawGetCaps(THIS, LPDDCAPS, LPDDCAPS);
|
---|
168 | HRESULT __stdcall DrawGetDisplayMode(THIS, LPDDSURFACEDESC);
|
---|
169 | HRESULT __stdcall DrawGetFourCCCodes(THIS, LPDWORD, LPDWORD);
|
---|
170 | HRESULT __stdcall DrawGetGDISurface(THIS, LPDIRECTDRAWSURFACE *);
|
---|
171 | HRESULT __stdcall DrawGetMonitorFrequency(THIS, LPDWORD);
|
---|
172 | HRESULT __stdcall DrawGetScanLine(THIS, LPDWORD);
|
---|
173 | HRESULT __stdcall DrawGetVerticalBlankStatus(THIS, LPBOOL);
|
---|
174 | HRESULT __stdcall DrawInitialize(THIS, GUID *);
|
---|
175 | HRESULT __stdcall DrawRestoreDisplayMode(THIS);
|
---|
176 | HRESULT __stdcall DrawSetCooperativeLevel(THIS, HWND, DWORD);
|
---|
177 | HRESULT __stdcall DrawSetDisplayMode(THIS, DWORD, DWORD,DWORD);
|
---|
178 | HRESULT __stdcall DrawSetDisplayMode2(THIS, DWORD, DWORD,DWORD, DWORD, DWORD);
|
---|
179 | HRESULT __stdcall DrawWaitForVerticalBlank(THIS, DWORD, HANDLE);
|
---|
180 | // V2
|
---|
181 | HRESULT __stdcall DrawGetAvailableVidMem(THIS, LPDDSCAPS, LPDWORD, LPDWORD);
|
---|
182 | // V4
|
---|
183 | HRESULT __stdcall DrawGetSurfaceFromDC(THIS, HDC, LPDIRECTDRAWSURFACE4 *);
|
---|
184 | HRESULT __stdcall DrawRestoreAllSurfaces(THIS) ;
|
---|
185 | HRESULT __stdcall DrawTestCooperativeLevel(THIS) ;
|
---|
186 | HRESULT __stdcall DrawGetDeviceIdentifier(THIS, LPDDDEVICEIDENTIFIER, DWORD );
|
---|
187 | // functions which ifaces are changed in DirectX6 after all MS uses COM where an programmer
|
---|
188 | // isn't allowd to change a function iface after he published the iface (See MS COM docs!)
|
---|
189 | HRESULT __stdcall DrawCreateSurface4(THIS, LPDDSURFACEDESC2, LPDIRECTDRAWSURFACE4 *, IUnknown *);
|
---|
190 | HRESULT __stdcall DrawDuplicateSurface4(THIS, LPDIRECTDRAWSURFACE4, LPDIRECTDRAWSURFACE4 * );
|
---|
191 | HRESULT __stdcall DrawEnumDisplayModes4(THIS, DWORD, LPDDSURFACEDESC2, LPVOID, LPDDENUMMODESCALLBACK2 );
|
---|
192 | HRESULT __stdcall DrawEnumSurfaces4(THIS, DWORD, LPDDSURFACEDESC2, LPVOID,LPDDENUMSURFACESCALLBACK2 );
|
---|
193 | HRESULT __stdcall DrawGetDisplayMode4(THIS, LPDDSURFACEDESC2);
|
---|
194 | HRESULT __stdcall DrawGetGDISurface4(THIS, LPDIRECTDRAWSURFACE4 *);
|
---|
195 | HRESULT __stdcall DrawGetAvailableVidMem4(THIS, LPDDSCAPS2, LPDWORD, LPDWORD);
|
---|
196 |
|
---|
197 | /*** IDirect3D methods ***/
|
---|
198 | HRESULT __stdcall D3DQueryInterface(THIS, REFIID riid, LPVOID * ppvObj);
|
---|
199 | ULONG __stdcall D3DAddRef(THIS);
|
---|
200 | ULONG __stdcall D3DRelease(THIS);
|
---|
201 | HRESULT __stdcall D3DInitialize(THIS, REFIID);
|
---|
202 | HRESULT __stdcall D3DEnumDevices(THIS, LPD3DENUMDEVICESCALLBACK, LPVOID);
|
---|
203 | HRESULT __stdcall D3DCreateLight(THIS, LPDIRECT3DLIGHT*, IUnknown*);
|
---|
204 | HRESULT __stdcall D3DCreateMaterial(THIS, LPDIRECT3DMATERIAL*, IUnknown*);
|
---|
205 | HRESULT __stdcall D3DCreateViewport(THIS, LPDIRECT3DVIEWPORT*, IUnknown*);
|
---|
206 | HRESULT __stdcall D3DFindDevice(THIS, LPD3DFINDDEVICESEARCH, LPD3DFINDDEVICERESULT);
|
---|
207 |
|
---|
208 | #define FOURCC_YUY2 mmioFOURCC( 'Y', 'U', 'Y', '2' )
|
---|
209 | #define FOURCC_UYVY mmioFOURCC( 'U', 'Y', 'V', 'Y' )
|
---|
210 |
|
---|
211 | #endif
|
---|