1 /*==========================================================================;
3 * Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
6 * Content: Direct3D internal include file
14 * 05/11/95 stevela Initial rev with this header.
15 * 11/11/95 stevela Light code changed.
16 * 21/11/95 colinmc Made Direct3D aggregatable
17 * (so it can be QI'd off DirectDraw).
18 * 23/11/95 colinmc Made Direct3D textures and devices aggregatable
19 * (QI'd off DirectDrawSurfaces).
20 * 07/12/95 stevela Merged in Colin's changes.
21 * 10/12/95 stevela Removed AGGREGATE_D3D.
22 * Removed Validate macros from here. Now in d3dpr.h
23 * 02/03/96 colinmc Minor build fix
24 * 17/04/96 stevela Use ddraw.h externally and ddrawp.h internally
27 ***************************************************************************/
43 #if !defined(BUILD_RLAPI) && !defined(BUILD_DDDDK)
52 INDEX_BATCH_SCALE is the constant which is used by DrawIndexedPrim
53 to deterimine if the number of primitives being drawn is small
54 relative to the number of vertices being passed. If it is then
55 the prims are dereferenced in batches and sent to DrawPrim.
57 #define INDEX_BATCH_SCALE 2
60 typedef D3DCOLORMODEL D3DCOLORMODEL;
62 #define D3DCOLOR_RAMP D3DCOLOR_RAMP
63 #define D3DCOLOR_RGB D3DCOLOR_RGB
64 #define D3D_COLORMODEL D3D_COLORMODEL
66 #endif /* !BUILD_RLAPI */
69 typedef DWORD D3DI_BUFFERHANDLE, *LPD3DI_BUFFERHANDLE;
72 * Internal version of executedata
74 typedef struct _D3DI_ExecuteData {
76 D3DI_BUFFERHANDLE dwHandle; /* Handle allocated by driver */
79 DWORD dwInstructionOffset;
80 DWORD dwInstructionLength;
81 DWORD dwHVertexOffset;
82 D3DSTATUS dsStatus; /* Status after execute */
83 } D3DI_EXECUTEDATA, *LPD3DI_EXECUTEDATA;
86 * Internal version of lightdata and constants for flags
89 #define D3DLIGHTI_ATT0_IS_NONZERO (0x00010000)
90 #define D3DLIGHTI_ATT1_IS_NONZERO (0x00020000)
91 #define D3DLIGHTI_ATT2_IS_NONZERO (0x00040000)
92 #define D3DLIGHTI_LINEAR_FALLOFF (0x00080000)
93 #define D3DLIGHTI_UNIT_SCALE (0x00100000)
94 #define D3DLIGHTI_LIGHT_AT_EYE (0x00200000)
96 typedef struct _D3DI_LIGHT {
98 DWORD version; /* matches number on D3DLIGHT struct */
100 D3DVALUE red, green, blue, shade;
102 D3DVECTOR model_position;
104 D3DVECTOR model_direction;
106 D3DVECTOR model_eye; /* direction from eye in model space */
107 D3DVECTOR model_scale; /* model scale for proper range computations */
109 D3DVALUE range_squared;
111 D3DVALUE attenuation0;
112 D3DVALUE attenuation1;
113 D3DVALUE attenuation2;
114 D3DVALUE cos_theta_by_2;
115 D3DVALUE cos_phi_by_2;
117 } D3DI_LIGHT, *LPD3DI_LIGHT;
119 // @@BEGIN_MSINTERNAL
120 #if !defined(BUILD_RLAPI) && !defined(BUILD_DDDDK)
122 #ifdef BUILD_D3D_LAYER
126 typedef struct IUnknownVtbl D3DUNKNOWNCALLBACKS, *LPD3DUNKNOWNCALLBACKS;
127 typedef struct ID3DObjectVtbl D3DOBJECTVTBL, *LPD3DOBJECTVTBL;
128 typedef struct IDirect3DVtbl DIRECT3DCALLBACKS, *LPDIRECT3DCALLBACKS;
129 typedef struct IDirect3D2Vtbl DIRECT3D2CALLBACKS, *LPDIRECT3D2CALLBACKS;
130 typedef struct IDirect3DDeviceVtbl DIRECT3DDEVICECALLBACKS, *LPDIRECT3DDEVICECALLBACKS;
131 typedef struct IDirect3DDevice2Vtbl DIRECT3DDEVICE2CALLBACKS, *LPDIRECT3DDEVICE2CALLBACKS;
132 typedef struct IDirect3DExecuteBufferVtbl DIRECT3DEXECUTEBUFFERCALLBACKS, *LPDIRECT3DEXECUTEBUFFERCALLBACKS;
133 typedef struct IDirect3DLightVtbl DIRECT3DLIGHTCALLBACKS, *LPDIRECT3DLIGHTCALLBACKS;
134 typedef struct IDirect3DMaterialVtbl DIRECT3DMATERIALCALLBACKS, *LPDIRECT3DMATERIALCALLBACKS;
135 typedef struct IDirect3DMaterial2Vtbl DIRECT3DMATERIAL2CALLBACKS, *LPDIRECT3DMATERIAL2CALLBACKS;
136 typedef struct IDirect3DTextureVtbl DIRECT3DTEXTURECALLBACKS, *LPDIRECT3DTEXTURECALLBACKS;
137 typedef struct IDirect3DTexture2Vtbl DIRECT3DTEXTURE2CALLBACKS, *LPDIRECT3DTEXTURE2CALLBACKS;
138 typedef struct IDirect3DViewport2Vtbl DIRECT3DVIEWPORT2CALLBACKS, *LPDIRECT3DVIEWPORT2CALLBACKS;
144 typedef struct _DIRECT3DI *LPDIRECT3DI;
145 typedef struct _DIRECT3DDEVICEI *LPDIRECT3DDEVICEI;
146 typedef struct _DIRECT3DEXECUTEBUFFERI *LPDIRECT3DEXECUTEBUFFERI;
147 typedef struct _DIRECT3DLIGHTI *LPDIRECT3DLIGHTI;
148 typedef struct _DIRECT3DMATERIALI *LPDIRECT3DMATERIALI;
149 typedef struct _DIRECT3DTEXTUREI *LPDIRECT3DTEXTUREI;
150 typedef struct _DIRECT3DVIEWPORTI *LPDIRECT3DVIEWPORTI;
153 * If we have an aggregate Direct3D we need a structure to
154 * represent an interface distinct from the underlying
155 * object. This is that structure. None of this would be necessary
158 typedef struct _DIRECT3DUNKNOWNI
160 LPD3DUNKNOWNCALLBACKS lpVtbl;
163 typedef struct _DIRECT3DUNKNOWNI *LPDIRECT3DUNKNOWNI;
165 typedef struct _DIRECT3DOLDI
167 LPDIRECT3DCALLBACKS lpVtbl;
170 typedef struct _DIRECT3DOLDI *LPDIRECT3DOLDI;
173 * Internal version of Direct3D object; it has data after the vtable
175 typedef struct _DIRECT3DI
177 /*** Object Interface ***/
178 LPDIRECT3D2CALLBACKS lpVtbl; /* Pointer to callbacks */
179 int refCnt; /* Reference count object */
181 /*** Object Relations ***/
183 int numDevs;/* Number of devices */
184 LIST_ROOT(_devices, _DIRECT3DDEVICEI) devices;
185 /* Associated IDirect3DDevices */
188 int numViewports; /* Number of viewports */
189 LIST_ROOT(_viewports, _DIRECT3DVIEWPORTI) viewports;
190 /* Created IDirect3DViewports */
193 int numLights; /* Number of lights */
194 LIST_ROOT(_lights, _DIRECT3DLIGHTI) lights;
195 /* Created IDirect3DLights */
198 int numMaterials; /* Number of materials */
199 LIST_ROOT(_materials, _DIRECT3DMATERIALI) materials;
200 /* Created IDirect3DMaterials */
202 /*** Object Data ***/
203 unsigned long v_next; /* id of next viewport to be created */
204 RLDDIRegistry* lpReg; /* Registry */
207 * DirectDraw Interface
209 LPDDRAWI_DIRECTDRAW_INT lpDDInt;
212 * The special IUnknown interface for the aggregate that does
213 * not punt to the parent object.
215 LPUNKNOWN lpOwningIUnknown; /* The owning IUnknown */
216 DIRECT3DUNKNOWNI lpThisIUnknown; /* Our IUnknown interface */
217 DIRECT3DOLDI lpThisIDirect3D; /* Our IDirect3D interface */
219 DWORD dwVersion; /* 1 for legacy D3D, 2 for D3D2 */
223 * If we have an aggreate Direct3DDevice we need a structure to
224 * represent an interface distinct from the underlying
225 * object. This is that structure.
227 typedef struct _DIRECT3DDEVICEUNKNOWNI
229 LPDIRECT3DDEVICE2CALLBACKS lpVtbl;
230 LPDIRECT3DDEVICEI lpObj;
231 } DIRECT3DDEVICEUNKNOWNI;
232 typedef struct _DIRECT3DDEVICEUNKNOWNI *LPDIRECT3DDEVICEUNKNOWNI;
234 typedef struct _DIRECT3DDEVICEOLDI
236 LPDIRECT3DDEVICECALLBACKS lpVtbl;
237 LPDIRECT3DDEVICEI lpObj;
238 } DIRECT3DDEVICEOLDI;
239 typedef struct _DIRECT3DDEVICEOLDI *LPDIRECT3DDEVICEOLDI;
242 * Internal version of Direct3DDevice object; it has data after the vtable
247 typedef RLDDIDriver* (*RLDDIDDrawCreateDriverFn)(
248 LPDDRAWI_DIRECTDRAW_INT lpDDInt,
249 LPDIRECTDRAWSURFACE lpDDS,
250 LPDIRECTDRAWSURFACE lpZ,
251 LPDIRECTDRAWPALETTE lpPal,
254 typedef HRESULT (*RLDDIGetCapsFn)(LPD3DDEVICEDESC*, LPD3DDEVICEDESC*);
255 typedef void (*RLDDIInitFn)(RLDDIMallocFn, RLDDIReallocFn, RLDDIFreeFn, RLDDIRaiseFn, RLDDIValue**, int, int);
256 typedef void (*RLDDIPushDriverFn)(RLDDIDriverStack*, RLDDIDriver*);
257 typedef void (*RLDDIPopDriverFn)(RLDDIDriverStack*);
259 struct _RLDDIGenRasDriver;
260 typedef struct _RLDDIGenRasDriver* LPRLDDIGENRASDRIVER;
261 struct _RLDDIDDrawDriver;
262 typedef struct _RLDDIDDrawDriver* LPRLDDIDDRAWDRIVER;
264 struct _RLDDITransformDriver;
265 typedef struct _RLDDITransformDriver* LPRLDDITRANSFORMDRIVER;
267 typedef HRESULT (*PFNLOCKTEXTURE)(LPRLDDIGENRASDRIVER driver);
268 typedef void (*PFNUNLOCKTEXTURE)(LPRLDDIGENRASDRIVER driver);
269 typedef int (*PFNSETFILLPARAMS)(LPRLDDIGENRASDRIVER driver, D3DSTATE* in_params,
271 typedef HRESULT (*PFNREALLOCALIGNED)(void** p_inout, size_t size);
272 typedef HRESULT (*PFNMALLOCALIGNED)(void** p_inout, size_t size);
273 typedef HRESULT (*PFNFREEALIGNED)(void* p_inout);
274 typedef HRESULT (*PFNDRVSETRENDERTARGET)(LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE,
275 LPDIRECTDRAWPALETTE, LPDIRECT3DDEVICEI);
276 typedef HRESULT (*PFNDOFLUSHBEGINEND)(LPDIRECT3DDEVICE2, DWORD);
277 typedef HRESULT (*PFNDRAWPRIMITIVES)(LPDIRECT3DDEVICEI, LPD3DTLVERTEX, LPVOID, LPD3DINSTRUCTION, DWORD);
280 typedef struct _D3DI_TEXTUREBLOCK
282 LIST_MEMBER(_D3DI_TEXTUREBLOCK) list;
283 /* Next block in IDirect3DTexture */
284 LIST_MEMBER(_D3DI_TEXTUREBLOCK) devList;
285 /* Next block in IDirect3DDevice */
286 LPDIRECT3DDEVICEI lpD3DDeviceI;
287 LPDIRECT3DTEXTUREI lpD3DTextureI;
288 D3DTEXTUREHANDLE hTex;
291 typedef struct _D3DI_TEXTUREBLOCK *LPD3DI_TEXTUREBLOCK;
293 typedef struct _D3DI_MATERIALBLOCK
295 LIST_MEMBER(_D3DI_MATERIALBLOCK) list;
296 /* Next block in IDirect3DMaterial */
297 LIST_MEMBER(_D3DI_MATERIALBLOCK) devList;
298 /* Next block in IDirect3DDevice */
299 LPDIRECT3DDEVICEI lpD3DDeviceI;
300 LPDIRECT3DMATERIALI lpD3DMaterialI;
301 D3DMATERIALHANDLE hMat;
302 /* material handle */
303 } D3DI_MATERIALBLOCK;
304 typedef struct _D3DI_MATERIALBLOCK *LPD3DI_MATERIALBLOCK;
306 #define D3D_RSTATEBUF_SIZE 128
307 #define D3D_MAX_RSTATES 96 /* Last render state ID + 1 */
308 #define D3D_MAX_MMX_VERTICES 1024
310 extern DWORD dwD3DTriBatchSize, dwTriBatchSize, dwLineBatchSize;
311 extern DWORD dwHWBufferSize, dwHWMaxTris;
312 extern DWORD dwHWFewVertices;
314 typedef struct _D3DHAL_DRAWPRIMCOUNTS *LPD3DHAL_DRAWPRIMCOUNTS;
316 // Legacy HAL batching is done with these structs.
317 typedef struct _D3DI_HWCOUNTS {
318 WORD wNumStateChanges; // Number of state changes batched
319 WORD wNumVertices; // Number of vertices in tri list
320 WORD wNumTriangles; // Number of triangles in tri list
321 } D3DI_HWCOUNTS, *LPD3DI_HWCOUNTS;
323 typedef struct _DIRECT3DDEVICEI
325 /*** Object Interface ***/
326 LPDIRECT3DDEVICE2CALLBACKS lpVtbl; /* Pointer to callbacks */
327 int refCnt; /* Reference count */
329 /*** Object Relations ***/
330 LPDIRECT3DI lpDirect3DI; /* parent */
331 LIST_MEMBER(_DIRECT3DDEVICEI)list; /* Next device IDirect3D */
334 LIST_ROOT(_textures, _D3DI_TEXTUREBLOCK) texBlocks;
335 /* Ref to created IDirect3DTextures */
337 /* Execute buffers */
338 LIST_ROOT(_buffers, _DIRECT3DEXECUTEBUFFERI) buffers;
339 /* Created IDirect3DExecuteBuffers */
343 CIRCLE_QUEUE_ROOT(_dviewports, _DIRECT3DVIEWPORTI) viewports;
344 /* Associated IDirect3DViewports */
345 LPDIRECT3DVIEWPORT2 lpCurrentViewport;
348 LIST_ROOT(_dmmaterials, _D3DI_MATERIALBLOCK) matBlocks;
349 /* Ref to associated IDirect3DMaterials */
351 /*** Object Data ***/
352 /* Private interfaces */
353 LPD3DOBJECTVTBL lpClassVtbl; /* Private Vtbl */
354 LPD3DOBJECTVTBL lpObjVtbl; /* Private Vtbl */
356 LPD3DHAL_CALLBACKS lpD3DHALCallbacks; /* HW specific */
357 LPD3DHAL_GLOBALDRIVERDATA lpD3DHALGlobalDriverData; /* HW specific */
360 unsigned long v_id; /* ID of last viewport rendered */
364 /* This indicates the maximum number
365 of lights that have been set in
368 /* Device characteristics */
373 unsigned long red_mask, green_mask, blue_mask;
376 int ramp_size; /* SW specific */
377 D3DCOLORMODEL color_model;
378 int wireframe_options;
379 D3DTEXTUREFILTER texture_quality;
381 unsigned char gamma_table[256];
382 int aspectx, aspecty;
383 D3DVALUE perspective_tolerance;
385 /* Library information */
388 char dllname[MAXPATH];
395 /* Are we in a scene? */
398 /* Our Device type */
401 /* GetCaps function from the library */
402 RLDDIGetCapsFn GetCapsFn;
404 /* Functions required to build driver */
405 RLDDIInitFn RLDDIInit;
406 RLDDIPushDriverFn RLDDIPushDriver;
407 RLDDIPopDriverFn RLDDIPopDriver;
408 RLDDIDDrawCreateDriverFn RLDDIDDrawCreateDriver;
410 /* Device description */
411 D3DDEVICEDESC d3dHWDevDesc;
412 D3DDEVICEDESC d3dHELDevDesc;
415 RLDDIDriverStack* stack;
418 * The special IUnknown interface for the aggregate that does
419 * not punt to the parent object.
421 LPUNKNOWN lpOwningIUnknown; /* The owning IUnknown */
422 DIRECT3DDEVICEUNKNOWNI lpThisIUnknown; /* Our IUnknown interface */
423 DIRECT3DDEVICEOLDI lpThisID3DDev; /* Our IDirect3DDevice interface */
425 LPD3DHAL_CALLBACKS2 lpD3DHALCallbacks2; /* HW specific */
428 * Renderstate cache for DrawPrimitive
430 WORD wRStateBufLevel;
431 D3DSTATE renStateBuf[D3D_RSTATEBUF_SIZE];
433 /* Pointers to drivers used by DrawPrimitive */
434 LPRLDDIGENRASDRIVER rasDriver; /* SW specific */
435 LPRLDDITRANSFORMDRIVER xfmDriver; /* Assumed to be NULL for HW */
436 LPRLDDIDDRAWDRIVER drawDriver; /* Assumed to be NULL for HW */
439 * Pointers to functions used by DrawPrim&Begin/End
442 PFNLOCKTEXTURE pfnLockTexture; /* SW specific */
443 PFNUNLOCKTEXTURE pfnUnlockTexture; /* SW specific */
444 PFNSETFILLPARAMS pfnSetFillParams; /* SW specific */
445 PFNREALLOCALIGNED pfnReallocAligned; /* SW specific */
446 PFNDRVSETRENDERTARGET pfnDrvSetRenderTarget; /* SW specific */
447 HRESULT (*pfnFlushStates)(struct _DIRECT3DDEVICEI*);
448 PFNDOFLUSHBEGINEND pfnDoFlushBeginEnd;
449 PFNDRAWPRIMITIVES pfnDrawPrimitives;
451 /* Are we between Begin/End? */
453 D3DVERTEXTYPE vtVertexType;
454 D3DPRIMITIVETYPE ptPrimitiveType;
455 CRITICAL_SECTION BeginEndCSect;
457 // max number of vertices
458 #define BEGIN_DATA_BLOCK_SIZE 256
460 LPVOID lpvVertexBatch;
463 // lpvVertexData is non-NULL if we are InBegin and indexed.
464 LPVOID lpvVertexData;
466 DWORD dwMaxVertexCount; // current number of vertices there is space for
467 WORD *lpVertexIndices;
469 DWORD dwMaxIndexCount; // current number of indices there is space for
475 * DrawPrimitives batching
479 // Buffer to put DrawPrimitives stuff into
480 // Used for both legacy and DrawPrimitive HALs
482 WORD *lpwDPBufferAlloced;
485 // pointer to current prim counts struct
486 LPD3DHAL_DRAWPRIMCOUNTS lpDPPrimCounts;
488 // Buffer of counts structures that keep track of the
489 // number of render states and vertices buffered
490 LPD3DI_HWCOUNTS lpHWCounts;
492 // Buffer of triangle structures.
493 LPD3DTRIANGLE lpHWTris;
495 // Buffer of interleaved render states and primitives.
496 LPD3DTLVERTEX lpHWVertices;
498 // Byte offset into lpHWVertices. This gets incremented
499 // by 8 when a render state is batched and by 32*dwNumVertices
500 // when a primitive is batched.
503 // Max value of dwHWOffset. Used to decide whether to flush.
506 // Index into lpHWTris.
509 // Number of counts structures used so far. This actually
510 // gives the number of primitives batched and the index of
511 // the counts structure to batch render states into.
514 /* DrawPrimitive-aware HALs */
516 // Byte offset into buffer (we are currently
517 // using the device's wTriIndex)
520 // Maximum offset. If dwDPOffset exceeds this, it is
526 // buffers for TL and H vertices
527 LPD3DTLVERTEX lpTLVbuf;
528 LPD3DHVERTEX lpHVbuf;
531 LPD3DHAL_D3DEXTENDEDCAPS lpD3DExtendedCaps; /* HW specific */
536 * Internal version of Direct3DExecuteBuffer object;
537 * it has data after the vtable
539 typedef struct _DIRECT3DEXECUTEBUFFERI
541 /*** Object Interface ***/
542 LPDIRECT3DEXECUTEBUFFERCALLBACKS lpVtbl; /* Pointer to callbacks */
543 int refCnt; /* Reference count */
545 /*** Object Relations ***/
546 LPDIRECT3DDEVICEI lpD3DDeviceI; /* Parent */
547 LIST_MEMBER(_DIRECT3DEXECUTEBUFFERI)list;
548 /* Next buffer in IDirect3D */
550 /*** Object Data ***/
551 DWORD pid; /* Process locking execute buffer */
552 D3DEXECUTEBUFFERDESC debDesc;
553 /* Description of the buffer */
554 D3DEXECUTEDATA exData; /* Execute Data */
555 BOOL locked; /* Is the buffer locked */
557 D3DI_BUFFERHANDLE hBuf;
558 /* Execute buffer handle */
559 } DIRECT3DEXECUTEBUFFERI;
562 * Internal version of Direct3DLight object;
563 * it has data after the vtable
565 typedef struct _DIRECT3DLIGHTI
567 /*** Object Interface ***/
568 LPDIRECT3DLIGHTCALLBACKS lpVtbl; /* Pointer to callbacks */
569 int refCnt; /* Reference count */
571 /*** Object Relations ***/
572 LPDIRECT3DI lpDirect3DI; /* Parent */
573 LIST_MEMBER(_DIRECT3DLIGHTI)list;
574 /* Next light in IDirect3D */
576 LPDIRECT3DVIEWPORTI lpD3DViewportI; /* Guardian */
577 CIRCLE_QUEUE_MEMBER(_DIRECT3DLIGHTI)light_list;
578 /* Next light in IDirect3DViewport */
580 /*** Object Data ***/
581 D3DLIGHT2 dlLight;/* Data describing light */
582 D3DI_LIGHT diLightData;
583 /* Internal representation of light */
586 typedef struct _DIRECT3DMATERIALOLDI
588 LPDIRECT3DMATERIALCALLBACKS lpVtbl;
589 LPDIRECT3DMATERIALI lpObj;
590 } DIRECT3DMATERIALOLDI, *LPDIRECT3DMATERIALOLDI;
593 * Internal version of Direct3DMaterial object;
594 * it has data after the vtable
596 typedef struct _DIRECT3DMATERIALI
598 /*** Object Interface ***/
599 LPDIRECT3DMATERIAL2CALLBACKS lpVtbl; /* Pointer to callbacks */
600 int refCnt; /* Reference count */
602 /*** Object Relations ***/
603 LPDIRECT3DI lpDirect3DI; /* Parent */
604 DIRECT3DMATERIALOLDI lpThisID3DMat; /* Our IDirect3DMaterial interface */
605 LIST_MEMBER(_DIRECT3DMATERIALI)list;
606 /* Next MATERIAL in IDirect3D */
608 LIST_ROOT(_mblocks, _D3DI_MATERIALBLOCK)blocks;
609 /* devices we're associated with */
611 /*** Object Data ***/
612 D3DMATERIAL dmMaterial; /* Data describing material */
613 BOOL bRes; /* Is this material reserved in the driver */
617 * If we have an aggreate Direct3DTexture we need a structure
618 * to represent an unknown interface distinct from the underlying
619 * object. This is that structure.
621 typedef struct _DIRECT3DTEXTUREUNKNOWNI
623 LPDIRECT3DTEXTURECALLBACKS lpVtbl;
624 LPDIRECT3DTEXTUREI lpObj;
625 } DIRECT3DTEXTUREUNKNOWNI;
626 typedef struct _DIRECT3DTEXTUREUNKNOWNI *LPDIRECT3DTEXTUREUNKNOWNI;
628 typedef struct _DIRECT3DTEXTUREOLDI
630 LPDIRECT3DTEXTURECALLBACKS lpVtbl;
631 LPDIRECT3DTEXTUREI lpObj;
632 } DIRECT3DTEXTUREOLDI, *LPDIRECT3DTEXTUREOLDI;
635 * Internal version of Direct3DTexture object; it has data after the vtable
637 typedef struct _DIRECT3DTEXTUREI
639 /*** Object Interface ***/
640 LPDIRECT3DTEXTURE2CALLBACKS lpVtbl; /* Pointer to callbacks */
641 int refCnt; /* Reference count */
644 /*** Object Relations ***/
645 LIST_ROOT(_blocks, _D3DI_TEXTUREBLOCK) blocks;
646 /* Devices we're associated with */
648 /*** Object Data ***/
649 LPDIRECTDRAWSURFACE lpDDS;
652 * The special IUnknown interface for the aggregate that does
653 * not punt to the parent object.
655 LPUNKNOWN lpOwningIUnknown; /* The owning IUnknown */
656 DIRECT3DTEXTUREUNKNOWNI lpThisIUnknown; /* Our IUnknown interface */
657 DIRECT3DTEXTUREOLDI lpThisID3DTex; /* Our IDirect3DTexture interface */
663 * Internal version of Direct3DViewport object; it has data after the vtable
665 typedef struct _DIRECT3DVIEWPORTI
667 /*** Object Interface ***/
668 LPDIRECT3DVIEWPORT2CALLBACKS lpVtbl; /* Pointer to callbacks */
669 int refCnt; /* Reference count */
671 /*** Object Relations */
672 LPDIRECT3DI lpDirect3DI; /* Parent */
673 LIST_MEMBER(_DIRECT3DVIEWPORTI)list;
674 /* Next viewport in IDirect3D */
676 LPDIRECT3DDEVICEI lpD3DDeviceI; /* Guardian */
677 CIRCLE_QUEUE_MEMBER(_DIRECT3DVIEWPORTI)vw_list;
678 /* Next viewport in IDirect3DDevice */
682 CIRCLE_QUEUE_ROOT(_dlights, _DIRECT3DLIGHTI) lights;
683 /* Associated IDirect3DLights */
685 /*** Object Data ***/
686 unsigned long v_id; /* Id for this viewport */
690 BOOL have_background;
691 D3DMATERIALHANDLE background;
692 /* Background material */
694 LPDIRECTDRAWSURFACE depth; /* Background depth */
697 /* Have the lights changed since they
698 were last collected? */
699 DWORD clrCount; /* Number of rects allocated */
700 LPD3DRECT clrRects; /* Rects used for clearing */
706 typedef struct _D3DI_PICKDATA {
707 D3DI_EXECUTEDATA* exe;
708 D3DPICKRECORD* records;
711 } D3DI_PICKDATA, *LPD3DI_PICKDATA;
714 * Direct3D memory allocation
718 * Register a set of functions to be used in place of malloc, realloc
719 * and free for memory allocation. The functions D3DMalloc, D3DRealloc
720 * and D3DFree will use these functions. The default is to use the
721 * ANSI C library routines malloc, realloc and free.
723 typedef LPVOID (*D3DMALLOCFUNCTION)(size_t);
724 typedef LPVOID (*D3DREALLOCFUNCTION)(LPVOID, size_t);
725 typedef VOID (*D3DFREEFUNCTION)(LPVOID);
728 * Allocate size bytes of memory and return a pointer to it in *p_return.
729 * Returns D3DERR_BADALLOC with *p_return unchanged if the allocation fails.
731 extern __declspec (dllexport) HRESULT D3DAPI D3DMalloc(LPVOID* p_return, size_t size);
734 * Change the size of an allocated block of memory. A pointer to the
735 * block is passed in in *p_inout. If *p_inout is NULL then a new
736 * block is allocated. If the reallocation is successful, *p_inout is
737 * changed to point to the new block. If the allocation fails,
738 * *p_inout is unchanged and D3DERR_BADALLOC is returned.
740 HRESULT D3DAPI D3DRealloc(LPVOID* p_inout, size_t size);
743 * Free a block of memory previously allocated with D3DMalloc or
746 extern __declspec (dllexport) VOID D3DAPI D3DFree(LPVOID p);
749 * Used for raising errors from the driver.
751 HRESULT D3DAPI D3DRaise(HRESULT);
754 * Convert RLDDI error codes to D3D error codes
756 #define RLDDITOD3DERR(_errcode) (RLDDIToD3DErrors[_errcode])
757 extern HRESULT RLDDIToD3DErrors[];
762 #if 1 /* defined(STACK_CALL) && defined(__WATCOMC__) */
763 D3DVALUE D3DIPow(D3DVALUE, D3DVALUE);
765 #define D3DIPow(v,p) DTOVAL(pow(VALTOD(v), VALTOD(p)))
771 void D3DI_DeviceMarkLightEnd(LPDIRECT3DDEVICEI, int);
772 void D3DI_UpdateLightInternal(LPDIRECT3DLIGHTI);
773 void D3DI_VectorNormalise12(LPD3DVECTOR v);
774 D3DTEXTUREHANDLE D3DI_FindTextureHandle(LPDIRECT3DTEXTUREI, LPDIRECT3DDEVICEI);
775 void D3DI_SetTextureHandle(LPDIRECT3DTEXTUREI, LPDIRECT3DDEVICEI, D3DTEXTUREHANDLE);
776 void D3DI_RemoveTextureBlock(LPD3DI_TEXTUREBLOCK);
777 void D3DI_RemoveMaterialBlock(LPD3DI_MATERIALBLOCK);
779 extern BOOL D3DI_isHALValid(LPD3DHAL_CALLBACKS);
781 #ifdef BUILD_D3D_LAYER
782 extern RLDDIValue* RLDDIFInvSqrtTable;
789 #endif /* BUILD_HEL */
790 #endif /* !BUILD_RLAPI */