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

Last change on this file since 2912 was 2174, checked in by hugh, 26 years ago

Added ODIn lic header with ID to all files where missing

Cleaned up Surface handling by movefing colorfill and
colorconversion into own files and use functionpointers
setup during creation.

updated makefile to add files

removed inhertiance from IBASE in DDrectangle class

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