Stub implementations for AbortPrinter, AddPortEx{A,W},
[wine] / dlls / wined3d / wined3d_private.h
1 /*
2  * Direct3D wine internal private include file
3  *
4  * Copyright 2002-2003 The wine-d3d team
5  * Copyright 2002-2003 Raphael Junqueira
6  * Copyright 2004      Jason Edmeades   
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_WINED3D_PRIVATE_H
24 #define __WINE_WINED3D_PRIVATE_H
25
26 #include <stdarg.h>
27 #include <math.h>
28 #define NONAMELESSUNION
29 #define NONAMELESSSTRUCT
30 #define COBJMACROS
31 #include "windef.h"
32 #include "winbase.h"
33 #include "winreg.h"
34 #include "wingdi.h"
35 #include "winuser.h"
36 #include "wine/debug.h"
37 #include "wine/unicode.h"
38
39 #include "d3d9.h"
40 #include "d3d9types.h"
41 #include "wine/wined3d_interface.h"
42 #include "wine/wined3d_gl.h"
43
44 extern int vs_mode;
45 #define VS_NONE 0
46 #define VS_HW   1
47 #define VS_SW   2
48
49 extern int ps_mode;
50 #define PS_NONE 0
51 #define PS_HW   1
52
53 /* X11 locking */
54
55 extern void (*wine_tsx11_lock_ptr)(void);
56 extern void (*wine_tsx11_unlock_ptr)(void);
57
58 /* As GLX relies on X, this is needed */
59 extern int num_lock;
60
61 #if 0
62 #define ENTER_GL() ++num_lock; if (num_lock > 1) FIXME("Recursive use of GL lock to: %d\n", num_lock); wine_tsx11_lock_ptr()
63 #define LEAVE_GL() if (num_lock != 1) FIXME("Recursive use of GL lock: %d\n", num_lock); --num_lock; wine_tsx11_unlock_ptr()
64 #else
65 #define ENTER_GL() wine_tsx11_lock_ptr()
66 #define LEAVE_GL() wine_tsx11_unlock_ptr()
67 #endif
68
69 /*****************************************************************************
70  * Defines
71  */
72
73 /* GL related defines */
74 /* ------------------ */
75 #define GL_SUPPORT(ExtName)           (GLINFO_LOCATION.supported[ExtName] != 0)
76 #define GL_LIMITS(ExtName)            (GLINFO_LOCATION.max_##ExtName)
77 #define GL_EXTCALL(FuncName)          (GLINFO_LOCATION.FuncName)
78
79 #define D3DCOLOR_R(dw) (((float) (((dw) >> 16) & 0xFF)) / 255.0f)
80 #define D3DCOLOR_G(dw) (((float) (((dw) >>  8) & 0xFF)) / 255.0f)
81 #define D3DCOLOR_B(dw) (((float) (((dw) >>  0) & 0xFF)) / 255.0f)
82 #define D3DCOLOR_A(dw) (((float) (((dw) >> 24) & 0xFF)) / 255.0f)
83
84 #define D3DCOLORTOGLFLOAT4(dw, vec) \
85   (vec)[0] = D3DCOLOR_R(dw); \
86   (vec)[1] = D3DCOLOR_G(dw); \
87   (vec)[2] = D3DCOLOR_B(dw); \
88   (vec)[3] = D3DCOLOR_A(dw);
89   
90 /* Note: The following is purely to keep the source code as clear from #ifdefs as possible */
91 #if defined(GL_VERSION_1_3)
92 #define GLACTIVETEXTURE(textureNo)                          \
93             glActiveTexture(GL_TEXTURE0 + textureNo);       \
94             checkGLcall("glActiveTexture");      
95 #define GLCLIENTACTIVETEXTURE(textureNo)                    \
96             glClientActiveTexture(GL_TEXTURE0 + textureNo);
97 #define GLMULTITEXCOORD1F(a,b)                              \
98             glMultiTexCoord1f(GL_TEXTURE0 + a, b);
99 #define GLMULTITEXCOORD2F(a,b,c)                            \
100             glMultiTexCoord2f(GL_TEXTURE0 + a, b, c);
101 #define GLMULTITEXCOORD3F(a,b,c,d)                          \
102             glMultiTexCoord3f(GL_TEXTURE0 + a, b, c, d);
103 #define GLMULTITEXCOORD4F(a,b,c,d,e)                        \
104             glMultiTexCoord4f(GL_TEXTURE0 + a, b, c, d, e);
105 #define GLTEXTURECUBEMAP GL_TEXTURE_CUBE_MAP
106 #else 
107 #define GLACTIVETEXTURE(textureNo)                             \
108             glActiveTextureARB(GL_TEXTURE0_ARB + textureNo);   \
109             checkGLcall("glActiveTextureARB");
110 #define GLCLIENTACTIVETEXTURE(textureNo)                    \
111             glClientActiveTextureARB(GL_TEXTURE0_ARB + textureNo);
112 #define GLMULTITEXCOORD1F(a,b)                                 \
113             glMultiTexCoord1fARB(GL_TEXTURE0_ARB + a, b);
114 #define GLMULTITEXCOORD2F(a,b,c)                               \
115             glMultiTexCoord2fARB(GL_TEXTURE0_ARB + a, b, c);
116 #define GLMULTITEXCOORD3F(a,b,c,d)                             \
117             glMultiTexCoord3fARB(GL_TEXTURE0_ARB + a, b, c, d);
118 #define GLMULTITEXCOORD4F(a,b,c,d,e)                           \
119             glMultiTexCoord4fARB(GL_TEXTURE0_ARB + a, b, c, d, e);
120 #define GLTEXTURECUBEMAP GL_TEXTURE_CUBE_MAP_ARB
121 #endif
122
123 /* DirectX Device Limits */
124 /* --------------------- */
125 #define MAX_LEVELS  256  /* Maximum number of mipmap levels. Guessed at 256 */
126
127 #define MAX_STREAMS  16  /* Maximum possible streams - used for fixed size arrays
128                             See MaxStreams in MSDN under GetDeviceCaps */
129 #define HIGHEST_TRANSFORMSTATE 512 
130                          /* Highest value in D3DTRANSFORMSTATETYPE */
131 #define HIGHEST_RENDER_STATE   209
132                          /* Highest D3DRS_ value                   */
133 #define HIGHEST_TEXTURE_STATE   32
134                          /* Highest D3DTSS_ value                  */
135 #define WINED3D_VSHADER_MAX_CONSTANTS  96   
136                          /* Maximum number of constants provided to the shaders */
137 #define MAX_CLIPPLANES  D3DMAXUSERCLIPPLANES
138
139 #define MAX_PALETTES      256
140
141 /* Checking of API calls */
142 /* --------------------- */
143 #define checkGLcall(A) \
144 { \
145     GLint err = glGetError();   \
146     if (err != GL_NO_ERROR) { \
147        FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", err, A, __FILE__, __LINE__); \
148     } else { \
149        TRACE("%s call ok %s / %d\n", A, __FILE__, __LINE__); \
150     } \
151 }
152
153 /* Trace routines / diagnostics */
154 /* ---------------------------- */
155
156 /* Dump out a matrix and copy it */
157 #define conv_mat(mat,gl_mat)                                                                \
158 do {                                                                                        \
159     TRACE("%f %f %f %f\n", (mat)->u.s._11, (mat)->u.s._12, (mat)->u.s._13, (mat)->u.s._14); \
160     TRACE("%f %f %f %f\n", (mat)->u.s._21, (mat)->u.s._22, (mat)->u.s._23, (mat)->u.s._24); \
161     TRACE("%f %f %f %f\n", (mat)->u.s._31, (mat)->u.s._32, (mat)->u.s._33, (mat)->u.s._34); \
162     TRACE("%f %f %f %f\n", (mat)->u.s._41, (mat)->u.s._42, (mat)->u.s._43, (mat)->u.s._44); \
163     memcpy(gl_mat, (mat), 16 * sizeof(float));                                              \
164 } while (0)
165
166 /* Macro to dump out the current state of the light chain */
167 #define DUMP_LIGHT_CHAIN()                    \
168 {                                             \
169   PLIGHTINFOEL *el = This->stateBlock->lights;\
170   while (el) {                                \
171     TRACE("Light %p (glIndex %ld, d3dIndex %ld, enabled %d)\n", el, el->glIndex, el->OriginalIndex, el->lightEnabled);\
172     el = el->next;                            \
173   }                                           \
174 }
175
176 /* Trace vector and strided data information */
177 #define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w);
178 #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);
179
180 /* Defines used for optimizations */
181
182 /*    Only reapply what is necessary */
183 #define REAPPLY_ALPHAOP  0x0001
184 #define REAPPLY_ALL      0xFFFF
185
186 /* Advance declaration of structures to satisfy compiler */
187 typedef struct IWineD3DStateBlockImpl IWineD3DStateBlockImpl;
188 typedef struct IWineD3DSurfaceImpl    IWineD3DSurfaceImpl;
189
190 /* Global variables */
191 extern const float identity[16];
192
193 /*****************************************************************************
194  * Compilable extra diagnostics
195  */
196
197 /* Trace information per-vertex: (extremely high amount of trace) */
198 #if 0 /* NOTE: Must be 0 in cvs */
199 # define VTRACE(A) TRACE A
200 #else 
201 # define VTRACE(A) 
202 #endif
203
204 /* Checking of per-vertex related GL calls */
205 #define vcheckGLcall(A) \
206 { \
207     GLint err = glGetError();   \
208     if (err != GL_NO_ERROR) { \
209        FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", err, A, __FILE__, __LINE__); \
210     } else { \
211        VTRACE(("%s call ok %s / %d\n", A, __FILE__, __LINE__)); \
212     } \
213 }
214
215 /* TODO: Confirm each of these works when wined3d move completed */
216 #if 0 /* NOTE: Must be 0 in cvs */
217   /* To avoid having to get gigabytes of trace, the following can be compiled in, and at the start
218      of each frame, a check is made for the existence of C:\D3DTRACE, and if if exists d3d trace
219      is enabled, and if it doesn't exists it is disabled.                                           */
220 # define FRAME_DEBUGGING
221   /*  Adding in the SINGLE_FRAME_DEBUGGING gives a trace of just what makes up a single frame, before
222       the file is deleted                                                                            */
223 # if 1 /* NOTE: Must be 1 in cvs, as this is mostly more useful than a trace from program start */
224 #  define SINGLE_FRAME_DEBUGGING
225 # endif  
226   /* The following, when enabled, lets you see the makeup of the frame, by drawprimitive calls.
227      It can only be enabled when FRAME_DEBUGGING is also enabled                               
228      The contents of the back buffer are written into /tmp/backbuffer_* after each primitive 
229      array is drawn.                                                                            */
230 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */                                                                                       
231 #  define SHOW_FRAME_MAKEUP 1
232 # endif  
233   /* The following, when enabled, lets you see the makeup of the all the textures used during each
234      of the drawprimitive calls. It can only be enabled when SHOW_FRAME_MAKEUP is also enabled.
235      The contents of the textures assigned to each stage are written into 
236      /tmp/texture_*_<Stage>.ppm after each primitive array is drawn.                            */
237 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
238 #  define SHOW_TEXTURE_MAKEUP 0
239 # endif  
240 extern BOOL isOn;
241 extern BOOL isDumpingFrames;
242 extern LONG primCounter;
243 #endif
244
245 /*****************************************************************************
246  * Prototypes
247  */
248
249 /* Routine common to the draw primitive and draw indexed primitive routines */
250 void drawPrimitive(IWineD3DDevice *iface,
251                     int PrimitiveType,
252                     long NumPrimitives,
253
254                     /* for Indexed: */
255                     long  StartVertexIndex,
256                     long  StartIdx,
257                     short idxBytes,
258                     const void *idxData,
259                     int   minIndex);
260
261 /*****************************************************************************
262  * Structures required to draw primitives 
263  */
264
265 typedef struct Direct3DStridedData {
266     BYTE     *lpData;        /* Pointer to start of data               */
267     DWORD     dwStride;      /* Stride between occurances of this data */
268     DWORD     dwType;        /* Type (as in D3DVSDT_TYPE)              */
269 } Direct3DStridedData;
270
271 typedef struct Direct3DVertexStridedData {
272     union {
273         struct {
274              Direct3DStridedData  position;
275              Direct3DStridedData  blendWeights;
276              Direct3DStridedData  blendMatrixIndices;
277              Direct3DStridedData  normal;
278              Direct3DStridedData  pSize;
279              Direct3DStridedData  diffuse;
280              Direct3DStridedData  specular;
281              Direct3DStridedData  texCoords[8];
282         } s;
283         Direct3DStridedData input[16];  /* Indexed by constants in D3DVSDE_REGISTER */
284     } u;
285 } Direct3DVertexStridedData;
286
287 /*****************************************************************************
288  * Internal representation of a light
289  */
290 typedef struct PLIGHTINFOEL PLIGHTINFOEL;
291 struct PLIGHTINFOEL {
292     WINED3DLIGHT OriginalParms; /* Note D3D8LIGHT == D3D9LIGHT */
293     DWORD        OriginalIndex;
294     LONG         glIndex;
295     BOOL         lightEnabled;
296     BOOL         changed;
297     BOOL         enabledChanged;
298
299     /* Converted parms to speed up swapping lights */
300     float                         lightPosn[4];
301     float                         lightDirn[4];
302     float                         exponent;
303     float                         cutoff;
304
305     PLIGHTINFOEL *next;
306     PLIGHTINFOEL *prev;
307 };
308
309 /*****************************************************************************
310  * IWineD3D implementation structure
311  */
312 typedef struct IWineD3DImpl
313 {
314     /* IUnknown fields */
315     IWineD3DVtbl           *lpVtbl;
316     DWORD                   ref;     /* Note: Ref counting not required */
317
318     /* WineD3D Information */
319     IUnknown               *parent;
320     UINT                    dxVersion;
321
322     /* GL Information */
323     BOOL                    isGLInfoValid;
324     WineD3D_GL_Info         gl_info;
325 } IWineD3DImpl;
326
327 extern IWineD3DVtbl IWineD3D_Vtbl;
328
329 /*****************************************************************************
330  * IWineD3DDevice implementation structure
331  */
332 typedef struct IWineD3DDeviceImpl
333 {
334     /* IUnknown fields      */
335     IWineD3DDeviceVtbl     *lpVtbl;
336     DWORD                   ref;     /* Note: Ref counting not required */
337
338     /* WineD3D Information  */
339     IUnknown               *parent;
340     IWineD3D               *wineD3D;
341
342     /* X and GL Information */
343     HWND                    win_handle;
344     Window                  win;
345     Display                *display;
346     GLXContext              glCtx;
347     XVisualInfo            *visInfo;
348     GLXContext              render_ctx;
349     Drawable                drawable;
350     GLint                   maxConcurrentLights;
351
352     /* Optimization */
353     BOOL                    modelview_valid;
354     BOOL                    proj_valid;
355     BOOL                    view_ident;        /* true iff view matrix is identity                */
356     BOOL                    last_was_rhw;      /* true iff last draw_primitive was in xyzrhw mode */
357     GLenum                  tracking_parm;     /* Which source is tracking current colour         */
358     LONG                    tracking_color;    /* used iff GL_COLOR_MATERIAL was enabled          */
359       #define                         DISABLED_TRACKING  0  /* Disabled                                 */
360       #define                         IS_TRACKING        1  /* tracking_parm is tracking diffuse color  */
361       #define                         NEEDS_TRACKING     2  /* Tracking needs to be enabled when needed */
362       #define                         NEEDS_DISABLE      3  /* Tracking needs to be disabled when needed*/
363     UINT                    srcBlend;
364     UINT                    dstBlend;
365     UINT                    alphafunc;
366     UINT                    stencilfunc;
367     BOOL                    texture_shader_active;  /* TODO: Confirm use is correct */
368
369     /* State block related */
370     BOOL                    isRecordingState;
371     IWineD3DStateBlockImpl *stateBlock;
372     IWineD3DStateBlockImpl *updateStateBlock;
373
374     /* Internal use fields  */
375     D3DDEVICE_CREATION_PARAMETERS   createParms;
376     D3DPRESENT_PARAMETERS           presentParms;
377     UINT                            adapterNo;
378     D3DDEVTYPE                      devType;
379
380     /* Render Target Support */
381     IWineD3DSurfaceImpl    *frontBuffer;
382     IWineD3DSurfaceImpl    *backBuffer;
383     IWineD3DSurfaceImpl    *depthStencilBuffer;
384
385     IWineD3DSurfaceImpl    *renderTarget;
386     IWineD3DSurfaceImpl    *stencilBufferTarget;
387
388     /* palettes texture management */
389     PALETTEENTRY                  palettes[MAX_PALETTES][256];
390     UINT                          currentPalette;
391
392     /* For rendering to a texture using glCopyTexImage */
393     BOOL                          renderUpsideDown;
394
395     /* Textures for when no other textures are mapped */
396     UINT                          dummyTextureName[8];
397
398 } IWineD3DDeviceImpl;
399
400 extern IWineD3DDeviceVtbl IWineD3DDevice_Vtbl;
401
402 /*****************************************************************************
403  * IWineD3DResource implementation structure
404  */
405 typedef struct IWineD3DResourceClass
406 {
407     /* IUnknown fields */
408     DWORD                   ref;     /* Note: Ref counting not required */
409
410     /* WineD3DResource Information */
411     IUnknown               *parent;
412     D3DRESOURCETYPE         resourceType;
413     IWineD3DDeviceImpl     *wineD3DDevice;
414
415 } IWineD3DResourceClass;
416
417 typedef struct IWineD3DResourceImpl
418 {
419     /* IUnknown & WineD3DResource Information     */
420     IWineD3DResourceVtbl   *lpVtbl;
421     IWineD3DResourceClass   resource;
422 } IWineD3DResourceImpl;
423
424 extern IWineD3DResourceVtbl IWineD3DResource_Vtbl;
425
426 /*****************************************************************************
427  * IWineD3DVertexBuffer implementation structure (extends IWineD3DResourceImpl)
428  */
429 typedef struct IWineD3DVertexBufferImpl
430 {
431     /* IUnknown & WineD3DResource Information     */
432     IWineD3DVertexBufferVtbl *lpVtbl;
433     IWineD3DResourceClass     resource;
434
435     /* WineD3DVertexBuffer specifics */
436     BYTE                     *allocatedMemory;
437     D3DVERTEXBUFFER_DESC      currentDesc;
438
439 } IWineD3DVertexBufferImpl;
440
441 extern IWineD3DVertexBufferVtbl IWineD3DVertexBuffer_Vtbl;
442
443 /*****************************************************************************
444  * IWineD3DIndexBuffer implementation structure (extends IWineD3DResourceImpl)
445  */
446 typedef struct IWineD3DIndexBufferImpl
447 {
448     /* IUnknown & WineD3DResource Information     */
449     IWineD3DIndexBufferVtbl *lpVtbl;
450     IWineD3DResourceClass     resource;
451
452     /* WineD3DVertexBuffer specifics */
453     BYTE                     *allocatedMemory;
454     D3DINDEXBUFFER_DESC       currentDesc;
455
456 } IWineD3DIndexBufferImpl;
457
458 extern IWineD3DIndexBufferVtbl IWineD3DIndexBuffer_Vtbl;
459
460 /*****************************************************************************
461  * IWineD3DBaseTexture implementation structure (extends IWineD3DResourceImpl)
462  */
463 typedef struct IWineD3DBaseTextureClass
464 {
465     UINT                    levels;
466     BOOL                    dirty;
467     D3DFORMAT               format;
468
469 } IWineD3DBaseTextureClass;
470
471 typedef struct IWineD3DBaseTextureImpl
472 {
473     /* IUnknown & WineD3DResource Information     */
474     IWineD3DBaseTextureVtbl  *lpVtbl;
475     IWineD3DResourceClass     resource;
476     IWineD3DBaseTextureClass  baseTexture;
477
478 } IWineD3DBaseTextureImpl;
479
480 extern IWineD3DBaseTextureVtbl IWineD3DBaseTexture_Vtbl;
481
482 /*****************************************************************************
483  * IWineD3DTexture implementation structure (extends IWineD3DBaseTextureImpl)
484  */
485 typedef struct IWineD3DTextureImpl
486 {
487     /* IUnknown & WineD3DResource/WineD3DBaseTexture Information     */
488     IWineD3DTextureVtbl      *lpVtbl;
489     IWineD3DResourceClass     resource;
490     IWineD3DBaseTextureClass  baseTexture;
491
492     /* IWineD3DTexture */
493     IWineD3DSurfaceImpl      *surfaces[MAX_LEVELS];
494     
495     UINT                      width;
496     UINT                      height;
497     DWORD                     usage;
498
499 } IWineD3DTextureImpl;
500
501 extern IWineD3DTextureVtbl IWineD3DTexture_Vtbl;
502
503 /*****************************************************************************
504  * IWineD3DCubeTexture implementation structure (extends IWineD3DBaseTextureImpl)
505  */
506 typedef struct IWineD3DCubeTextureImpl
507 {
508     /* IUnknown & WineD3DResource/WineD3DBaseTexture Information     */
509     IWineD3DCubeTextureVtbl  *lpVtbl;
510     IWineD3DResourceClass     resource;
511     IWineD3DBaseTextureClass  baseTexture;
512
513     /* IWineD3DCubeTexture */
514     IWineD3DSurfaceImpl      *surfaces[6][MAX_LEVELS];
515
516     UINT                      edgeLength;
517     DWORD                     usage;
518 } IWineD3DCubeTextureImpl;
519
520 extern IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl;
521
522 /*****************************************************************************
523  * IWineD3DVolume implementation structure (extends IUnknown)
524  */
525 typedef struct IWineD3DVolumeImpl
526 {
527     /* IUnknown fields */
528     IWineD3DVolumeVtbl     *lpVtbl;
529     DWORD                   ref;     /* Note: Ref counting not required */
530
531     /* WineD3DVolume Information */
532     IUnknown               *parent;
533     D3DRESOURCETYPE         resourceType;
534     IWineD3DDeviceImpl     *wineD3DDevice;
535
536     D3DVOLUME_DESC          currentDesc;
537     UINT                    textureName;
538     BYTE                   *allocatedMemory;
539     IUnknown               *container;
540     UINT                    bytesPerPixel;
541
542     BOOL                    lockable;
543     BOOL                    locked;
544     D3DBOX                  lockedBox;
545     D3DBOX                  dirtyBox;
546     BOOL                    dirty;
547
548
549 } IWineD3DVolumeImpl;
550
551 extern IWineD3DVolumeVtbl IWineD3DVolume_Vtbl;
552
553 /*****************************************************************************
554  * IWineD3DVolumeTexture implementation structure (extends IWineD3DBaseTextureImpl)
555  */
556 typedef struct IWineD3DVolumeTextureImpl
557 {
558     /* IUnknown & WineD3DResource/WineD3DBaseTexture Information     */
559     IWineD3DVolumeTextureVtbl *lpVtbl;
560     IWineD3DResourceClass     resource;
561     IWineD3DBaseTextureClass  baseTexture;
562
563     /* IWineD3DVolumeTexture */
564     IWineD3DVolumeImpl       *volumes[MAX_LEVELS];
565
566     UINT                      width;
567     UINT                      height;
568     UINT                      depth;
569     DWORD                     usage;
570 } IWineD3DVolumeTextureImpl;
571
572 extern IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl;
573
574 /*****************************************************************************
575  * IWineD3DSurface implementation structure
576  */
577 struct IWineD3DSurfaceImpl
578 {
579     /* IUnknown & IWineD3DResource Information     */
580     IWineD3DSurfaceVtbl      *lpVtbl;
581     IWineD3DResourceClass     resource;
582
583     /* IWineD3DSurface fields */
584     IUnknown                 *container;
585     D3DSURFACE_DESC           currentDesc;
586     UINT                      currentDesc_size; 
587     BYTE                     *allocatedMemory;
588
589     UINT                      textureName;
590     UINT                      bytesPerPixel;
591     
592     BOOL                      lockable;
593     BOOL                      locked;
594     RECT                      lockedRect;
595     RECT                      dirtyRect;
596     BOOL                      Dirty;
597     BOOL                      inTexture;
598     BOOL                      inPBuffer;
599 };
600
601 extern IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl;
602
603 /*****************************************************************************
604  * IWineD3DVertexDeclaration implementation structure
605  */
606 typedef struct IWineD3DVertexDeclarationImpl {
607  /* IUnknown  Information     */
608   IWineD3DVertexDeclarationVtbl *lpVtbl;
609   DWORD                   ref;     /* Note: Ref counting not required */
610
611   /** precomputed fvf if simple declaration */
612   IWineD3DDeviceImpl     *wineD3DDevice;
613   DWORD   fvf[MAX_STREAMS];
614   DWORD   allFVF;
615
616   /** dx8 compatible Declaration fields */
617   DWORD*  pDeclaration8;
618   DWORD   declaration8Length;
619
620   /** dx9+ */
621   D3DVERTEXELEMENT9* pDeclaration9;
622   UINT               declaration9NumElements;
623 } IWineD3DVertexDeclarationImpl;
624
625 extern IWineD3DVertexDeclarationVtbl IWineD3DVertexDeclaration_Vtbl;
626
627 /*****************************************************************************
628  * IWineD3DStateBlock implementation structure
629  */
630
631 /* Internal state Block for Begin/End/Capture/Create/Apply info  */
632 /*   Note: Very long winded but gl Lists are not flexible enough */
633 /*   to resolve everything we need, so doing it manually for now */
634 typedef struct SAVEDSTATES {
635         BOOL                      indices;
636         BOOL                      material;
637         BOOL                      fvf;
638         BOOL                      stream_source[MAX_STREAMS];
639         BOOL                      textures[8];
640         BOOL                      transform[HIGHEST_TRANSFORMSTATE];
641         BOOL                      viewport;
642         BOOL                      renderState[HIGHEST_RENDER_STATE];
643         BOOL                      textureState[8][HIGHEST_TEXTURE_STATE];
644         BOOL                      clipplane[MAX_CLIPPLANES];
645         BOOL                      vertexDecl;
646 } SAVEDSTATES;
647
648 struct IWineD3DStateBlockImpl
649 {
650     /* IUnknown fields */
651     IWineD3DStateBlockVtbl   *lpVtbl;
652     DWORD                     ref;     /* Note: Ref counting not required */
653     
654     /* IWineD3DStateBlock information */
655     IUnknown                 *parent;
656     IWineD3DDeviceImpl       *wineD3DDevice;
657     D3DSTATEBLOCKTYPE         blockType;
658
659     /* Array indicating whether things have been set or changed */
660     SAVEDSTATES               changed;
661     SAVEDSTATES               set;
662   
663     /* Drawing - Vertex Shader or FVF related */
664     DWORD                     fvf;
665     /* Vertex Shader Declaration */
666     IWineD3DVertexDeclaration* vertexDecl;
667
668     void                     *vertexShader; /* @TODO: Replace void * with IWineD3DVertexShader * */
669
670     /* Stream Source */
671     BOOL                      streamIsUP;
672     UINT                      stream_stride[MAX_STREAMS];
673     UINT                      stream_offset[MAX_STREAMS];
674     IWineD3DVertexBuffer     *stream_source[MAX_STREAMS];
675
676     /* Indices */
677     IWineD3DIndexBuffer*      pIndexData;
678     UINT                      baseVertexIndex; /* Note: only used for d3d8 */
679
680     /* Transform */
681     D3DMATRIX                 transforms[HIGHEST_TRANSFORMSTATE];
682
683     /* Lights */
684     PLIGHTINFOEL             *lights; /* NOTE: active GL lights must be front of the chain */
685     
686     /* Clipping */
687     double                    clipplane[MAX_CLIPPLANES][4];
688     WINED3DCLIPSTATUS         clip_status;
689
690     /* ViewPort */
691     WINED3DVIEWPORT           viewport;
692
693     /* Material */
694     WINED3DMATERIAL           material;
695
696     /* Indexed Vertex Blending */
697     D3DVERTEXBLENDFLAGS       vertex_blend;
698     FLOAT                     tween_factor;
699
700     /* RenderState */
701     DWORD                     renderState[HIGHEST_RENDER_STATE];
702
703     /* Texture */
704     IWineD3DBaseTexture      *textures[8];
705     int                       textureDimensions[8];
706
707     /* Texture State Stage */
708     DWORD                     textureState[8][HIGHEST_TEXTURE_STATE];
709
710 };
711
712 extern IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl;
713
714 /*****************************************************************************
715  * Utility function prototypes 
716  */
717
718 /* Trace routines */
719 const char* debug_d3dformat(D3DFORMAT fmt);
720 const char* debug_d3ddevicetype(D3DDEVTYPE devtype);
721 const char* debug_d3dresourcetype(D3DRESOURCETYPE res);
722 const char* debug_d3dusage(DWORD usage);
723 const char* debug_d3dprimitivetype(D3DPRIMITIVETYPE PrimitiveType);
724 const char* debug_d3drenderstate(DWORD state);
725 const char* debug_d3dtexturestate(DWORD state);
726 const char* debug_d3dpool(D3DPOOL pool);
727
728 /* Routines for GL <-> D3D values */
729 GLenum StencilOp(DWORD op);
730 void   set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3);
731 void   set_texture_matrix(const float *smat, DWORD flags);
732 void   GetSrcAndOpFromValue(DWORD iValue, BOOL isAlphaArg, GLenum* source, GLenum* operand);
733
734 SHORT  D3DFmtGetBpp(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
735 GLenum D3DFmt2GLFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
736 GLenum D3DFmt2GLType(IWineD3DDeviceImpl *This, D3DFORMAT fmt);
737 GLint  D3DFmt2GLIntFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
738
739 /*****************************************************************************
740  * To enable calling of inherited functions, requires prototypes 
741  *
742  * Note: Only require classes which are subclassed, ie resource, basetexture, 
743  */
744     /*** IUnknown methods ***/
745     extern HRESULT WINAPI IWineD3DResourceImpl_QueryInterface(IWineD3DResource *iface, REFIID riid, void** ppvObject);
746     extern ULONG WINAPI IWineD3DResourceImpl_AddRef(IWineD3DResource *iface);
747     extern ULONG WINAPI IWineD3DResourceImpl_Release(IWineD3DResource *iface);
748     /*** IWineD3DResource methods ***/
749     extern HRESULT WINAPI IWineD3DResourceImpl_GetParent(IWineD3DResource *iface, IUnknown **pParent);
750     extern HRESULT WINAPI IWineD3DResourceImpl_GetDevice(IWineD3DResource *iface, IWineD3DDevice ** ppDevice);
751     extern HRESULT WINAPI IWineD3DResourceImpl_SetPrivateData(IWineD3DResource *iface, REFGUID  refguid, CONST void * pData, DWORD  SizeOfData, DWORD  Flags);
752     extern HRESULT WINAPI IWineD3DResourceImpl_GetPrivateData(IWineD3DResource *iface, REFGUID  refguid, void * pData, DWORD * pSizeOfData);
753     extern HRESULT WINAPI IWineD3DResourceImpl_FreePrivateData(IWineD3DResource *iface, REFGUID  refguid);
754     extern DWORD WINAPI IWineD3DResourceImpl_SetPriority(IWineD3DResource *iface, DWORD  PriorityNew);
755     extern DWORD WINAPI IWineD3DResourceImpl_GetPriority(IWineD3DResource *iface);
756     extern void WINAPI IWineD3DResourceImpl_PreLoad(IWineD3DResource *iface);
757     extern D3DRESOURCETYPE WINAPI IWineD3DResourceImpl_GetType(IWineD3DResource *iface);
758
759
760     /*** IUnknown methods ***/
761     extern HRESULT WINAPI IWineD3DBaseTextureImpl_QueryInterface(IWineD3DBaseTexture *iface, REFIID riid, void** ppvObject);
762     extern ULONG WINAPI IWineD3DBaseTextureImpl_AddRef(IWineD3DBaseTexture *iface);
763     extern ULONG WINAPI IWineD3DBaseTextureImpl_Release(IWineD3DBaseTexture *iface);
764     /*** IWineD3DResource methods ***/
765     extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetParent(IWineD3DBaseTexture *iface, IUnknown **pParent);
766     extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetDevice(IWineD3DBaseTexture *iface, IWineD3DDevice ** ppDevice);
767     extern HRESULT WINAPI IWineD3DBaseTextureImpl_SetPrivateData(IWineD3DBaseTexture *iface, REFGUID  refguid, CONST void * pData, DWORD  SizeOfData, DWORD  Flags);
768     extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetPrivateData(IWineD3DBaseTexture *iface, REFGUID  refguid, void * pData, DWORD * pSizeOfData);
769     extern HRESULT WINAPI IWineD3DBaseTextureImpl_FreePrivateData(IWineD3DBaseTexture *iface, REFGUID  refguid);
770     extern DWORD WINAPI IWineD3DBaseTextureImpl_SetPriority(IWineD3DBaseTexture *iface, DWORD  PriorityNew);
771     extern DWORD WINAPI IWineD3DBaseTextureImpl_GetPriority(IWineD3DBaseTexture *iface);
772     extern void WINAPI IWineD3DBaseTextureImpl_PreLoad(IWineD3DBaseTexture *iface);
773     extern D3DRESOURCETYPE WINAPI IWineD3DBaseTextureImpl_GetType(IWineD3DBaseTexture *iface);
774     /*** IWineD3DBaseTexture methods ***/
775     extern DWORD WINAPI IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture *iface, DWORD LODNew);
776     extern DWORD WINAPI IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture *iface);
777     extern DWORD WINAPI IWineD3DBaseTextureImpl_GetLevelCount(IWineD3DBaseTexture *iface);
778     extern HRESULT WINAPI IWineD3DBaseTextureImpl_SetAutoGenFilterType(IWineD3DBaseTexture *iface, D3DTEXTUREFILTERTYPE FilterType);
779     extern D3DTEXTUREFILTERTYPE WINAPI IWineD3DBaseTextureImpl_GetAutoGenFilterType(IWineD3DBaseTexture *iface);
780     extern void WINAPI IWineD3DBaseTextureImpl_GenerateMipSubLevels(IWineD3DBaseTexture *iface);
781     extern BOOL WINAPI IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture *iface, BOOL);
782     extern BOOL WINAPI IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture *iface);
783
784
785 #if 0 /* Needs fixing during rework */
786
787 /*****************************************************************************
788  * IDirect3DVertexShader implementation structure
789  */
790 struct IDirect3DVertexShaderImpl {
791   /* The device */
792   /*IDirect3DDeviceImpl* device;*/
793
794   DWORD* function;
795   UINT functionLength;
796   DWORD usage;
797   DWORD version;
798   /* run time datas */
799   VSHADERDATA* data;
800   VSHADERINPUTDATA input;
801   VSHADEROUTPUTDATA output;
802 };
803
804
805 /*****************************************************************************
806  * IDirect3DPixelShader implementation structure
807  */
808 struct IDirect3DPixelShaderImpl { 
809   /* The device */
810   /*IDirect3DDeviceImpl* device;*/
811
812   DWORD* function;
813   UINT functionLength;
814   DWORD version;
815   /* run time datas */
816   PSHADERDATA* data;
817   PSHADERINPUTDATA input;
818   PSHADEROUTPUTDATA output;
819 };
820
821 #endif /* Needs fixing during rework */
822 #endif