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