- Fix compilation again using olders GL headers
[wine] / dlls / d3d8 / d3d8_private.h
1 /*
2  * Direct3D 8 private include file
3  *
4  * Copyright 2002-2004 Jason Edmeades
5  * Copyright 2003-2004 Raphael Junqueira
6  * Copyright 2004 Christian Costa
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #ifndef __WINE_D3D8_PRIVATE_H
24 #define __WINE_D3D8_PRIVATE_H
25
26 #ifndef __WINE_CONFIG_H
27 # error You must include config.h to use this header
28 #endif
29
30 /* THIS FILE MUST NOT CONTAIN X11 or MESA DEFINES */
31 #define XMD_H /* This is to prevent the Xmd.h inclusion bug :-/ */
32 #include <GL/gl.h>
33 #define GLX_GLXEXT_PROTOTYPES
34 #include <GL/glx.h>
35 #ifdef HAVE_GL_GLEXT_H
36 # include <GL/glext.h>
37 #endif
38 #undef  XMD_H
39
40 #undef APIENTRY
41 #undef CALLBACK
42 #undef WINAPI
43
44 /* Redefines the constants */
45 #define CALLBACK    __stdcall
46 #define WINAPI      __stdcall
47 #define APIENTRY    WINAPI
48
49 /* X11 locking */
50
51 extern void (*wine_tsx11_lock_ptr)(void);
52 extern void (*wine_tsx11_unlock_ptr)(void);
53
54 /* As GLX relies on X, this is needed */
55 extern int num_lock;
56 #if 0
57 #define ENTER_GL() ++num_lock; TRACE("inc lock to: %d\n", num_lock); wine_tsx11_lock_ptr()
58 #define LEAVE_GL() if (num_lock > 2) TRACE("fucking locks: %d\n", num_lock); --num_lock; wine_tsx11_unlock_ptr()
59 #else
60 #define ENTER_GL() wine_tsx11_lock_ptr()
61 #define LEAVE_GL() wine_tsx11_unlock_ptr()
62 #endif
63
64 #include <stdarg.h>
65
66 #include "windef.h"
67 #include "winbase.h"
68 #include "d3d8.h"
69
70 extern int vs_mode;
71 #define VS_NONE 0
72 #define VS_HW   1
73 #define VS_SW   2
74
75 /* Device caps */
76 #define MAX_PALETTES      256
77 #define MAX_STREAMS       16
78 #define MAX_CLIPPLANES    D3DMAXUSERCLIPPLANES
79 #define MAX_LEVELS        256
80
81 /* Other useful values */
82 #define HIGHEST_RENDER_STATE 174
83 #define HIGHEST_TEXTURE_STATE 29
84 #define HIGHEST_TRANSFORMSTATE 512
85 #define D3DSBT_RECORDED 0xfffffffe
86
87 /* Performance changes - Only reapply what is necessary */
88 #define REAPPLY_ALPHAOP  0x0001
89 #define REAPPLY_ALL      0xFFFF
90
91 /* CreateVertexShader can return > 0xFFFF */
92 #define VS_HIGHESTFIXEDFXF 0xF0000000
93 #define VERTEX_SHADER(Handle) \
94   ((Handle <= VS_HIGHESTFIXEDFXF) ? ((Handle >= sizeof(VertexShaders) / sizeof(IDirect3DVertexShaderImpl*)) ? NULL : VertexShaders[Handle]) : VertexShaders[Handle - VS_HIGHESTFIXEDFXF])
95 #define VERTEX_SHADER_DECL(Handle) \
96   ((Handle <= VS_HIGHESTFIXEDFXF) ? ((Handle >= sizeof(VertexShaderDeclarations) / sizeof(IDirect3DVertexShaderDeclarationImpl*)) ? NULL : VertexShaderDeclarations[Handle]) : VertexShaderDeclarations[Handle - VS_HIGHESTFIXEDFXF])
97 #define PIXEL_SHADER(Handle) \
98   ((Handle <= VS_HIGHESTFIXEDFXF) ? ((Handle >= sizeof(PixelShaders) / sizeof(IDirect3DPixelShaderImpl*)) ? NULL : PixelShaders[Handle]) : PixelShaders[Handle - VS_HIGHESTFIXEDFXF])
99
100 /* Direct3D8 Interfaces: */
101 typedef struct IDirect3DBaseTexture8Impl IDirect3DBaseTexture8Impl;
102 typedef struct IDirect3DVolumeTexture8Impl IDirect3DVolumeTexture8Impl;
103 typedef struct IDirect3D8Impl IDirect3D8Impl;
104 typedef struct IDirect3DDevice8Impl IDirect3DDevice8Impl;
105 typedef struct IDirect3DTexture8Impl IDirect3DTexture8Impl;
106 typedef struct IDirect3DCubeTexture8Impl IDirect3DCubeTexture8Impl;
107 typedef struct IDirect3DIndexBuffer8Impl IDirect3DIndexBuffer8Impl;
108 typedef struct IDirect3DSurface8Impl IDirect3DSurface8Impl;
109 typedef struct IDirect3DSwapChain8Impl IDirect3DSwapChain8Impl;
110 typedef struct IDirect3DResource8Impl IDirect3DResource8Impl;
111 typedef struct IDirect3DVolume8Impl IDirect3DVolume8Impl;
112 typedef struct IDirect3DVertexBuffer8Impl IDirect3DVertexBuffer8Impl;
113
114 /** Private Interfaces: */
115 typedef struct IDirect3DStateBlockImpl IDirect3DStateBlockImpl;
116 typedef struct IDirect3DVertexShaderImpl IDirect3DVertexShaderImpl;
117 typedef struct IDirect3DPixelShaderImpl IDirect3DPixelShaderImpl;
118 typedef struct IDirect3DVertexShaderDeclarationImpl IDirect3DVertexShaderDeclarationImpl;
119
120 typedef struct D3DSHADERVECTOR {
121   float x;
122   float y;
123   float z;
124   float w;
125 } D3DSHADERVECTOR;
126
127 typedef struct D3DSHADERSCALAR {
128   float x;
129 } D3DSHADERSCALAR;
130
131 #define D3D8_VSHADER_MAX_CONSTANTS 96
132 typedef D3DSHADERVECTOR VSHADERCONSTANTS8[D3D8_VSHADER_MAX_CONSTANTS];
133
134 typedef struct VSHADERDATA8 {
135   /** Run Time Shader Function Constants */
136   /*D3DXBUFFER* constants;*/
137   VSHADERCONSTANTS8 C;
138   /** Shader Code as char ... */
139   CONST DWORD* code;
140   UINT codeLength;
141 } VSHADERDATA8;
142
143 /** temporary here waiting for buffer code */
144 typedef struct VSHADERINPUTDATA8 {
145   D3DSHADERVECTOR V[17];
146 } VSHADERINPUTDATA8;
147
148 /** temporary here waiting for buffer code */
149 typedef struct VSHADEROUTPUTDATA8 {
150   D3DSHADERVECTOR oPos;
151   D3DSHADERVECTOR oD[2];
152   D3DSHADERVECTOR oT[8];
153   D3DSHADERVECTOR oFog;
154   D3DSHADERVECTOR oPts;
155 } VSHADEROUTPUTDATA8;
156
157
158 #define D3D8_PSHADER_MAX_CONSTANTS 32
159 typedef D3DSHADERVECTOR PSHADERCONSTANTS8[D3D8_PSHADER_MAX_CONSTANTS];
160
161 typedef struct PSHADERDATA8 {
162   /** Run Time Shader Function Constants */
163   /*D3DXBUFFER* constants;*/
164   PSHADERCONSTANTS8 C;
165   /** Shader Code as char ... */
166   CONST DWORD* code;
167   UINT codeLength;
168 } PSHADERDATA8;
169
170 /** temporary here waiting for buffer code */
171 typedef struct PSHADERINPUTDATA8 {
172   D3DSHADERVECTOR V[2];
173   D3DSHADERVECTOR T[8];
174   D3DSHADERVECTOR S[16];
175   /*D3DSHADERVECTOR R[12];*/
176 } PSHADERINPUTDATA8;
177
178 /** temporary here waiting for buffer code */
179 typedef struct PSHADEROUTPUTDATA8 {
180   D3DSHADERVECTOR oC[4];
181   D3DSHADERVECTOR oDepth;
182 } PSHADEROUTPUTDATA8;
183
184 /* 
185  * Private definitions for internal use only
186  */
187 typedef struct PLIGHTINFOEL PLIGHTINFOEL;
188 struct PLIGHTINFOEL {
189     D3DLIGHT8 OriginalParms;
190     DWORD     OriginalIndex;
191     LONG      glIndex;
192     BOOL      lightEnabled;
193     BOOL      changed;
194     BOOL      enabledChanged;
195
196     /* Converted parms to speed up swapping lights */
197     float                         lightPosn[4];
198     float                         lightDirn[4];
199     float                         exponent;
200     float                         cutoff;
201
202     PLIGHTINFOEL *next;
203     PLIGHTINFOEL *prev;
204 };
205
206 /*
207  * Macros
208  */
209 #define checkGLcall(A) \
210 { \
211     GLint err = glGetError();   \
212     if (err != GL_NO_ERROR) { \
213        FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", err, A, __FILE__, __LINE__); \
214     } else { \
215        TRACE("%s call ok %s / %d\n", A, __FILE__, __LINE__); \
216     } \
217 }
218 #define vcheckGLcall(A) \
219 { \
220     GLint err = glGetError();   \
221     if (err != GL_NO_ERROR) { \
222        FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", err, A, __FILE__, __LINE__); \
223     } else { \
224        VTRACE(("%s call ok %s / %d\n", A, __FILE__, __LINE__)); \
225     } \
226 }
227
228 #include "d3dcore_gl.h"
229
230
231 #define GL_LIMITS(ExtName)            (This->direct3d8->gl_info.max_##ExtName)
232 #define GL_SUPPORT(ExtName)           (TRUE == This->direct3d8->gl_info.supported[ExtName])
233 #define GL_SUPPORT_DEV(ExtName, dev)  (TRUE == (dev)->direct3d8->gl_info.supported[ExtName])
234 #define GL_EXTCALL(FuncName)          (This->direct3d8->gl_info.FuncName)
235 #define GL_EXTCALL_DEV(FuncName, dev) ((dev)->direct3d8->gl_info.FuncName)
236
237
238 #define D3DCOLOR_R(dw) (((float) (((dw) >> 16) & 0xFF)) / 255.0f)
239 #define D3DCOLOR_G(dw) (((float) (((dw) >>  8) & 0xFF)) / 255.0f)
240 #define D3DCOLOR_B(dw) (((float) (((dw) >>  0) & 0xFF)) / 255.0f)
241 #define D3DCOLOR_A(dw) (((float) (((dw) >> 24) & 0xFF)) / 255.0f)
242
243 #define D3DCOLORTOCOLORVALUE(dw, col) \
244   (col).r = D3DCOLOR_R(dw); \
245   (col).g = D3DCOLOR_G(dw); \
246   (col).b = D3DCOLOR_B(dw); \
247   (col).a = D3DCOLOR_A(dw); 
248
249 #define D3DCOLORTOVECTOR4(dw, vec) \
250   (vec).x = D3DCOLOR_R(dw); \
251   (vec).y = D3DCOLOR_G(dw); \
252   (vec).z = D3DCOLOR_B(dw); \
253   (vec).w = D3DCOLOR_A(dw);
254
255 #define D3DCOLORTOGLFLOAT4(dw, vec) \
256   (vec)[0] = D3DCOLOR_R(dw); \
257   (vec)[1] = D3DCOLOR_G(dw); \
258   (vec)[2] = D3DCOLOR_B(dw); \
259   (vec)[3] = D3DCOLOR_A(dw);
260
261 /* ===========================================================================
262     The interfactes themselves
263    =========================================================================== */
264
265 /* ---------- */
266 /* IDirect3D8 */
267 /* ---------- */
268
269 /*****************************************************************************
270  * Predeclare the interface implementation structures
271  */
272 extern ICOM_VTABLE(IDirect3D8) Direct3D8_Vtbl;
273
274 /*****************************************************************************
275  * IDirect3D implementation structure
276  */
277 struct IDirect3D8Impl
278 {
279     /* IUnknown fields */
280     ICOM_VFIELD(IDirect3D8);
281     DWORD                   ref;
282
283     /* IDirect3D8 fields */
284     GL_Info                 gl_info;
285     BOOL                    isGLInfoValid;
286     IDirect3D8Impl         *direct3d8;
287 };
288
289 /* IUnknown: */
290 extern HRESULT WINAPI   IDirect3D8Impl_QueryInterface(LPDIRECT3D8 iface,REFIID refiid,LPVOID *obj);
291 extern ULONG WINAPI     IDirect3D8Impl_AddRef(LPDIRECT3D8 iface);
292 extern ULONG WINAPI     IDirect3D8Impl_Release(LPDIRECT3D8 iface);
293
294 /* IDirect3d8: */
295 extern HRESULT  WINAPI  IDirect3D8Impl_RegisterSoftwareDevice(LPDIRECT3D8 iface, void* pInitializeFunction);
296 extern UINT     WINAPI  IDirect3D8Impl_GetAdapterCount(LPDIRECT3D8 iface);
297 extern HRESULT  WINAPI  IDirect3D8Impl_GetAdapterIdentifier(LPDIRECT3D8 iface, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER8* pIdentifier);
298 extern UINT     WINAPI  IDirect3D8Impl_GetAdapterModeCount(LPDIRECT3D8 iface, UINT Adapter);
299 extern HRESULT  WINAPI  IDirect3D8Impl_EnumAdapterModes(LPDIRECT3D8 iface, UINT Adapter, UINT Mode, D3DDISPLAYMODE* pMode);
300 extern HRESULT  WINAPI  IDirect3D8Impl_GetAdapterDisplayMode(LPDIRECT3D8 iface, UINT Adapter, D3DDISPLAYMODE* pMode);
301 extern HRESULT  WINAPI  IDirect3D8Impl_CheckDeviceType(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat,
302                                                        D3DFORMAT BackBufferFormat, BOOL Windowed);
303 extern HRESULT  WINAPI  IDirect3D8Impl_CheckDeviceFormat(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
304                                                        DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat);
305 extern HRESULT  WINAPI  IDirect3D8Impl_CheckDeviceMultiSampleType(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat,
306                                                        BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType);
307 extern HRESULT  WINAPI  IDirect3D8Impl_CheckDepthStencilMatch(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
308                                                        D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat);
309 extern HRESULT  WINAPI  IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS8* pCaps);
310 extern HMONITOR WINAPI  IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface, UINT Adapter);
311 extern HRESULT  WINAPI  IDirect3D8Impl_CreateDevice(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow,
312                                                     DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters,
313                                                     IDirect3DDevice8** ppReturnedDeviceInterface);
314
315 /* ---------------- */
316 /* IDirect3DDevice8 */
317 /* ---------------- */
318
319 /*****************************************************************************
320  * Predeclare the interface implementation structures
321  */
322 extern ICOM_VTABLE(IDirect3DDevice8) Direct3DDevice8_Vtbl;
323
324 /*****************************************************************************
325  * IDirect3DDevice8 implementation structure
326  */
327 struct IDirect3DDevice8Impl
328 {
329     /* IUnknown fields */
330     ICOM_VFIELD(IDirect3DDevice8);
331     DWORD                         ref;
332
333     /* IDirect3DDevice8 fields */
334     IDirect3D8Impl               *direct3d8;
335
336     IDirect3DSurface8Impl        *frontBuffer;
337     IDirect3DSurface8Impl        *backBuffer;
338     IDirect3DSurface8Impl        *depthStencilBuffer;
339
340     IDirect3DSurface8Impl        *renderTarget;
341     IDirect3DSurface8Impl        *stencilBufferTarget;
342
343     D3DPRESENT_PARAMETERS         PresentParms;
344     D3DDEVICE_CREATION_PARAMETERS CreateParms;
345
346     UINT                          adapterNo;
347     D3DDEVTYPE                    devType;
348
349     UINT                          srcBlend;
350     UINT                          dstBlend;
351     UINT                          alphafunc;
352     UINT                          stencilfunc;
353
354     /* State block related */
355     BOOL                          isRecordingState;
356     IDirect3DStateBlockImpl      *StateBlock;
357     IDirect3DStateBlockImpl      *UpdateStateBlock;
358
359     /* palettes texture management */
360     PALETTEENTRY                  palettes[MAX_PALETTES][256];
361     UINT                          currentPalette;
362
363     BOOL                          texture_shader_active;
364
365     /* Optimization */
366     BOOL                          modelview_valid;
367     BOOL                          proj_valid;
368     BOOL                          view_ident;        /* true iff view matrix is identity                */
369     BOOL                          last_was_rhw;      /* true iff last draw_primitive was in xyzrhw mode */
370     GLenum                        tracking_parm;     /* Which source is tracking current colour         */
371     LONG                          tracking_color;    /* used iff GL_COLOR_MATERIAL was enabled          */
372       #define                         DISABLED_TRACKING  0  /* Disabled                                 */
373       #define                         IS_TRACKING        1  /* tracking_parm is tracking diffuse color  */
374       #define                         NEEDS_TRACKING     2  /* Tracking needs to be enabled when needed */
375       #define                         NEEDS_DISABLE      3  /* Tracking needs to be disabled when needed*/
376
377     /* OpenGL related */
378     GLXContext                    glCtx;
379     XVisualInfo                  *visInfo;
380     Display                      *display;
381     HWND                          win_handle;
382     Window                        win;
383     GLXContext                    render_ctx;
384     Drawable                      drawable;
385     GLint                         maxConcurrentLights;
386
387     /* OpenGL Extension related */
388
389     /* Cursor management */
390     BOOL                          bCursorVisible;
391     UINT                          xHotSpot;
392     UINT                          yHotSpot;
393     UINT                          xScreenSpace;
394     UINT                          yScreenSpace;
395     GLint                         cursor;
396
397     UINT                          dummyTextureName[8];
398
399     /* For rendering to a texture using glCopyTexImage */
400     BOOL                          renderUpsideDown;
401 };
402
403 /* IUnknown: */
404 extern HRESULT WINAPI   IDirect3DDevice8Impl_QueryInterface(LPDIRECT3DDEVICE8 iface, REFIID refiid, LPVOID *obj);
405 extern ULONG WINAPI     IDirect3DDevice8Impl_AddRef(LPDIRECT3DDEVICE8 iface);
406 extern ULONG WINAPI     IDirect3DDevice8Impl_Release(LPDIRECT3DDEVICE8 iface);
407
408 /* IDirect3DDevice8: */
409 extern HRESULT  WINAPI  IDirect3DDevice8Impl_TestCooperativeLevel(LPDIRECT3DDEVICE8 iface);
410 extern UINT     WINAPI  IDirect3DDevice8Impl_GetAvailableTextureMem(LPDIRECT3DDEVICE8 iface);
411 extern HRESULT  WINAPI  IDirect3DDevice8Impl_ResourceManagerDiscardBytes(LPDIRECT3DDEVICE8 iface, DWORD Bytes);
412 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetDirect3D(LPDIRECT3DDEVICE8 iface, IDirect3D8** ppD3D8);
413 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetDeviceCaps(LPDIRECT3DDEVICE8 iface, D3DCAPS8* pCaps);
414 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetDisplayMode(LPDIRECT3DDEVICE8 iface, D3DDISPLAYMODE* pMode);
415 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetCreationParameters(LPDIRECT3DDEVICE8 iface, D3DDEVICE_CREATION_PARAMETERS* pParameters);
416 extern HRESULT  WINAPI  IDirect3DDevice8Impl_SetCursorProperties(LPDIRECT3DDEVICE8 iface, UINT XHotSpot, UINT YHotSpot, IDirect3DSurface8* pCursorBitmap);
417 extern void     WINAPI  IDirect3DDevice8Impl_SetCursorPosition(LPDIRECT3DDEVICE8 iface, UINT XScreenSpace, UINT YScreenSpace, DWORD Flags);
418 extern BOOL     WINAPI  IDirect3DDevice8Impl_ShowCursor(LPDIRECT3DDEVICE8 iface, BOOL bShow);
419 extern HRESULT  WINAPI  IDirect3DDevice8Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE8 iface, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain8** pSwapChain);
420 extern HRESULT  WINAPI  IDirect3DDevice8Impl_Reset(LPDIRECT3DDEVICE8 iface, D3DPRESENT_PARAMETERS* pPresentationParameters);
421 extern HRESULT  WINAPI  IDirect3DDevice8Impl_Present(LPDIRECT3DDEVICE8 iface, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion);
422 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetBackBuffer(LPDIRECT3DDEVICE8 iface, UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface8** ppBackBuffer);
423 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetRasterStatus(LPDIRECT3DDEVICE8 iface, D3DRASTER_STATUS* pRasterStatus);
424 extern void     WINAPI  IDirect3DDevice8Impl_SetGammaRamp(LPDIRECT3DDEVICE8 iface, DWORD Flags, CONST D3DGAMMARAMP* pRamp);
425 extern void     WINAPI  IDirect3DDevice8Impl_GetGammaRamp(LPDIRECT3DDEVICE8 iface, D3DGAMMARAMP* pRamp);
426 extern HRESULT  WINAPI  IDirect3DDevice8Impl_CreateTexture(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture8** ppTexture);
427 extern HRESULT  WINAPI  IDirect3DDevice8Impl_CreateVolumeTexture(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture8** ppVolumeTexture);
428 extern HRESULT  WINAPI  IDirect3DDevice8Impl_CreateCubeTexture(LPDIRECT3DDEVICE8 iface, UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture8** ppCubeTexture);
429 extern HRESULT  WINAPI  IDirect3DDevice8Impl_CreateVertexBuffer(LPDIRECT3DDEVICE8 iface, UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer8** ppVertexBuffer);
430 extern HRESULT  WINAPI  IDirect3DDevice8Impl_CreateIndexBuffer(LPDIRECT3DDEVICE8 iface, UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer8** ppIndexBuffer);
431 extern HRESULT  WINAPI  IDirect3DDevice8Impl_CreateRenderTarget(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, BOOL Lockable, IDirect3DSurface8** ppSurface);
432 extern HRESULT  WINAPI  IDirect3DDevice8Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, IDirect3DSurface8** ppSurface);
433 extern HRESULT  WINAPI  IDirect3DDevice8Impl_CreateImageSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, IDirect3DSurface8** ppSurface);
434 extern HRESULT  WINAPI  IDirect3DDevice8Impl_CopyRects(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pSourceSurface, CONST RECT* pSourceRectsArray, UINT cRects, IDirect3DSurface8* pDestinationSurface, CONST POINT* pDestPointsArray);
435 extern HRESULT  WINAPI  IDirect3DDevice8Impl_UpdateTexture(LPDIRECT3DDEVICE8 iface, IDirect3DBaseTexture8* pSourceTexture, IDirect3DBaseTexture8* pDestinationTexture);
436 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetFrontBuffer(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pDestSurface);
437 extern HRESULT  WINAPI  IDirect3DDevice8Impl_SetRenderTarget(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pRenderTarget, IDirect3DSurface8* pNewZStencil);
438 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetRenderTarget(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8** ppRenderTarget);
439 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8** ppZStencilSurface);
440 extern HRESULT  WINAPI  IDirect3DDevice8Impl_BeginScene(LPDIRECT3DDEVICE8 iface);
441 extern HRESULT  WINAPI  IDirect3DDevice8Impl_EndScene(LPDIRECT3DDEVICE8 iface);
442 extern HRESULT  WINAPI  IDirect3DDevice8Impl_Clear(LPDIRECT3DDEVICE8 iface, DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil);
443 extern HRESULT  WINAPI  IDirect3DDevice8Impl_SetTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix);
444 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix);
445 extern HRESULT  WINAPI  IDirect3DDevice8Impl_MultiplyTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix);
446 extern HRESULT  WINAPI  IDirect3DDevice8Impl_SetViewport(LPDIRECT3DDEVICE8 iface, CONST D3DVIEWPORT8* pViewport);
447 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetViewport(LPDIRECT3DDEVICE8 iface, D3DVIEWPORT8* pViewport);
448 extern HRESULT  WINAPI  IDirect3DDevice8Impl_SetMaterial(LPDIRECT3DDEVICE8 iface, CONST D3DMATERIAL8* pMaterial);
449 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetMaterial(LPDIRECT3DDEVICE8 iface, D3DMATERIAL8* pMaterial);
450 extern HRESULT  WINAPI  IDirect3DDevice8Impl_SetLight(LPDIRECT3DDEVICE8 iface, DWORD Index, CONST D3DLIGHT8* pLight);
451 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetLight(LPDIRECT3DDEVICE8 iface, DWORD Index, D3DLIGHT8* pLight);
452 extern HRESULT  WINAPI  IDirect3DDevice8Impl_LightEnable(LPDIRECT3DDEVICE8 iface, DWORD Index, BOOL Enable);
453 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetLightEnable(LPDIRECT3DDEVICE8 iface, DWORD Index, BOOL* pEnable);
454 extern HRESULT  WINAPI  IDirect3DDevice8Impl_SetClipPlane(LPDIRECT3DDEVICE8 iface, DWORD Index, CONST float* pPlane);
455 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetClipPlane(LPDIRECT3DDEVICE8 iface, DWORD Index, float* pPlane);
456 extern HRESULT  WINAPI  IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State, DWORD Value);
457 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State, DWORD* pValue);
458 extern HRESULT  WINAPI  IDirect3DDevice8Impl_BeginStateBlock(LPDIRECT3DDEVICE8 iface);
459 extern HRESULT  WINAPI  IDirect3DDevice8Impl_EndStateBlock(LPDIRECT3DDEVICE8 iface, DWORD* pToken);
460 extern HRESULT  WINAPI  IDirect3DDevice8Impl_ApplyStateBlock(LPDIRECT3DDEVICE8 iface, DWORD Token);
461 extern HRESULT  WINAPI  IDirect3DDevice8Impl_CaptureStateBlock(LPDIRECT3DDEVICE8 iface, DWORD Token);
462 extern HRESULT  WINAPI  IDirect3DDevice8Impl_DeleteStateBlock(LPDIRECT3DDEVICE8 iface, DWORD Token);
463 extern HRESULT  WINAPI  IDirect3DDevice8Impl_CreateStateBlock(LPDIRECT3DDEVICE8 iface, D3DSTATEBLOCKTYPE Type,DWORD* pToken);
464 extern HRESULT  WINAPI  IDirect3DDevice8Impl_SetClipStatus(LPDIRECT3DDEVICE8 iface, CONST D3DCLIPSTATUS8* pClipStatus);
465 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetClipStatus(LPDIRECT3DDEVICE8 iface, D3DCLIPSTATUS8* pClipStatus);
466 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetTexture(LPDIRECT3DDEVICE8 iface, DWORD Stage, IDirect3DBaseTexture8** ppTexture);
467 extern HRESULT  WINAPI  IDirect3DDevice8Impl_SetTexture(LPDIRECT3DDEVICE8 iface, DWORD Stage, IDirect3DBaseTexture8* pTexture);
468 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue);
469 extern HRESULT  WINAPI  IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value);
470 extern HRESULT  WINAPI  IDirect3DDevice8Impl_ValidateDevice(LPDIRECT3DDEVICE8 iface, DWORD* pNumPasses);
471 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetInfo(LPDIRECT3DDEVICE8 iface, DWORD DevInfoID, void* pDevInfoStruct, DWORD DevInfoStructSize);
472 extern HRESULT  WINAPI  IDirect3DDevice8Impl_SetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber, CONST PALETTEENTRY* pEntries);
473 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber, PALETTEENTRY* pEntries);
474 extern HRESULT  WINAPI  IDirect3DDevice8Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber);
475 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE8 iface, UINT *PaletteNumber);
476 extern HRESULT  WINAPI  IDirect3DDevice8Impl_DrawPrimitive(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount);
477 extern HRESULT  WINAPI  IDirect3DDevice8Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType, UINT minIndex, UINT NumVertices, UINT startIndex, UINT primCount);
478 extern HRESULT  WINAPI  IDirect3DDevice8Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride);
479 extern HRESULT  WINAPI  IDirect3DDevice8Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertexIndices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride);
480 extern HRESULT  WINAPI  IDirect3DDevice8Impl_ProcessVertices(LPDIRECT3DDEVICE8 iface, UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer8* pDestBuffer,DWORD Flags);
481 extern HRESULT  WINAPI  IDirect3DDevice8Impl_CreateVertexShader(LPDIRECT3DDEVICE8 iface, CONST DWORD* pDeclaration,CONST DWORD* pFunction,DWORD* pHandle,DWORD Usage);
482 extern HRESULT  WINAPI  IDirect3DDevice8Impl_SetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD Handle);
483 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD* pHandle);
484 extern HRESULT  WINAPI  IDirect3DDevice8Impl_DeleteVertexShader(LPDIRECT3DDEVICE8 iface, DWORD Handle);
485 extern HRESULT  WINAPI  IDirect3DDevice8Impl_SetVertexShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register,CONST void* pConstantData,DWORD ConstantCount);
486 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetVertexShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register,void* pConstantData,DWORD ConstantCount);
487 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetVertexShaderDeclaration(LPDIRECT3DDEVICE8 iface, DWORD Handle,void* pData,DWORD* pSizeOfData);
488 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetVertexShaderFunction(LPDIRECT3DDEVICE8 iface, DWORD Handle,void* pData,DWORD* pSizeOfData);
489 extern HRESULT  WINAPI  IDirect3DDevice8Impl_SetStreamSource(LPDIRECT3DDEVICE8 iface, UINT StreamNumber,IDirect3DVertexBuffer8* pStreamData,UINT Stride);
490 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetStreamSource(LPDIRECT3DDEVICE8 iface, UINT StreamNumber,IDirect3DVertexBuffer8** ppStreamData,UINT* pStride);
491 extern HRESULT  WINAPI  IDirect3DDevice8Impl_SetIndices(LPDIRECT3DDEVICE8 iface, IDirect3DIndexBuffer8* pIndexData,UINT BaseVertexIndex);
492 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetIndices(LPDIRECT3DDEVICE8 iface, IDirect3DIndexBuffer8** ppIndexData,UINT* pBaseVertexIndex);
493 extern HRESULT  WINAPI  IDirect3DDevice8Impl_CreatePixelShader(LPDIRECT3DDEVICE8 iface, CONST DWORD* pFunction,DWORD* pHandle);
494 extern HRESULT  WINAPI  IDirect3DDevice8Impl_SetPixelShader(LPDIRECT3DDEVICE8 iface, DWORD Handle);
495 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetPixelShader(LPDIRECT3DDEVICE8 iface, DWORD* pHandle);
496 extern HRESULT  WINAPI  IDirect3DDevice8Impl_DeletePixelShader(LPDIRECT3DDEVICE8 iface, DWORD Handle);
497 extern HRESULT  WINAPI  IDirect3DDevice8Impl_SetPixelShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register,CONST void* pConstantData,DWORD ConstantCount);
498 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetPixelShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register,void* pConstantData,DWORD ConstantCount);
499 extern HRESULT  WINAPI  IDirect3DDevice8Impl_GetPixelShaderFunction(LPDIRECT3DDEVICE8 iface, DWORD Handle,void* pData,DWORD* pSizeOfData);
500 extern HRESULT  WINAPI  IDirect3DDevice8Impl_DrawRectPatch(LPDIRECT3DDEVICE8 iface, UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo);
501 extern HRESULT  WINAPI  IDirect3DDevice8Impl_DrawTriPatch(LPDIRECT3DDEVICE8 iface, UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo);
502 extern HRESULT  WINAPI  IDirect3DDevice8Impl_DeletePatch(LPDIRECT3DDEVICE8 iface, UINT Handle);
503
504 /* internal Interfaces */
505 extern HRESULT WINAPI   IDirect3DDevice8Impl_CleanRender(LPDIRECT3DDEVICE8 iface);
506 extern HRESULT WINAPI   IDirect3DDevice8Impl_ActiveRender(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* RenderSurface, IDirect3DSurface8* StencilSurface);
507
508
509 /* ---------------- */
510 /* IDirect3DVolume8 */
511 /* ---------------- */
512
513 /*****************************************************************************
514  * Predeclare the interface implementation structures
515  */
516 extern ICOM_VTABLE(IDirect3DVolume8) Direct3DVolume8_Vtbl;
517
518 /*****************************************************************************
519  * IDirect3DVolume8 implementation structure
520  */
521 struct IDirect3DVolume8Impl
522 {
523     /* IUnknown fields */
524     ICOM_VFIELD(IDirect3DVolume8);
525     DWORD                   ref;
526
527     /* IDirect3DVolume8 fields */
528     IDirect3DDevice8Impl   *Device;
529     D3DRESOURCETYPE         ResourceType;
530
531     IUnknown               *Container;
532     D3DVOLUME_DESC          myDesc;
533     BYTE                   *allocatedMemory;
534     UINT                    textureName;
535     UINT                    bytesPerPixel;
536
537     BOOL                    lockable;
538     BOOL                    locked;
539     D3DBOX                  lockedBox;
540     D3DBOX                  dirtyBox;
541     BOOL                    Dirty;
542 };
543
544 /* IUnknown: */
545 extern HRESULT WINAPI IDirect3DVolume8Impl_QueryInterface(LPDIRECT3DVOLUME8 iface,REFIID refiid,LPVOID *obj);
546 extern ULONG WINAPI   IDirect3DVolume8Impl_AddRef(LPDIRECT3DVOLUME8 iface);
547 extern ULONG WINAPI   IDirect3DVolume8Impl_Release(LPDIRECT3DVOLUME8 iface);
548
549 /* IDirect3DVolume8: */
550 extern HRESULT WINAPI IDirect3DVolume8Impl_GetDevice(LPDIRECT3DVOLUME8 iface, IDirect3DDevice8** ppDevice);
551 extern HRESULT WINAPI IDirect3DVolume8Impl_SetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
552 extern HRESULT WINAPI IDirect3DVolume8Impl_GetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID  refguid, void* pData, DWORD* pSizeOfData);
553 extern HRESULT WINAPI IDirect3DVolume8Impl_FreePrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid);
554 extern HRESULT WINAPI IDirect3DVolume8Impl_GetContainer(LPDIRECT3DVOLUME8 iface, REFIID riid, void** ppContainer);
555 extern HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface, D3DVOLUME_DESC* pDesc);
556 extern HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags);
557 extern HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface);
558
559 /* internal Interfaces */
560 extern HRESULT WINAPI IDirect3DVolume8Impl_CleanDirtyBox(LPDIRECT3DVOLUME8 iface);
561 extern HRESULT WINAPI IDirect3DVolume8Impl_AddDirtyBox(LPDIRECT3DVOLUME8 iface, CONST D3DBOX* pDirtyBox);
562
563 /* ------------------- */
564 /* IDirect3DSwapChain8 */
565 /* ------------------- */
566
567 /*****************************************************************************
568  * Predeclare the interface implementation structures
569  */
570 extern ICOM_VTABLE(IDirect3DSwapChain8) Direct3DSwapChain8_Vtbl;
571
572 /*****************************************************************************
573  * IDirect3DSwapChain8 implementation structure
574  */
575 struct IDirect3DSwapChain8Impl
576 {
577     /* IUnknown fields */
578     ICOM_VFIELD(IDirect3DSwapChain8);
579     DWORD                   ref;
580
581     /* IDirect3DSwapChain8 fields */
582     IDirect3DSurface8Impl  *frontBuffer;
583     IDirect3DSurface8Impl  *backBuffer;
584     IDirect3DSurface8Impl  *depthStencilBuffer;
585     D3DPRESENT_PARAMETERS   PresentParms;
586
587     /* OpenGL/GLX related */
588     GLXContext              swap_ctx;
589     Drawable                swap_drawable;
590 };
591
592 /* IUnknown: */
593 extern HRESULT WINAPI IDirect3DSwapChain8Impl_QueryInterface(LPDIRECT3DSWAPCHAIN8 iface, REFIID refiid, LPVOID *obj);
594 extern ULONG WINAPI   IDirect3DSwapChain8Impl_AddRef(LPDIRECT3DSWAPCHAIN8 iface);
595 extern ULONG WINAPI   IDirect3DSwapChain8Impl_Release(LPDIRECT3DSWAPCHAIN8 iface);
596
597 /* IDirect3DSwapChain8: */
598 extern HRESULT WINAPI IDirect3DSwapChain8Impl_Present(LPDIRECT3DSWAPCHAIN8 iface, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion);
599 extern HRESULT WINAPI IDirect3DSwapChain8Impl_GetBackBuffer(LPDIRECT3DSWAPCHAIN8 iface, UINT BackBuffer, D3DBACKBUFFER_TYPE Type,IDirect3DSurface8** ppBackBuffer);
600
601
602 /* ----------------- */
603 /* IDirect3DSurface8 */
604 /* ----------------- */
605
606 /*****************************************************************************
607  * Predeclare the interface implementation structures
608  */
609 extern ICOM_VTABLE(IDirect3DSurface8) Direct3DSurface8_Vtbl;
610
611 /*****************************************************************************
612  * IDirect3DSurface8 implementation structure
613  */
614 struct IDirect3DSurface8Impl
615 {
616     /* IUnknown fields */
617     ICOM_VFIELD(IDirect3DSurface8);
618     DWORD                   ref;
619
620     /* IDirect3DSurface8 fields */
621     IDirect3DDevice8Impl   *Device;
622     D3DRESOURCETYPE         ResourceType;
623
624     IUnknown               *Container;
625     D3DSURFACE_DESC         myDesc;
626     BYTE                   *allocatedMemory;
627     UINT                    textureName;
628     UINT                    bytesPerPixel;
629
630     BOOL                    lockable;
631     BOOL                    locked;
632     RECT                    lockedRect;
633     RECT                    dirtyRect;
634     BOOL                    Dirty;
635     BOOL                    inTexture;
636     BOOL                    inPBuffer;
637 };
638
639 /* IUnknown: */
640 extern HRESULT WINAPI IDirect3DSurface8Impl_QueryInterface(LPDIRECT3DSURFACE8 iface,REFIID refiid,LPVOID *obj);
641 extern ULONG WINAPI   IDirect3DSurface8Impl_AddRef(LPDIRECT3DSURFACE8 iface);
642 extern ULONG WINAPI   IDirect3DSurface8Impl_Release(LPDIRECT3DSURFACE8 iface);
643
644 /* IDirect3DSurface8: */
645 extern HRESULT WINAPI IDirect3DSurface8Impl_GetDevice(LPDIRECT3DSURFACE8 iface, IDirect3DDevice8** ppDevice);
646 extern HRESULT WINAPI IDirect3DSurface8Impl_SetPrivateData(LPDIRECT3DSURFACE8 iface, REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags);
647 extern HRESULT WINAPI IDirect3DSurface8Impl_GetPrivateData(LPDIRECT3DSURFACE8 iface, REFGUID refguid,void* pData,DWORD* pSizeOfData);
648 extern HRESULT WINAPI IDirect3DSurface8Impl_FreePrivateData(LPDIRECT3DSURFACE8 iface, REFGUID refguid);
649 extern HRESULT WINAPI IDirect3DSurface8Impl_GetContainer(LPDIRECT3DSURFACE8 iface, REFIID riid,void** ppContainer);
650 extern HRESULT WINAPI IDirect3DSurface8Impl_GetDesc(LPDIRECT3DSURFACE8 iface, D3DSURFACE_DESC *pDesc);
651 extern HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect,DWORD Flags);
652 extern HRESULT WINAPI IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface);
653
654 /* internal Interfaces */
655 extern HRESULT WINAPI IDirect3DSurface8Impl_LoadTexture(LPDIRECT3DSURFACE8 iface, GLenum gl_target, GLenum gl_level);
656 extern HRESULT WINAPI IDirect3DSurface8Impl_SaveSnapshot(LPDIRECT3DSURFACE8 iface, const char* filename);
657 extern HRESULT WINAPI IDirect3DSurface8Impl_CleanDirtyRect(LPDIRECT3DSURFACE8 iface);
658 extern HRESULT WINAPI IDirect3DSurface8Impl_AddDirtyRect(LPDIRECT3DSURFACE8 iface, CONST RECT* pDirtyRect);
659
660 /* ------------------ */
661 /* IDirect3DResource8 */
662 /* ------------------ */
663
664 /*****************************************************************************
665  * Predeclare the interface implementation structures
666  */
667 extern ICOM_VTABLE(IDirect3DResource8) Direct3DResource8_Vtbl;
668
669 /*****************************************************************************
670  * IDirect3DResource8 implementation structure
671  */
672 struct IDirect3DResource8Impl
673 {
674     /* IUnknown fields */
675     ICOM_VFIELD(IDirect3DResource8);
676     DWORD                   ref;
677
678     /* IDirect3DResource8 fields */
679     IDirect3DDevice8Impl   *Device;
680     D3DRESOURCETYPE         ResourceType;
681 };
682
683 /* IUnknown: */
684 extern HRESULT WINAPI         IDirect3DResource8Impl_QueryInterface(LPDIRECT3DRESOURCE8 iface,REFIID refiid,LPVOID *obj);
685 extern ULONG WINAPI           IDirect3DResource8Impl_AddRef(LPDIRECT3DRESOURCE8 iface);
686 extern ULONG WINAPI           IDirect3DResource8Impl_Release(LPDIRECT3DRESOURCE8 iface);
687
688 /* IDirect3DResource8: */
689 extern HRESULT  WINAPI        IDirect3DResource8Impl_GetDevice(LPDIRECT3DRESOURCE8 iface, IDirect3DDevice8** ppDevice);
690 extern HRESULT  WINAPI        IDirect3DResource8Impl_SetPrivateData(LPDIRECT3DRESOURCE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
691 extern HRESULT  WINAPI        IDirect3DResource8Impl_GetPrivateData(LPDIRECT3DRESOURCE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData);
692 extern HRESULT  WINAPI        IDirect3DResource8Impl_FreePrivateData(LPDIRECT3DRESOURCE8 iface, REFGUID refguid);
693 extern DWORD    WINAPI        IDirect3DResource8Impl_SetPriority(LPDIRECT3DRESOURCE8 iface, DWORD PriorityNew);
694 extern DWORD    WINAPI        IDirect3DResource8Impl_GetPriority(LPDIRECT3DRESOURCE8 iface);
695 extern void     WINAPI        IDirect3DResource8Impl_PreLoad(LPDIRECT3DRESOURCE8 iface);
696 extern D3DRESOURCETYPE WINAPI IDirect3DResource8Impl_GetType(LPDIRECT3DRESOURCE8 iface);
697
698 /* internal Interfaces */
699 extern D3DPOOL WINAPI         IDirect3DResource8Impl_GetPool(LPDIRECT3DRESOURCE8 iface);
700
701
702 /* ---------------------- */
703 /* IDirect3DVertexBuffer8 */
704 /* ---------------------- */
705
706 /*****************************************************************************
707  * Predeclare the interface implementation structures
708  */
709 extern ICOM_VTABLE(IDirect3DVertexBuffer8) Direct3DVertexBuffer8_Vtbl;
710
711 /*****************************************************************************
712  * IDirect3DVertexBuffer8 implementation structure
713  */
714 struct IDirect3DVertexBuffer8Impl
715 {
716     /* IUnknown fields */
717     ICOM_VFIELD(IDirect3DVertexBuffer8);
718     DWORD                   ref;
719
720     /* IDirect3DResource8 fields */
721     IDirect3DDevice8Impl   *Device;
722     D3DRESOURCETYPE         ResourceType;
723
724     /* IDirect3DVertexBuffer8 fields */
725     BYTE                   *allocatedMemory;
726     D3DVERTEXBUFFER_DESC    currentDesc;
727 };
728
729 /* IUnknown: */
730 extern HRESULT WINAPI         IDirect3DVertexBuffer8Impl_QueryInterface(LPDIRECT3DVERTEXBUFFER8 iface,REFIID refiid,LPVOID *obj);
731 extern ULONG WINAPI           IDirect3DVertexBuffer8Impl_AddRef(LPDIRECT3DVERTEXBUFFER8 iface);
732 extern ULONG WINAPI           IDirect3DVertexBuffer8Impl_Release(LPDIRECT3DVERTEXBUFFER8 iface);
733
734 /* IDirect3DVertexBuffer8: (Inherited from IDirect3DResource8) */
735 extern HRESULT  WINAPI        IDirect3DVertexBuffer8Impl_GetDevice(LPDIRECT3DVERTEXBUFFER8 iface, IDirect3DDevice8** ppDevice);
736 extern HRESULT  WINAPI        IDirect3DVertexBuffer8Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
737 extern HRESULT  WINAPI        IDirect3DVertexBuffer8Impl_GetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData);
738 extern HRESULT  WINAPI        IDirect3DVertexBuffer8Impl_FreePrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid);
739 extern DWORD    WINAPI        IDirect3DVertexBuffer8Impl_SetPriority(LPDIRECT3DVERTEXBUFFER8 iface, DWORD PriorityNew);
740 extern DWORD    WINAPI        IDirect3DVertexBuffer8Impl_GetPriority(LPDIRECT3DVERTEXBUFFER8 iface);
741 extern void     WINAPI        IDirect3DVertexBuffer8Impl_PreLoad(LPDIRECT3DVERTEXBUFFER8 iface);
742 extern D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer8Impl_GetType(LPDIRECT3DVERTEXBUFFER8 iface);
743
744 /* IDirect3DVertexBuffer8: */
745 extern HRESULT  WINAPI        IDirect3DVertexBuffer8Impl_Lock(LPDIRECT3DVERTEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE** ppbData, DWORD Flags);
746 extern HRESULT  WINAPI        IDirect3DVertexBuffer8Impl_Unlock(LPDIRECT3DVERTEXBUFFER8 iface);
747 extern HRESULT  WINAPI        IDirect3DVertexBuffer8Impl_GetDesc(LPDIRECT3DVERTEXBUFFER8 iface, D3DVERTEXBUFFER_DESC *pDesc);
748
749
750 /* --------------------- */
751 /* IDirect3DIndexBuffer8 */
752 /* --------------------- */
753
754 /*****************************************************************************
755  * Predeclare the interface implementation structures
756  */
757 extern ICOM_VTABLE(IDirect3DIndexBuffer8) Direct3DIndexBuffer8_Vtbl;
758
759 /*****************************************************************************
760  * IDirect3DIndexBuffer8 implementation structure
761  */
762 struct IDirect3DIndexBuffer8Impl
763 {
764     /* IUnknown fields */
765     ICOM_VFIELD(IDirect3DIndexBuffer8);
766     DWORD                   ref;
767
768     /* IDirect3DResource8 fields */
769     IDirect3DDevice8Impl   *Device;
770     D3DRESOURCETYPE         ResourceType;
771
772     /* IDirect3DIndexBuffer8 fields */
773     void                   *allocatedMemory;
774     D3DINDEXBUFFER_DESC     currentDesc;
775 };
776
777 /* IUnknown: */
778 extern HRESULT WINAPI         IDirect3DIndexBuffer8Impl_QueryInterface(LPDIRECT3DINDEXBUFFER8 iface,REFIID refiid,LPVOID *obj);
779 extern ULONG WINAPI           IDirect3DIndexBuffer8Impl_AddRef(LPDIRECT3DINDEXBUFFER8 iface);
780 extern ULONG WINAPI           IDirect3DIndexBuffer8Impl_Release(LPDIRECT3DINDEXBUFFER8 iface);
781
782 /* IDirect3DIndexBuffer8: (Inherited from IDirect3DResource8) */
783 extern HRESULT  WINAPI        IDirect3DIndexBuffer8Impl_GetDevice(LPDIRECT3DINDEXBUFFER8 iface, IDirect3DDevice8** ppDevice);
784 extern HRESULT  WINAPI        IDirect3DIndexBuffer8Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
785 extern HRESULT  WINAPI        IDirect3DIndexBuffer8Impl_GetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData);
786 extern HRESULT  WINAPI        IDirect3DIndexBuffer8Impl_FreePrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid);
787 extern DWORD    WINAPI        IDirect3DIndexBuffer8Impl_SetPriority(LPDIRECT3DINDEXBUFFER8 iface, DWORD PriorityNew);
788 extern DWORD    WINAPI        IDirect3DIndexBuffer8Impl_GetPriority(LPDIRECT3DINDEXBUFFER8 iface);
789 extern void     WINAPI        IDirect3DIndexBuffer8Impl_PreLoad(LPDIRECT3DINDEXBUFFER8 iface);
790 extern D3DRESOURCETYPE WINAPI IDirect3DIndexBuffer8Impl_GetType(LPDIRECT3DINDEXBUFFER8 iface);
791
792 /* IDirect3DIndexBuffer8: */
793 extern HRESULT  WINAPI        IDirect3DIndexBuffer8Impl_Lock(LPDIRECT3DINDEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE** ppbData, DWORD Flags);
794 extern HRESULT  WINAPI        IDirect3DIndexBuffer8Impl_Unlock(LPDIRECT3DINDEXBUFFER8 iface);
795 extern HRESULT  WINAPI        IDirect3DIndexBuffer8Impl_GetDesc(LPDIRECT3DINDEXBUFFER8 iface, D3DINDEXBUFFER_DESC *pDesc);
796
797
798 /* --------------------- */
799 /* IDirect3DBaseTexture8 */
800 /* --------------------- */
801
802 /*****************************************************************************
803  * Predeclare the interface implementation structures
804  */
805 extern ICOM_VTABLE(IDirect3DBaseTexture8) Direct3DBaseTexture8_Vtbl;
806
807 /*****************************************************************************
808  * IDirect3DBaseTexture8 implementation structure
809  */
810 struct IDirect3DBaseTexture8Impl
811 {
812     /* IUnknown fields */
813     ICOM_VFIELD(IDirect3DBaseTexture8);
814     DWORD                   ref;
815
816     /* IDirect3DResource8 fields */
817     IDirect3DDevice8Impl   *Device;
818     D3DRESOURCETYPE         ResourceType;
819
820     /* IDirect3DBaseTexture8 fields */
821     BOOL                    Dirty;
822     D3DFORMAT               format;
823     UINT                    levels;
824     /*
825      *BOOL                    isManaged;
826      *DWORD                   lod;
827      */
828 };
829
830 /* IUnknown: */
831 extern HRESULT WINAPI         IDirect3DBaseTexture8Impl_QueryInterface(LPDIRECT3DBASETEXTURE8 iface,REFIID refiid,LPVOID *obj);
832 extern ULONG WINAPI           IDirect3DBaseTexture8Impl_AddRef(LPDIRECT3DBASETEXTURE8 iface);
833 extern ULONG WINAPI           IDirect3DBaseTexture8Impl_Release(LPDIRECT3DBASETEXTURE8 iface);
834
835 /* IDirect3DBaseTexture8: (Inherited from IDirect3DResource8) */
836 extern HRESULT  WINAPI        IDirect3DBaseTexture8Impl_GetDevice(LPDIRECT3DBASETEXTURE8 iface, IDirect3DDevice8** ppDevice);
837 extern HRESULT  WINAPI        IDirect3DBaseTexture8Impl_SetPrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
838 extern HRESULT  WINAPI        IDirect3DBaseTexture8Impl_GetPrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData);
839 extern HRESULT  WINAPI        IDirect3DBaseTexture8Impl_FreePrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid);
840 extern DWORD    WINAPI        IDirect3DBaseTexture8Impl_SetPriority(LPDIRECT3DBASETEXTURE8 iface, DWORD PriorityNew);
841 extern DWORD    WINAPI        IDirect3DBaseTexture8Impl_GetPriority(LPDIRECT3DBASETEXTURE8 iface);
842 extern void     WINAPI        IDirect3DBaseTexture8Impl_PreLoad(LPDIRECT3DBASETEXTURE8 iface);
843 extern D3DRESOURCETYPE WINAPI IDirect3DBaseTexture8Impl_GetType(LPDIRECT3DBASETEXTURE8 iface);
844
845 /* IDirect3DBaseTexture8: */
846 extern DWORD    WINAPI        IDirect3DBaseTexture8Impl_SetLOD(LPDIRECT3DBASETEXTURE8 iface, DWORD LODNew);
847 extern DWORD    WINAPI        IDirect3DBaseTexture8Impl_GetLOD(LPDIRECT3DBASETEXTURE8 iface);
848 extern DWORD    WINAPI        IDirect3DBaseTexture8Impl_GetLevelCount(LPDIRECT3DBASETEXTURE8 iface);
849
850 /* internal Interfaces */
851 extern BOOL     WINAPI        IDirect3DBaseTexture8Impl_IsDirty(LPDIRECT3DBASETEXTURE8 iface);
852 extern BOOL     WINAPI        IDirect3DBaseTexture8Impl_SetDirty(LPDIRECT3DBASETEXTURE8 iface, BOOL dirty);
853
854
855 /* --------------------- */
856 /* IDirect3DCubeTexture8 */
857 /* --------------------- */
858
859 /*****************************************************************************
860  * Predeclare the interface implementation structures
861  */
862 extern ICOM_VTABLE(IDirect3DCubeTexture8) Direct3DCubeTexture8_Vtbl;
863
864 /*****************************************************************************
865  * IDirect3DCubeTexture8 implementation structure
866  */
867 struct IDirect3DCubeTexture8Impl
868 {
869     /* IUnknown fields */
870     ICOM_VFIELD(IDirect3DCubeTexture8);
871     DWORD                   ref;
872
873     /* IDirect3DResource8 fields */
874     IDirect3DDevice8Impl   *Device;
875     D3DRESOURCETYPE         ResourceType;
876
877     /* IDirect3DBaseTexture8 fields */
878     BOOL                    Dirty;
879     D3DFORMAT               format;
880     UINT                    levels;
881
882     /* IDirect3DCubeTexture8 fields */
883     UINT                    edgeLength;
884     DWORD                   usage;
885
886     IDirect3DSurface8Impl  *surfaces[6][MAX_LEVELS];
887 };
888
889 /* IUnknown: */
890 extern HRESULT WINAPI         IDirect3DCubeTexture8Impl_QueryInterface(LPDIRECT3DCUBETEXTURE8 iface,REFIID refiid,LPVOID *obj);
891 extern ULONG WINAPI           IDirect3DCubeTexture8Impl_AddRef(LPDIRECT3DCUBETEXTURE8 iface);
892 extern ULONG WINAPI           IDirect3DCubeTexture8Impl_Release(LPDIRECT3DCUBETEXTURE8 iface);
893
894 /* IDirect3DCubeTexture8: (Inherited from IDirect3DResource8) */
895 extern HRESULT  WINAPI        IDirect3DCubeTexture8Impl_GetDevice(LPDIRECT3DCUBETEXTURE8 iface, IDirect3DDevice8** ppDevice);
896 extern HRESULT  WINAPI        IDirect3DCubeTexture8Impl_SetPrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
897 extern HRESULT  WINAPI        IDirect3DCubeTexture8Impl_GetPrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData);
898 extern HRESULT  WINAPI        IDirect3DCubeTexture8Impl_FreePrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid);
899 extern DWORD    WINAPI        IDirect3DCubeTexture8Impl_SetPriority(LPDIRECT3DCUBETEXTURE8 iface, DWORD PriorityNew);
900 extern DWORD    WINAPI        IDirect3DCubeTexture8Impl_GetPriority(LPDIRECT3DCUBETEXTURE8 iface);
901 extern void     WINAPI        IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8 iface);
902 extern D3DRESOURCETYPE WINAPI IDirect3DCubeTexture8Impl_GetType(LPDIRECT3DCUBETEXTURE8 iface);
903
904 /* IDirect3DCubeTexture8: (Inherited from IDirect3DBaseTexture8) */
905 extern DWORD    WINAPI        IDirect3DCubeTexture8Impl_SetLOD(LPDIRECT3DCUBETEXTURE8 iface, DWORD LODNew);
906 extern DWORD    WINAPI        IDirect3DCubeTexture8Impl_GetLOD(LPDIRECT3DCUBETEXTURE8 iface);
907 extern DWORD    WINAPI        IDirect3DCubeTexture8Impl_GetLevelCount(LPDIRECT3DCUBETEXTURE8 iface);
908
909 /* IDirect3DCubeTexture8 */
910 extern HRESULT  WINAPI        IDirect3DCubeTexture8Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE8 iface, UINT Level, D3DSURFACE_DESC* pDesc);
911 extern HRESULT  WINAPI        IDirect3DCubeTexture8Impl_GetCubeMapSurface(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface8** ppCubeMapSurface);
912 extern HRESULT  WINAPI        IDirect3DCubeTexture8Impl_LockRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags);
913 extern HRESULT  WINAPI        IDirect3DCubeTexture8Impl_UnlockRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level);
914 extern HRESULT  WINAPI        IDirect3DCubeTexture8Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect);
915
916
917 /* ----------------- */
918 /* IDirect3DTexture8 */
919 /* ----------------- */
920
921 /*****************************************************************************
922  * Predeclare the interface implementation structures
923  */
924 extern ICOM_VTABLE(IDirect3DTexture8) Direct3DTexture8_Vtbl;
925
926 /*****************************************************************************
927  * IDirect3DTexture8 implementation structure
928  */
929 struct IDirect3DTexture8Impl
930 {
931     /* IUnknown fields */
932     ICOM_VFIELD(IDirect3DTexture8);
933     DWORD                   ref;
934
935     /* IDirect3DResourc8 fields */
936     IDirect3DDevice8Impl   *Device;
937     D3DRESOURCETYPE         ResourceType;
938
939     /* IDirect3DBaseTexture8 fields */
940     BOOL                    Dirty;
941     D3DFORMAT               format;
942     UINT                    levels;
943
944     /* IDirect3DTexture8 fields */
945     UINT                    width;
946     UINT                    height;
947     DWORD                   usage;
948
949     IDirect3DSurface8Impl  *surfaces[MAX_LEVELS];
950 };
951
952 /* IUnknown: */
953 extern HRESULT WINAPI         IDirect3DTexture8Impl_QueryInterface(LPDIRECT3DTEXTURE8 iface,REFIID refiid,LPVOID *obj);
954 extern ULONG WINAPI           IDirect3DTexture8Impl_AddRef(LPDIRECT3DTEXTURE8 iface);
955 extern ULONG WINAPI           IDirect3DTexture8Impl_Release(LPDIRECT3DTEXTURE8 iface);
956
957 /* IDirect3DTexture8: (Inherited from IDirect3DResource8) */
958 extern HRESULT  WINAPI        IDirect3DTexture8Impl_GetDevice(LPDIRECT3DTEXTURE8 iface, IDirect3DDevice8** ppDevice);
959 extern HRESULT  WINAPI        IDirect3DTexture8Impl_SetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
960 extern HRESULT  WINAPI        IDirect3DTexture8Impl_GetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData);
961 extern HRESULT  WINAPI        IDirect3DTexture8Impl_FreePrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid);
962 extern DWORD    WINAPI        IDirect3DTexture8Impl_SetPriority(LPDIRECT3DTEXTURE8 iface, DWORD PriorityNew);
963 extern DWORD    WINAPI        IDirect3DTexture8Impl_GetPriority(LPDIRECT3DTEXTURE8 iface);
964 extern void     WINAPI        IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface);
965 extern D3DRESOURCETYPE WINAPI IDirect3DTexture8Impl_GetType(LPDIRECT3DTEXTURE8 iface);
966
967 /* IDirect3DTexture8: (Inherited from IDirect3DBaseTexture8) */
968 extern DWORD    WINAPI        IDirect3DTexture8Impl_SetLOD(LPDIRECT3DTEXTURE8 iface, DWORD LODNew);
969 extern DWORD    WINAPI        IDirect3DTexture8Impl_GetLOD(LPDIRECT3DTEXTURE8 iface);
970 extern DWORD    WINAPI        IDirect3DTexture8Impl_GetLevelCount(LPDIRECT3DTEXTURE8 iface);
971
972 /* IDirect3DTexture8: */
973 extern HRESULT  WINAPI        IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DSURFACE_DESC* pDesc);
974 extern HRESULT  WINAPI        IDirect3DTexture8Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE8 iface, UINT Level, IDirect3DSurface8** ppSurfaceLevel);
975 extern HRESULT  WINAPI        IDirect3DTexture8Impl_LockRect(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags);
976 extern HRESULT  WINAPI        IDirect3DTexture8Impl_UnlockRect(LPDIRECT3DTEXTURE8 iface, UINT Level);
977 extern HRESULT  WINAPI        IDirect3DTexture8Impl_AddDirtyRect(LPDIRECT3DTEXTURE8 iface, CONST RECT* pDirtyRect);
978
979
980 /* ----------------------- */
981 /* IDirect3DVolumeTexture8 */
982 /* ----------------------- */
983
984 /*****************************************************************************
985  * Predeclare the interface implementation structures
986  */
987 extern ICOM_VTABLE(IDirect3DVolumeTexture8) Direct3DVolumeTexture8_Vtbl;
988
989 /*****************************************************************************
990  * IDirect3DVolumeTexture8 implementation structure
991  */
992 struct IDirect3DVolumeTexture8Impl
993 {
994     /* IUnknown fields */
995     ICOM_VFIELD(IDirect3DVolumeTexture8);
996     DWORD                   ref;
997
998     /* IDirect3DResource8 fields */
999     IDirect3DDevice8Impl   *Device;
1000     D3DRESOURCETYPE         ResourceType;
1001
1002     /* IDirect3DBaseTexture8 fields */
1003     BOOL                    Dirty;
1004     D3DFORMAT               format;
1005     UINT                    levels;
1006
1007     /* IDirect3DVolumeTexture8 fields */
1008     UINT                    width;
1009     UINT                    height;
1010     UINT                    depth;
1011     DWORD                   usage;
1012
1013     IDirect3DVolume8Impl   *volumes[MAX_LEVELS];
1014 };
1015
1016 /* IUnknown: */
1017 extern HRESULT WINAPI         IDirect3DVolumeTexture8Impl_QueryInterface(LPDIRECT3DVOLUMETEXTURE8 iface,REFIID refiid,LPVOID *obj);
1018 extern ULONG WINAPI           IDirect3DVolumeTexture8Impl_AddRef(LPDIRECT3DVOLUMETEXTURE8 iface);
1019 extern ULONG WINAPI           IDirect3DVolumeTexture8Impl_Release(LPDIRECT3DVOLUMETEXTURE8 iface);
1020
1021 /* IDirect3DVolumeTexture8: (Inherited from IDirect3DResource8) */
1022 extern HRESULT  WINAPI        IDirect3DVolumeTexture8Impl_GetDevice(LPDIRECT3DVOLUMETEXTURE8 iface, IDirect3DDevice8** ppDevice);
1023 extern HRESULT  WINAPI        IDirect3DVolumeTexture8Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
1024 extern HRESULT  WINAPI        IDirect3DVolumeTexture8Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData);
1025 extern HRESULT  WINAPI        IDirect3DVolumeTexture8Impl_FreePrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid);
1026 extern DWORD    WINAPI        IDirect3DVolumeTexture8Impl_SetPriority(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD PriorityNew);
1027 extern DWORD    WINAPI        IDirect3DVolumeTexture8Impl_GetPriority(LPDIRECT3DVOLUMETEXTURE8 iface);
1028 extern void     WINAPI        IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE8 iface);
1029 extern D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture8Impl_GetType(LPDIRECT3DVOLUMETEXTURE8 iface);
1030
1031 /* IDirect3DVolumeTexture8: (Inherited from IDirect3DBaseTexture8) */
1032 extern DWORD    WINAPI        IDirect3DVolumeTexture8Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD LODNew);
1033 extern DWORD    WINAPI        IDirect3DVolumeTexture8Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE8 iface);
1034 extern DWORD    WINAPI        IDirect3DVolumeTexture8Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE8 iface);
1035
1036 /* IDirect3DVolumeTexture8: */
1037 extern HRESULT  WINAPI        IDirect3DVolumeTexture8Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DVOLUME_DESC *pDesc);
1038 extern HRESULT  WINAPI        IDirect3DVolumeTexture8Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, IDirect3DVolume8** ppVolumeLevel);
1039 extern HRESULT  WINAPI        IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags);
1040 extern HRESULT  WINAPI        IDirect3DVolumeTexture8Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level);
1041 extern HRESULT  WINAPI        IDirect3DVolumeTexture8Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE8 iface, CONST D3DBOX* pDirtyBox);
1042
1043
1044 /* ==============================================================================
1045     Private interfactes: beginning of cleaning/splitting for HAL and d3d9 support
1046    ============================================================================== */
1047
1048 /* State Block for Begin/End/Capture/Create/Apply State Block   */
1049 /*   Note: Very long winded but I do not believe gl Lists will  */
1050 /*   resolve everything we need, so doing it manually for now   */
1051 typedef struct SAVEDSTATES {
1052         BOOL                      Indices;
1053         BOOL                      material;
1054         BOOL                      stream_source[MAX_STREAMS];
1055         BOOL                      textures[8];
1056         BOOL                      transform[HIGHEST_TRANSFORMSTATE];
1057         BOOL                      viewport;
1058         BOOL                      vertexShader;
1059         BOOL                      vertexShaderConstant;
1060         BOOL                      vertexShaderDecl;
1061         BOOL                      pixelShader;
1062         BOOL                      pixelShaderConstant;
1063         BOOL                      renderstate[HIGHEST_RENDER_STATE];
1064         BOOL                      texture_state[8][HIGHEST_TEXTURE_STATE];
1065         BOOL                      clipplane[MAX_CLIPPLANES];
1066 } SAVEDSTATES;
1067
1068
1069 /* ----------------------- */
1070 /* IDirect3DStateBlockImpl */
1071 /* ----------------------- */
1072
1073 /*****************************************************************************
1074  * Predeclare the interface implementation structures
1075  */
1076 /*extern ICOM_VTABLE(IDirect3DStateBlock9) Direct3DStateBlock9_Vtbl;*/
1077
1078 /*****************************************************************************
1079  * IDirect3DStateBlock implementation structure
1080  */
1081 struct  IDirect3DStateBlockImpl {
1082   /* IUnknown fields */
1083   /*ICOM_VFIELD(IDirect3DStateBlock9);*/
1084   DWORD  ref;
1085
1086   /* The device, to be replaced by a IDirect3DDeviceImpl */
1087   IDirect3DDevice8Impl* device;
1088
1089   D3DSTATEBLOCKTYPE         blockType;
1090
1091   SAVEDSTATES               Changed;
1092   SAVEDSTATES               Set;
1093   
1094   /* ClipPlane */
1095   double                    clipplane[MAX_CLIPPLANES][4];
1096   
1097   /* Stream Source */
1098   UINT                      stream_stride[MAX_STREAMS];
1099   IDirect3DVertexBuffer8   *stream_source[MAX_STREAMS];
1100   BOOL                      streamIsUP;
1101
1102   /* Indices */
1103   IDirect3DIndexBuffer8*    pIndexData;
1104   UINT                      baseVertexIndex;
1105   
1106   /* Texture */
1107   IDirect3DBaseTexture8    *textures[8];
1108   int                       textureDimensions[8];
1109   /* Texture State Stage */
1110   DWORD                     texture_state[8][HIGHEST_TEXTURE_STATE];
1111   
1112   /* Lights */
1113   PLIGHTINFOEL             *lights; /* NOTE: active GL lights must be front of the chain */
1114   
1115   /* Material */
1116   D3DMATERIAL8              material;
1117   
1118   /* RenderState */
1119   DWORD                     renderstate[HIGHEST_RENDER_STATE];
1120   
1121   /* Transform */
1122   D3DMATRIX                 transforms[HIGHEST_TRANSFORMSTATE];
1123   
1124   /* ViewPort */
1125   D3DVIEWPORT8              viewport;
1126   
1127   /* Vertex Shader */
1128   DWORD                     VertexShader;
1129
1130   /* Vertex Shader Declaration */
1131   IDirect3DVertexShaderDeclarationImpl* vertexShaderDecl;
1132   
1133   /* Pixel Shader */
1134   DWORD                     PixelShader;
1135   
1136   /* Indexed Vertex Blending */
1137   D3DVERTEXBLENDFLAGS       vertex_blend;
1138   FLOAT                     tween_factor;
1139
1140   /* Vertex Shader Constant */
1141   D3DSHADERVECTOR           vertexShaderConstant[D3D8_VSHADER_MAX_CONSTANTS];
1142   /* Pixel Shader Constant */
1143   D3DSHADERVECTOR           pixelShaderConstant[D3D8_PSHADER_MAX_CONSTANTS];
1144 };
1145
1146 /* exported Interfaces */
1147 /* internal Interfaces */
1148 /* temporary internal Interfaces */
1149 extern HRESULT WINAPI IDirect3DDeviceImpl_InitStartupStateBlock(IDirect3DDevice8Impl* This);
1150 extern HRESULT WINAPI IDirect3DDeviceImpl_CreateStateBlock(IDirect3DDevice8Impl* This, D3DSTATEBLOCKTYPE Type, IDirect3DStateBlockImpl** ppStateBlock);
1151 extern HRESULT WINAPI IDirect3DDeviceImpl_DeleteStateBlock(IDirect3DDevice8Impl* This, IDirect3DStateBlockImpl* pSB);
1152 extern HRESULT WINAPI IDirect3DDeviceImpl_BeginStateBlock(IDirect3DDevice8Impl* This);
1153 extern HRESULT WINAPI IDirect3DDeviceImpl_EndStateBlock(IDirect3DDevice8Impl* This, IDirect3DStateBlockImpl** ppStateBlock);
1154 extern HRESULT WINAPI IDirect3DDeviceImpl_ApplyStateBlock(IDirect3DDevice8Impl* iface, IDirect3DStateBlockImpl* pSB);
1155 extern HRESULT WINAPI IDirect3DDeviceImpl_CaptureStateBlock(IDirect3DDevice8Impl* This, IDirect3DStateBlockImpl* pSB);
1156
1157 /* ------------------------------------ */
1158 /* IDirect3DVertexShaderDeclarationImpl */
1159 /* ------------------------------------ */
1160
1161 /*****************************************************************************
1162  * Predeclare the interface implementation structures
1163  */
1164 /*extern ICOM_VTABLE(IDirect3DVertexShaderDeclaration9) Direct3DVertexShaderDeclaration9_Vtbl;*/
1165
1166 /*****************************************************************************
1167  * IDirect3DVertexShaderDeclaration implementation structure
1168  */
1169 struct IDirect3DVertexShaderDeclarationImpl {
1170   /* IUnknown fields */
1171   /*ICOM_VFIELD(IDirect3DVertexShaderDeclaration9);*/
1172   DWORD  ref;
1173
1174   /* The device, to be replaced by a IDirect3DDeviceImpl */
1175   IDirect3DDevice8Impl* device;
1176
1177   /** precomputed fvf if simple declaration */
1178   DWORD   fvf[MAX_STREAMS];
1179   DWORD   allFVF;
1180
1181   /** dx8 compatible Declaration fields */
1182   DWORD*  pDeclaration8;
1183   DWORD   declaration8Length;
1184 };
1185
1186 /* exported Interfaces */
1187 extern HRESULT WINAPI IDirect3DVertexShaderDeclarationImpl_GetDeclaration8(IDirect3DVertexShaderDeclarationImpl* This, DWORD* pData, UINT* pSizeOfData);
1188 /*extern HRESULT IDirect3DVertexShaderDeclarationImpl_GetDeclaration9(IDirect3DVertexShaderDeclarationImpl* This, D3DVERTEXELEMENT9* pData, UINT* pNumElements);*/
1189 /* internal Interfaces */
1190 /* temporary internal Interfaces */
1191 extern HRESULT WINAPI IDirect3DDeviceImpl_CreateVertexShaderDeclaration8(IDirect3DDevice8Impl* This, CONST DWORD* pDeclaration8, IDirect3DVertexShaderDeclarationImpl** ppVertexShaderDecl);
1192
1193
1194 /* ------------------------- */
1195 /* IDirect3DVertexShaderImpl */
1196 /* ------------------------- */
1197
1198 /*****************************************************************************
1199  * Predeclare the interface implementation structures
1200  */
1201 /*extern ICOM_VTABLE(IDirect3DVertexShader9) Direct3DVertexShader9_Vtbl;*/
1202
1203 /*****************************************************************************
1204  * IDirect3DVertexShader implementation structure
1205  */
1206 struct IDirect3DVertexShaderImpl {
1207   /*ICOM_VFIELD(IDirect3DVertexShader9);*/
1208   DWORD ref;
1209
1210   /* The device, to be replaced by a IDirect3DDeviceImpl */
1211   IDirect3DDevice8Impl* device;
1212
1213   DWORD* function;
1214   UINT functionLength;
1215   DWORD usage; /* 0 || D3DUSAGE_SOFTWAREPROCESSING */
1216   DWORD version;
1217   
1218   /** fields for hw vertex shader use */
1219   GLuint  prgId;
1220
1221   /* run time datas */
1222   VSHADERDATA8* data;
1223   VSHADERINPUTDATA8 input;
1224   VSHADEROUTPUTDATA8 output;
1225 };
1226
1227 /* exported Interfaces */
1228 extern HRESULT WINAPI IDirect3DVertexShaderImpl_GetFunction(IDirect3DVertexShaderImpl* This, VOID* pData, UINT* pSizeOfData);
1229 /*extern HRESULT WINAPI IDirect3DVertexShaderImpl_SetConstantB(IDirect3DVertexShaderImpl* This, UINT StartRegister, CONST BOOL*  pConstantData, UINT BoolCount);*/
1230 /*extern HRESULT WINAPI IDirect3DVertexShaderImpl_SetConstantI(IDirect3DVertexShaderImpl* This, UINT StartRegister, CONST INT*   pConstantData, UINT Vector4iCount);*/
1231 extern HRESULT WINAPI IDirect3DVertexShaderImpl_SetConstantF(IDirect3DVertexShaderImpl* This, UINT StartRegister, CONST FLOAT* pConstantData, UINT Vector4fCount);
1232 /*extern HRESULT WINAPI IDirect3DVertexShaderImpl_GetConstantB(IDirect3DVertexShaderImpl* This, UINT StartRegister, BOOL*  pConstantData, UINT BoolCount);*/
1233 /*extern HRESULT WINAPI IDirect3DVertexShaderImpl_GetConstantI(IDirect3DVertexShaderImpl* This, UINT StartRegister, INT*   pConstantData, UINT Vector4iCount);*/
1234 extern HRESULT WINAPI IDirect3DVertexShaderImpl_GetConstantF(IDirect3DVertexShaderImpl* This, UINT StartRegister, FLOAT* pConstantData, UINT Vector4fCount);
1235 /* internal Interfaces */
1236 extern DWORD WINAPI IDirect3DVertexShaderImpl_GetVersion(IDirect3DVertexShaderImpl* This);
1237 extern HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* This, VSHADERINPUTDATA8* input, VSHADEROUTPUTDATA8* output);
1238 /* temporary internal Interfaces */
1239 extern HRESULT WINAPI IDirect3DDeviceImpl_CreateVertexShader(IDirect3DDevice8Impl* This, CONST DWORD* pFunction, DWORD Usage, IDirect3DVertexShaderImpl** ppVertexShader);
1240 extern HRESULT WINAPI IDirect3DDeviceImpl_FillVertexShaderInputSW(IDirect3DDevice8Impl* This, IDirect3DVertexShaderImpl* vshader,  DWORD SkipnStrides);
1241 extern HRESULT WINAPI IDirect3DDeviceImpl_FillVertexShaderInputArbHW(IDirect3DDevice8Impl* This, IDirect3DVertexShaderImpl* vshader,  DWORD SkipnStrides);
1242
1243 /* ------------------------ */
1244 /* IDirect3DPixelShaderImpl */
1245 /* ------------------------ */
1246
1247 /*****************************************************************************
1248  * Predeclare the interface implementation structures
1249  */
1250 /*extern ICOM_VTABLE(IDirect3DPixelShader9) Direct3DPixelShader9_Vtbl;*/
1251
1252 /*****************************************************************************
1253  * IDirect3DPixelShader implementation structure
1254  */
1255 struct IDirect3DPixelShaderImpl { 
1256   /*ICOM_VFIELD(IDirect3DPixelShader9);*/
1257   DWORD ref;
1258
1259   /* The device, to be replaced by a IDirect3DDeviceImpl */
1260   IDirect3DDevice8Impl* device;
1261
1262   DWORD* function;
1263   UINT functionLength;
1264   DWORD version;
1265   /* run time datas */
1266   PSHADERDATA8* data;
1267   PSHADERINPUTDATA8 input;
1268   PSHADEROUTPUTDATA8 output;
1269 };
1270
1271 /* exported Interfaces */
1272 extern HRESULT WINAPI IDirect3DPixelShaderImpl_GetFunction(IDirect3DPixelShaderImpl* This, VOID* pData, UINT* pSizeOfData);
1273 /* internal Interfaces */
1274 extern DWORD WINAPI IDirect3DPixelShaderImpl_GetVersion(IDirect3DPixelShaderImpl* This);
1275 /* temporary internal Interfaces */
1276 extern HRESULT WINAPI IDirect3DDeviceImpl_CreatePixelShader(IDirect3DDevice8Impl* This, CONST DWORD* pFunction, IDirect3DPixelShaderImpl** ppPixelShader);
1277
1278
1279 /**
1280  * Internals functions
1281  *
1282  * to see how not defined it here
1283  */ 
1284 void   GetSrcAndOpFromValue(DWORD iValue, BOOL isAlphaArg, GLenum* source, GLenum* operand);
1285 void   setupTextureStates(LPDIRECT3DDEVICE8 iface, DWORD Stage, DWORD Flags);
1286 void   set_tex_op(LPDIRECT3DDEVICE8 iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3);
1287
1288 SHORT  D3DFmtGetBpp(IDirect3DDevice8Impl* This, D3DFORMAT fmt);
1289 GLint  D3DFmt2GLIntFmt(IDirect3DDevice8Impl* This, D3DFORMAT fmt);
1290 GLenum D3DFmt2GLFmt(IDirect3DDevice8Impl* This, D3DFORMAT fmt);
1291 GLenum D3DFmt2GLType(IDirect3DDevice8Impl* This, D3DFORMAT fmt);
1292
1293 GLenum D3DFmt2GLDepthFmt(D3DFORMAT fmt);
1294 GLenum D3DFmt2GLDepthType(D3DFORMAT fmt);
1295
1296 int D3DPrimitiveListGetVertexSize(D3DPRIMITIVETYPE PrimitiveType, int iNumPrim);
1297 int D3DPrimitive2GLenum(D3DPRIMITIVETYPE PrimitiveType);
1298 int D3DFVFGetSize(D3DFORMAT fvf);
1299
1300 int SOURCEx_RGB_EXT(DWORD arg);
1301 int OPERANDx_RGB_EXT(DWORD arg);
1302 int SOURCEx_ALPHA_EXT(DWORD arg);
1303 int OPERANDx_ALPHA_EXT(DWORD arg);
1304 GLenum StencilOp(DWORD op);
1305
1306 /**
1307  * Internals debug functions
1308  */
1309 const char* debug_d3ddevicetype(D3DDEVTYPE devtype);
1310 const char* debug_d3dusage(DWORD usage);
1311 const char* debug_d3dformat(D3DFORMAT fmt);
1312 const char* debug_d3dressourcetype(D3DRESOURCETYPE res);
1313 const char* debug_d3dprimitivetype(D3DPRIMITIVETYPE PrimitiveType);
1314 const char* debug_d3dpool(D3DPOOL Pool);
1315 const char *debug_d3drenderstate(DWORD State);
1316 const char *debug_d3dtexturestate(DWORD State);
1317
1318 /* Some #defines for additional diagnostics */
1319 #if 0 /* NOTE: Must be 0 in cvs */
1320   /* To avoid having to get gigabytes of trace, the following can be compiled in, and at the start
1321      of each frame, a check is made for the existence of C:\D3DTRACE, and if if exists d3d trace
1322      is enabled, and if it doesn't exists it is disabled.                                           */
1323 # define FRAME_DEBUGGING
1324   /*  Adding in the SINGLE_FRAME_DEBUGGING gives a trace of just what makes up a single frame, before
1325       the file is deleted                                                                            */
1326 # if 1 /* NOTE: Must be 1 in cvs, as this is mostly more useful than a trace from program start */
1327 #  define SINGLE_FRAME_DEBUGGING
1328 # endif  
1329   /* The following, when enabled, lets you see the makeup of the frame, by drawprimitive calls.
1330      It can only be enabled when FRAME_DEBUGGING is also enabled                               
1331      The contents of the back buffer are written into /tmp/backbuffer_* after each primitive 
1332      array is drawn.                                                                            */
1333 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */                                                                                       
1334 #  define SHOW_FRAME_MAKEUP 1
1335 # endif  
1336   /* The following, when enabled, lets you see the makeup of the all the textures used during each
1337      of the drawprimitive calls. It can only be enabled when SHOW_FRAME_MAKEUP is also enabled.
1338      The contents of the textures assigned to each stage are written into 
1339      /tmp/texture_*_<Stage>.ppm after each primitive array is drawn.                            */
1340 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
1341 #  define SHOW_TEXTURE_MAKEUP 0
1342 # endif  
1343 extern BOOL isOn;
1344 extern BOOL isDumpingFrames;
1345 extern LONG primCounter;
1346 #endif
1347
1348 /* Per-vertex trace: */
1349 #if 0 /* NOTE: Must be 0 in cvs */
1350 # define VTRACE(A) TRACE A
1351 #else 
1352 # define VTRACE(A) 
1353 #endif
1354
1355 #define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w);
1356 #define TRACE_STRIDED(sd,name) TRACE( #name "=(data:%p, stride:%ld, type:%ld)\n", sd->u.s.name.lpData, sd->u.s.name.dwStride, sd->u.s.name.dwType);
1357
1358 #define DUMP_LIGHT_CHAIN()                    \
1359 {                                             \
1360   PLIGHTINFOEL *el = This->StateBlock->lights;\
1361   while (el) {                                \
1362     TRACE("Light %p (glIndex %ld, d3dIndex %ld, enabled %d)\n", el, el->glIndex, el->OriginalIndex, el->lightEnabled);\
1363     el = el->next;                            \
1364   }                                           \
1365 }
1366
1367 #endif /* __WINE_D3DX8_PRIVATE_H */