source: trunk/src/ddraw/OS2DDRAW.H@ 6502

Last change on this file since 6502 was 5326, checked in by mike, 24 years ago

Merged DDRAW and DDRAW\NEW

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