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

Last change on this file since 2012 was 913, checked in by hugh, 26 years ago

Changess in basic implementation of the IDrectDraw class
MS does assume 2 Vtables at the end and MS tools seam to use internal
knownledge of the implmentation. DDCAPS is one butn thsi does work/start now.

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