ReactOS  0.4.13-dev-563-g0561610
rosdraw.h
Go to the documentation of this file.
1 #pragma once
2 
3 /********* Includes *********/
4 #include <windows.h>
5 #include <stdio.h>
6 #include <ddraw.h>
7 #include <ddrawi.h>
8 #include <d3dhal.h>
9 #include <ddrawgdi.h>
10 #include <pseh/pseh.h>
11 
12 #include <pseh/pseh2.h>
13 
14 #include "Ddraw/ddraw.h"
15 #include "Surface/surface.h"
16 #include "Clipper/clipper.h"
17 
18 #include "resource.h"
19 
20 /* DirectDraw startup code only internal use */
23 extern WCHAR classname[128];
24 extern WNDCLASSW wnd_class;
25 extern CRITICAL_SECTION ddcs;
26 extern IDirectDraw7Vtbl DirectDraw7_Vtable;
27 extern IDirectDraw4Vtbl DirectDraw4_Vtable;
28 extern IDirectDraw2Vtbl DirectDraw2_Vtable;
29 extern IDirectDrawVtbl DirectDraw_Vtable;
30 
31 
32 extern IDirectDrawSurface7Vtbl DirectDrawSurface7_Vtable;
33 extern IDirectDrawSurface4Vtbl DirectDrawSurface4_Vtable;
34 extern IDirectDrawSurface3Vtbl DirectDrawSurface3_Vtable;
35 extern IDirectDrawSurface2Vtbl DirectDrawSurface2_Vtable;
36 extern IDirectDrawSurfaceVtbl DirectDrawSurface_Vtable;
37 extern const IDirectDrawPaletteVtbl DirectDrawPalette_Vtable;
38 extern IDirectDrawClipperVtbl DirectDrawClipper_Vtable;
39 extern IDirectDrawColorControlVtbl DirectDrawColorControl_Vtable;
40 extern IDirectDrawGammaControlVtbl DirectDrawGammaControl_Vtable;
41 extern IDirectDrawKernelVtbl DirectDrawKernel_Vtable;
42 extern IDirectDrawSurfaceKernelVtbl DirectDrawSurfaceKernel_Vtable;
43 
44 extern IDirect3DVtbl IDirect3D_Vtbl;
45 extern IDirect3D2Vtbl IDirect3D2_Vtbl;
46 extern IDirect3D3Vtbl IDirect3D3_Vtbl;
47 extern IDirect3D7Vtbl IDirect3D7_Vtbl;
48 
49 /* Start up direct hal or hel
50  * iface = a pointer to the com object
51  * pGUID = guid hardware accelerations or software acceleration this can be NULL
52  * reenable = FALSE if we whant create a new directdraw com
53  * = TRUE if we really whant rebuild the whole com interface (not in use)
54  */
55 
58  LPDIRECTDRAW iface,
59  LPGUID pGUID,
60  BOOL reenable);
61 
62 /* iface = a pointer to the com object
63  * reenable = FALSE / TRUE rebuld dx hal interface, this is need if we doing a mode change
64  */
65 
68  LPDIRECTDRAW iface,
69  BOOL reenable);
70 
71 /* iface = a pointer to the com object
72  * reenable = FALSE / TRUE rebuld dx hel interface, this is need if we doing a mode change
73  */
74 
77  LPDIRECTDRAW iface,
78  BOOL reenable);
79 
82  LPGUID pGUID,
83  LPDIRECTDRAW* pIface,
84  REFIID id,
85  BOOL ex);
86 
89 HRESULT
92  LPDDSURFACEDESC2 pDDSD,
94  IUnknown *pUnkOuter);
95 
96 HRESULT
98  LPPALETTEENTRY palent, LPDIRECTDRAWPALETTE* ppPalette, LPUNKNOWN pUnkOuter);
99 
100 /* convert DDSURFACEDESC to DDSURFACEDESC2 */
102 
103 /* DirectDraw Cleanup code only internal use */
105 
106 /* own macro to alloc memory */
107 
108 /*
109 #define DxHeapMemAlloc(m) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, m)
110 #define DxHeapMemFree(p) HeapFree(GetProcessHeap(), 0, p); \
111  p = NULL;
112 */
113 #define DxHeapMemAlloc(p, m) { \
114  p = malloc(m); \
115  if (p != NULL) \
116  { \
117  ZeroMemory(p,m); \
118  } \
119  }
120 #define DxHeapMemFree(p) { \
121  free(p); \
122  p = NULL; \
123  }
124 
125 /******** Main Object ********/
126 
127 /* Public interface */
130 
133 
135 {
141 
143 {
149 
150 typedef struct _DDRAWI_DDKERNEL_INT
151 {
157 
159 {
165 
166 /* now to real info that are for private use and are our own */
167 
168 
169 
170 
171 
172 
173 
174 
175 /********* Prototypes **********/
177 
178 /* Setting for HEL should be move to ros special reg key ? */
179 
180 /* setup how much graphic memory should hel be limit, set it now to 64MB */
181 #define HEL_GRAPHIC_MEMORY_MAX 67108864
182 
183 /*********** Macros ***********/
184 
185 /*
186  use this macro to close
187  down the debugger text complete
188  no debuging at all, it will
189  crash ms debugger in VS
190 */
191 
192 //#define DX_WINDBG_trace()
193 //#define DX_STUB
194 //#define DX_STUB_DD_OK return DD_OK;
195 //#define DX_STUB_str(x)
196 //#define DX_WINDBG_trace_res
197 
198 
199 /*
200  Use this macro if you want debug in visual studio or
201  if you have a program to look at the _INT struct from
202  ReactOS ddraw.dll or ms ddraw.dll, so you can see what
203  value ms are being setup.
204 
205  This macro will create allot warnings and can not be help when you compile
206 */
207 
208 
209 //#define DX_WINDBG_trace()
210 //#define DX_STUB
211 //#define DX_STUB_DD_OK return DD_OK;
212 //#define DX_STUB_str(x) printf("%s",x);
213 //#define DX_WINDBG_trace_res
214 
215 /*
216  use this if want doing a trace from a program
217  like a game and ReactOS ddraw.dll in windows
218  so you can figout what going wrong and what
219  api are being call or if it hel or is it hal
220 
221  This marco does not create warnings when you compile
222 */
223 
224 #define DX_STUB \
225 { \
226  static BOOL firstcall = TRUE; \
227  if (firstcall) \
228  { \
229  char buffer[1024]; \
230  sprintf ( buffer, "Function %s is not implemented yet (%s:%d)\n", __FUNCTION__,__FILE__,__LINE__ ); \
231  OutputDebugStringA(buffer); \
232  firstcall = FALSE; \
233  } \
234 } \
235  return DDERR_UNSUPPORTED;
236 
237 
238 
239 #define DX_STUB_DD_OK \
240 { \
241  static BOOL firstcall = TRUE; \
242  if (firstcall) \
243  { \
244  char buffer[1024]; \
245  sprintf ( buffer, "Function %s is not implemented yet (%s:%d)\n", __FUNCTION__,__FILE__,__LINE__ ); \
246  OutputDebugStringA(buffer); \
247  firstcall = FALSE; \
248  } \
249 } \
250  return DD_OK;
251 
252 
253 #if 1
254  #define DX_STUB_str(x) \
255  { \
256  char buffer[1024]; \
257  sprintf ( buffer, "Function %s %s (%s:%d)\n", __FUNCTION__,x,__FILE__,__LINE__ ); \
258  OutputDebugStringA(buffer); \
259  }
260 
261 
262  #define DX_WINDBG_trace() \
263  static BOOL firstcallx = TRUE; \
264  if (firstcallx) \
265  { \
266  char buffer[1024]; \
267  sprintf ( buffer, "Enter Function %s (%s:%d)\n", __FUNCTION__,__FILE__,__LINE__ ); \
268  OutputDebugStringA(buffer); \
269  firstcallx = TRUE; \
270  }
271 
272 
273 #define DX_WINDBG_trace_res(width,height,bpp, freq) \
274  static BOOL firstcallxx = TRUE; \
275  if (firstcallxx) \
276  { \
277  char buffer[1024]; \
278  sprintf ( buffer, "Setmode have been req width=%ld, height=%ld bpp=%ld freq = %ld\n",width,height,bpp, freq); \
279  OutputDebugStringA(buffer); \
280  firstcallxx = TRUE; \
281  }
282 #else
283  #define DX_WINDBG_trace() //
284  #define DX_WINDBG_trace_res(width,height,bpp, freq) \\
285 
286  #define DX_STUB_str(x) //
287 
288 #endif
IDirectDrawSurfaceKernelVtbl DirectDrawSurfaceKernel_Vtable
Definition: kernel_stubs.c:123
struct DDRAWI_DDCOLORCONTROL_INT DDRAWI_DDCOLORCONTROL_INT
HRESULT Internal_CreatePalette(LPDDRAWI_DIRECTDRAW_INT pDDraw, DWORD dwFlags, LPPALETTEENTRY palent, LPDIRECTDRAWPALETTE *ppPalette, LPUNKNOWN pUnkOuter)
Definition: createpalette.c:33
struct _DDRAWI_DDKERNELSURFACE_INT * LPDDRAWI_DDKERNELSURFACE_INT
#define REFIID
Definition: guiddef.h:113
Definition: comerr.c:44
struct _DDRAWI_DDGAMMACONTROL_INT * LPDDRAWI_DDGAMMACONTROL_INT
IDirectDrawVtbl DirectDraw_Vtable
Definition: ddraw_thunk.c:835
struct _DDRAWI_DDKERNEL_INT DDRAWI_KERNEL_INT
IDirectDrawColorControlVtbl DirectDrawColorControl_Vtable
Definition: color_stubs.c:58
CRITICAL_SECTION ddcs
Definition: main.c:14
HRESULT WINAPI StartDirectDrawHal(LPDIRECTDRAW iface, BOOL reenable)
Definition: startup.c:458
struct _DDRAWI_DDKERNEL_INT * LPDDRAWI_KERNEL_INT
struct _DDRAWI_DDGAMMACONTROL_INT DDRAWI_DDGAMMACONTROL_INT
IDirectDrawSurface2Vtbl DirectDrawSurface2_Vtable
WCHAR classname[128]
Definition: startup.c:15
const IDirectDrawPaletteVtbl DirectDrawPalette_Vtable
Definition: palette.c:147
IDirectDraw2Vtbl DirectDraw2_Vtable
Definition: ddraw_thunk.c:862
HRESULT Internal_CreateSurface(LPDDRAWI_DIRECTDRAW_INT pDDraw, LPDDSURFACEDESC2 pDDSD, LPDDRAWI_DDRAWSURFACE_INT *ppSurf, IUnknown *pUnkOuter)
Definition: createsurface.c:18
IDirectDraw4Vtbl DirectDraw4_Vtable
Definition: ddraw_thunk.c:890
HRESULT WINAPI StartDirectDrawHel(LPDIRECTDRAW iface, BOOL reenable)
Definition: startup.c:368
unsigned int BOOL
Definition: ntddk_ex.h:94
DDRAWI_DDRAWSURFACE_GBL ddSurfGbl
Definition: startup.c:13
static LPUNKNOWN
Definition: ndr_ole.c:49
IDirectDrawSurface4Vtbl DirectDrawSurface4_Vtable
DDRAWI_DIRECTDRAW_GBL ddgbl
Definition: startup.c:12
struct IDirectDraw * LPDIRECTDRAW
Definition: ddraw.h:710
struct _DDRAWI_DDKERNELSURFACE_INT _DDRAWI_DDKERNELSURFACE_INT
HRESULT WINAPI Create_DirectDraw(LPGUID pGUID, LPDIRECTDRAW *pIface, REFIID id, BOOL ex)
Definition: startup.c:20
struct DDRAWI_DDCOLORCONTROL_INT * LPDDRAWI_DDCOLORCONTROL_INT
IDirect3D2Vtbl IDirect3D2_Vtbl
IDirectDrawSurface3Vtbl DirectDrawSurface3_Vtable
IDirectDrawSurfaceVtbl DirectDrawSurface_Vtable
__wchar_t WCHAR
Definition: xmlstorage.h:180
IDirect3D7Vtbl IDirect3D7_Vtbl
LONG HRESULT
Definition: typedefs.h:77
VOID WINAPI AcquireDDThreadLock(VOID)
#define WINAPI
Definition: msvc.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT WINAPI ReCreateDirectDraw(LPDIRECTDRAW iface)
HRESULT WINAPI StartDirectDraw(LPDIRECTDRAW iface, LPGUID pGUID, BOOL reenable)
Definition: startup.c:180
HRESULT WINAPI DirectDrawClipper_Initialize(LPDIRECTDRAWCLIPPER iface, LPDIRECTDRAW lpDD, DWORD dwFlags)
Definition: clipper_main.c:23
VOID WINAPI ReleaseDDThreadLock(VOID)
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
VOID Cleanup(LPDDRAWI_DIRECTDRAW_INT iface)
Definition: cleanup.c:15
IDirect3DVtbl IDirect3D_Vtbl
IDirectDrawSurface7Vtbl DirectDrawSurface7_Vtable
VOID Hal_DirectDraw_Release(LPDIRECTDRAW7)
struct IDirectDrawClipper * LPDIRECTDRAWCLIPPER
Definition: ddraw.h:721
void CopyDDSurfDescToDDSurfDesc2(LPDDSURFACEDESC2 dst_pDesc, LPDDSURFACEDESC src_pDesc)
IDirectDrawClipperVtbl DirectDrawClipper_Vtable
Definition: clipper_main.c:131
IDirectDrawKernelVtbl DirectDrawKernel_Vtable
Definition: kernel_stubs.c:114
DWORD * LPDIRECTDRAW7
Definition: vmrender.idl:4
ULONG WINAPI DirectDrawClipper_AddRef(LPDIRECTDRAWCLIPPER iface)
Definition: clipper_main.c:75
unsigned int ULONG
Definition: retypes.h:1
IDirectDraw7Vtbl DirectDraw7_Vtable
IDirectDrawGammaControlVtbl DirectDrawGammaControl_Vtable
Definition: gamma_stubs.c:60
WNDCLASSW wnd_class
Definition: startup.c:16
struct IDirectDrawPalette * LPDIRECTDRAWPALETTE
Definition: ddraw.h:720
IDirect3D3Vtbl IDirect3D3_Vtbl