1 /* Direct3D ExecuteBuffer
4 This files contains the implementation of Direct3DExecuteBuffer. */
10 #include "wine/obj_base.h"
16 #include "d3d_private.h"
20 /* Structure to store the 'semi transformed' vertices */
48 static IDirect3DExecuteBuffer_VTable executebuffer_vtable;
50 /*******************************************************************************
51 * ExecuteBuffer static functions
53 void _dump_d3dstatus(LPD3DSTATUS lpStatus) {
57 void _dump_executedata(LPD3DEXECUTEDATA lpData) {
58 DUMP("dwSize : %ld\n", lpData->dwSize);
59 DUMP("Vertex Offset : %ld Count : %ld\n", lpData->dwVertexOffset, lpData->dwVertexCount);
60 DUMP("Instruction Offset : %ld Length : %ld\n", lpData->dwInstructionOffset, lpData->dwInstructionLength);
61 DUMP("HVertex Offset : %ld\n", lpData->dwHVertexOffset);
62 _dump_d3dstatus(&(lpData->dsStatus));
65 #define DO_VERTEX(index) \
67 glTexCoord2f(vx[index].u, \
69 glNormal3f(vx[index].nx, \
72 glVertex4f(vx[index].x, \
77 TRACE(ddraw, " V: %f %f %f %f (%f %f %f) (%f %f)\n", \
78 vx[index].x, vx[index].y, vx[index].z, vx[index].w, \
79 vx[index].nx, vx[index].ny, vx[index].nz, \
80 vx[index].u, vx[index].v); \
83 #define DO_LVERTEX(index) \
85 DWORD col = l_vx[index].c; \
87 glColor3f(((col >> 16) & 0xFF) / 255.0, \
88 ((col >> 8) & 0xFF) / 255.0, \
89 ((col >> 0) & 0xFF) / 255.0); \
90 glTexCoord2f(l_vx[index].u, \
92 glVertex4f(l_vx[index].x, \
97 TRACE(ddraw, " LV: %f %f %f %f (%02lx %02lx %02lx) (%f %f)\n", \
98 l_vx[index].x, l_vx[index].y, l_vx[index].z, l_vx[index].w, \
99 ((col >> 16) & 0xFF), ((col >> 8) & 0xFF), ((col >> 0) & 0xFF), \
100 l_vx[index].u, l_vx[index].v); \
103 #define DO_TLVERTEX(index) \
105 D3DTLVERTEX *vx = &(tl_vx[index]); \
106 DWORD col = vx->c.color; \
108 glColor3f(((col >> 16) & 0xFF) / 255.0, \
109 ((col >> 8) & 0xFF) / 255.0, \
110 ((col >> 0) & 0xFF) / 255.0); \
111 glTexCoord2f(vx->u.tu, vx->v.tv); \
112 if (vx->r.rhw < 0.01) \
113 glVertex3f(vx->x.sx, \
117 glVertex4f(vx->x.sx / vx->r.rhw, \
118 vx->y.sy / vx->r.rhw, \
119 vx->z.sz / vx->r.rhw, \
121 TRACE(ddraw, " TLV: %f %f %f (%02lx %02lx %02lx) (%f %f) (%f)\n", \
122 vx->x.sx, vx->y.sy, vx->z.sz, \
123 ((col >> 16) & 0xFF), ((col >> 8) & 0xFF), ((col >> 0) & 0xFF), \
124 vx->u.tu, vx->v.tv, vx->r.rhw); \
127 #define TRIANGLE_LOOP(macro) \
129 glBegin(GL_TRIANGLES); { \
130 for (i = 0; i < count; i++) { \
131 LPD3DTRIANGLE ci = (LPD3DTRIANGLE) instr; \
133 TRACE(ddraw, " v1: %d v2: %d v3: %d\n", \
134 ci->v1.v1, ci->v2.v2, ci->v3.v3); \
135 TRACE(ddraw, " Flags : "); \
136 if (TRACE_ON(ddraw)) { \
138 if (ci->wFlags & D3DTRIFLAG_EDGEENABLE1) \
139 DUMP("EDGEENABLE1 "); \
140 if (ci->wFlags & D3DTRIFLAG_EDGEENABLE2) \
141 DUMP("EDGEENABLE2 "); \
142 if (ci->wFlags & D3DTRIFLAG_EDGEENABLE1) \
143 DUMP("EDGEENABLE3 "); \
145 /* Strips / Fans */ \
146 if (ci->wFlags == D3DTRIFLAG_EVEN) \
148 if (ci->wFlags == D3DTRIFLAG_ODD) \
150 if (ci->wFlags == D3DTRIFLAG_START) \
152 if ((ci->wFlags > 0) && (ci->wFlags < 30)) \
153 DUMP("STARTFLAT(%d) ", ci->wFlags); \
157 /* Draw the triangle */ \
168 static void execute(LPDIRECT3DEXECUTEBUFFER lpBuff,
169 LPDIRECT3DDEVICE dev,
170 LPDIRECT3DVIEWPORT vp) {
171 /* DWORD bs = lpBuff->desc.dwBufferSize; */
172 DWORD vs = lpBuff->data.dwVertexOffset;
173 /* DWORD vc = lpBuff->data.dwVertexCount; */
174 DWORD is = lpBuff->data.dwInstructionOffset;
175 /* DWORD il = lpBuff->data.dwInstructionLength; */
177 void *instr = lpBuff->desc.lpData + is;
178 OpenGL_IDirect3DDevice *odev = (OpenGL_IDirect3DDevice *) dev;
180 TRACE(ddraw, "ExecuteData : \n");
182 _dump_executedata(&(lpBuff->data));
185 LPD3DINSTRUCTION current = (LPD3DINSTRUCTION) instr;
189 count = current->wCount;
190 size = current->bSize;
191 instr += sizeof(D3DINSTRUCTION);
193 switch (current->bOpcode) {
195 TRACE(ddraw, "POINT-s (%d)\n", count);
197 instr += count * size;
201 TRACE(ddraw, "LINE-s (%d)\n", count);
203 instr += count * size;
206 case D3DOP_TRIANGLE: {
208 float z_inv_matrix[16] = {
215 OGL_Vertex *vx = (OGL_Vertex *) lpBuff->vertex_data;
216 OGL_LVertex *l_vx = (OGL_LVertex *) lpBuff->vertex_data;
217 D3DTLVERTEX *tl_vx = (D3DTLVERTEX *) lpBuff->vertex_data;
219 TRACE(ddraw, "TRIANGLE (%d)\n", count);
221 switch (lpBuff->vertex_type) {
223 /* This time, there is lighting */
224 glEnable(GL_LIGHTING);
226 /* Use given matrixes */
227 glMatrixMode(GL_MODELVIEW);
228 glLoadIdentity(); /* The model transformation was done during the
229 transformation phase */
230 glMatrixMode(GL_PROJECTION);
231 TRACE(ddraw, " Projection Matrix : (%p)\n", odev->proj_mat);
232 dump_mat(odev->proj_mat);
233 TRACE(ddraw, " View Matrix : (%p)\n", odev->view_mat);
234 dump_mat(odev->view_mat);
236 glLoadMatrixf((float *) z_inv_matrix);
237 glMultMatrixf((float *) odev->proj_mat);
238 glMultMatrixf((float *) odev->view_mat);
243 glDisable(GL_LIGHTING);
245 /* Use given matrixes */
246 glMatrixMode(GL_MODELVIEW);
247 glLoadIdentity(); /* The model transformation was done during the
248 transformation phase */
249 glMatrixMode(GL_PROJECTION);
251 TRACE(ddraw, " Projection Matrix : (%p)\n", odev->proj_mat);
252 dump_mat(odev->proj_mat);
253 TRACE(ddraw, " View Matrix : (%p)\n", odev->view_mat);
254 dump_mat(odev->view_mat);
256 glLoadMatrixf((float *) z_inv_matrix);
257 glMultMatrixf((float *) odev->proj_mat);
258 glMultMatrixf((float *) odev->view_mat);
261 case D3DVT_TLVERTEX: {
262 GLdouble height, width, minZ, maxZ;
264 /* First, disable lighting */
265 glDisable(GL_LIGHTING);
267 /* Then do not put any transformation matrixes */
268 glMatrixMode(GL_MODELVIEW);
270 glMatrixMode(GL_PROJECTION);
274 ERR(ddraw, "No current viewport !\n");
275 /* Using standard values */
281 height = (GLdouble) vp->viewport.vp1.dwHeight;
282 width = (GLdouble) vp->viewport.vp1.dwWidth;
283 minZ = (GLdouble) vp->viewport.vp1.dvMinZ;
284 maxZ = (GLdouble) vp->viewport.vp1.dvMaxZ;
287 /* I do not know why, but many Dx 3.0 games have minZ = maxZ = 0.0 */
293 glOrtho(0.0, width, height, 0.0, -minZ, -maxZ);
297 ERR(ddraw, "Unhandled vertex type !\n");
301 switch (lpBuff->vertex_type) {
303 TRIANGLE_LOOP(DO_VERTEX);
307 TRIANGLE_LOOP(DO_LVERTEX);
311 TRIANGLE_LOOP(DO_TLVERTEX);
315 ERR(ddraw, "Unhandled vertex type !\n");
320 case D3DOP_MATRIXLOAD: {
321 TRACE(ddraw, "MATRIXLOAD-s (%d)\n", count);
323 instr += count * size;
326 case D3DOP_MATRIXMULTIPLY: {
328 TRACE(ddraw, "MATRIXMULTIPLY (%d)\n", count);
330 for (i = 0; i < count; i++) {
331 LPD3DMATRIXMULTIPLY ci = (LPD3DMATRIXMULTIPLY) instr;
332 LPD3DMATRIX a = (LPD3DMATRIX) ci->hDestMatrix;
333 LPD3DMATRIX b = (LPD3DMATRIX) ci->hSrcMatrix1;
334 LPD3DMATRIX c = (LPD3DMATRIX) ci->hSrcMatrix2;
336 TRACE(ddraw, " Dest : %08lx Src1 : %08lx Src2 : %08lx\n",
337 ci->hDestMatrix, ci->hSrcMatrix1, ci->hSrcMatrix2);
339 /* Do the multiplication..
340 As I am VERY lazy, I let OpenGL do the multiplication for me */
341 glMatrixMode(GL_PROJECTION);
342 /* Save the current matrix */
344 /* Load Matrix one and do the multiplication */
345 glLoadMatrixf((float *) c);
346 glMultMatrixf((float *) b);
347 glGetFloatv(GL_PROJECTION_MATRIX, (float *) a);
348 /* Restore the current matrix */
355 case D3DOP_STATETRANSFORM: {
357 TRACE(ddraw, "STATETRANSFORM (%d)\n", count);
359 for (i = 0; i < count; i++) {
360 LPD3DSTATE ci = (LPD3DSTATE) instr;
362 /* Handle the state transform */
363 switch (ci->t.dtstTransformStateType) {
364 case D3DTRANSFORMSTATE_WORLD: {
365 TRACE(ddraw, " WORLD (%p)\n", (D3DMATRIX*) ci->v.dwArg[0]);
366 odev->world_mat = (D3DMATRIX*) ci->v.dwArg[0];
369 case D3DTRANSFORMSTATE_VIEW: {
370 TRACE(ddraw, " VIEW (%p)\n", (D3DMATRIX*) ci->v.dwArg[0]);
371 odev->view_mat = (D3DMATRIX*) ci->v.dwArg[0];
374 case D3DTRANSFORMSTATE_PROJECTION: {
375 TRACE(ddraw, " PROJECTION (%p)\n", (D3DMATRIX*) ci->v.dwArg[0]);
376 odev->proj_mat = (D3DMATRIX*) ci->v.dwArg[0];
380 ERR(ddraw, " Unhandled state transformation !! (%d)\n", (int) ci->t.dtstTransformStateType);
389 case D3DOP_STATELIGHT: {
391 TRACE(ddraw, "STATELIGHT (%d)\n", count);
393 for (i = 0; i < count; i++) {
394 LPD3DSTATE ci = (LPD3DSTATE) instr;
396 /* Handle the state transform */
397 switch (ci->t.dlstLightStateType) {
398 case D3DLIGHTSTATE_MATERIAL: {
399 LPDIRECT3DMATERIAL mat = (LPDIRECT3DMATERIAL) ci->v.dwArg[0];
400 TRACE(ddraw, " MATERIAL\n");
405 TRACE(ddraw, " bad Material Handle\n");
409 case D3DLIGHTSTATE_AMBIENT: {
411 DWORD dwLightState = ci->v.dwArg[0];
412 TRACE(ddraw, " AMBIENT\n");
414 light[0] = ((dwLightState >> 16) & 0xFF) / 255.0;
415 light[1] = ((dwLightState >> 8) & 0xFF) / 255.0;
416 light[2] = ((dwLightState >> 0) & 0xFF) / 255.0;
418 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, (float *) light);
420 TRACE(ddraw, " R:%02lx G:%02lx B:%02lx A:%02lx\n",
421 ((dwLightState >> 16) & 0xFF),
422 ((dwLightState >> 8) & 0xFF),
423 ((dwLightState >> 0) & 0xFF),
424 ((dwLightState >> 24) & 0xFF));
427 case D3DLIGHTSTATE_COLORMODEL: {
428 TRACE(ddraw, " COLORMODEL\n");
431 case D3DLIGHTSTATE_FOGMODE: {
432 TRACE(ddraw, " FOGMODE\n");
435 case D3DLIGHTSTATE_FOGSTART: {
436 TRACE(ddraw, " FOGSTART\n");
439 case D3DLIGHTSTATE_FOGEND: {
440 TRACE(ddraw, " FOGEND\n");
443 case D3DLIGHTSTATE_FOGDENSITY: {
444 TRACE(ddraw, " FOGDENSITY\n");
448 ERR(ddraw, " Unhandled light state !! (%d)\n", (int) ci->t.dlstLightStateType);
455 case D3DOP_STATERENDER: {
457 TRACE(ddraw, "STATERENDER (%d)\n", count);
459 for (i = 0; i < count; i++) {
460 LPD3DSTATE ci = (LPD3DSTATE) instr;
462 /* Handle the state transform */
463 set_render_state(ci->t.drstRenderStateType, ci->v.dwArg[0], &(odev->rs));
469 case D3DOP_PROCESSVERTICES: {
471 TRACE(ddraw, "PROCESSVERTICES (%d)\n", count);
473 for (i = 0; i < count; i++) {
474 LPD3DPROCESSVERTICES ci = (LPD3DPROCESSVERTICES) instr;
476 TRACE(ddraw, " Start : %d Dest : %d Count : %ld\n",
477 ci->wStart, ci->wDest, ci->dwCount);
478 TRACE(ddraw, " Flags : ");
479 if (TRACE_ON(ddraw)) {
480 if (ci->dwFlags & D3DPROCESSVERTICES_COPY)
482 if (ci->dwFlags & D3DPROCESSVERTICES_NOCOLOR)
484 if (ci->dwFlags == D3DPROCESSVERTICES_OPMASK)
486 if (ci->dwFlags & D3DPROCESSVERTICES_TRANSFORM)
488 if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORMLIGHT)
489 DUMP("TRANSFORMLIGHT ");
490 if (ci->dwFlags & D3DPROCESSVERTICES_UPDATEEXTENTS)
491 DUMP("UPDATEEXTENTS ");
495 /* This is where doing Direct3D on top on OpenGL is quite difficult.
496 This method transforms a set of vertices using the CURRENT state
497 (lighting, projection, ...) but does not rasterize them.
498 They will oinly be put on screen later (with the POINT / LINE and
499 TRIANGLE op-codes). The problem is that you can have a triangle
500 with each point having been transformed using another state...
502 In this implementation, I will emulate only ONE thing : each
503 vertex can have its own "WORLD" transformation (this is used in the
504 TWIST.EXE demo of the 5.2 SDK). I suppose that all vertices of the
505 execute buffer use the same state.
507 If I find applications that change other states, I will try to do a
508 more 'fine-tuned' state emulation (but I may become quite tricky if
509 it changes a light position in the middle of a triangle).
511 In this case, a 'direct' approach (i.e. without using OpenGL, but
512 writing our own 3D rasterizer) would be easier. */
514 /* The current method (with the hypothesis that only the WORLD matrix
515 will change between two points) is like this :
516 - I transform 'manually' all the vertices with the current WORLD
517 matrix and store them in the vertex buffer
518 - during the rasterization phase, the WORLD matrix will be set to
519 the Identity matrix */
521 /* Enough for the moment */
522 if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORMLIGHT) {
524 D3DVERTEX *src = ((LPD3DVERTEX) (lpBuff->desc.lpData + vs)) + ci->wStart;
525 OGL_Vertex *dst = ((OGL_Vertex *) (lpBuff->vertex_data)) + ci->wDest;
526 D3DMATRIX *mat = odev->world_mat;
528 TRACE(ddraw, " World Matrix : (%p)\n", mat);
531 lpBuff->vertex_type = D3DVT_VERTEX;
533 for (nb = 0; nb < ci->dwCount; nb++) {
534 /* For the moment, no normal transformation... */
535 dst->nx = src->nx.nx;
536 dst->ny = src->ny.ny;
537 dst->nz = src->nz.nz;
542 /* Now, the matrix multiplication */
543 dst->x = (src->x.x * mat->_11) + (src->y.y * mat->_21) + (src->z.z * mat->_31) + (1.0 * mat->_41);
544 dst->y = (src->x.x * mat->_12) + (src->y.y * mat->_22) + (src->z.z * mat->_32) + (1.0 * mat->_42);
545 dst->z = (src->x.x * mat->_13) + (src->y.y * mat->_23) + (src->z.z * mat->_33) + (1.0 * mat->_43);
546 dst->w = (src->x.x * mat->_14) + (src->y.y * mat->_24) + (src->z.z * mat->_34) + (1.0 * mat->_44);
551 } else if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORM) {
553 D3DLVERTEX *src = ((LPD3DLVERTEX) (lpBuff->desc.lpData + vs)) + ci->wStart;
554 OGL_LVertex *dst = ((OGL_LVertex *) (lpBuff->vertex_data)) + ci->wDest;
555 D3DMATRIX *mat = odev->world_mat;
557 TRACE(ddraw, " World Matrix : (%p)\n", mat);
560 lpBuff->vertex_type = D3DVT_LVERTEX;
562 for (nb = 0; nb < ci->dwCount; nb++) {
563 dst->c = src->c.color;
564 dst->sc = src->s.specular;
568 /* Now, the matrix multiplication */
569 dst->x = (src->x.x * mat->_11) + (src->y.y * mat->_21) + (src->z.z * mat->_31) + (1.0 * mat->_41);
570 dst->y = (src->x.x * mat->_12) + (src->y.y * mat->_22) + (src->z.z * mat->_32) + (1.0 * mat->_42);
571 dst->z = (src->x.x * mat->_13) + (src->y.y * mat->_23) + (src->z.z * mat->_33) + (1.0 * mat->_43);
572 dst->w = (src->x.x * mat->_14) + (src->y.y * mat->_24) + (src->z.z * mat->_34) + (1.0 * mat->_44);
577 } else if (ci->dwFlags == D3DPROCESSVERTICES_COPY) {
578 D3DTLVERTEX *src = ((LPD3DTLVERTEX) (lpBuff->desc.lpData + vs)) + ci->wStart;
579 D3DTLVERTEX *dst = ((LPD3DTLVERTEX) (lpBuff->vertex_data)) + ci->wDest;
581 lpBuff->vertex_type = D3DVT_TLVERTEX;
583 memcpy(dst, src, ci->dwCount * sizeof(D3DTLVERTEX));
585 ERR(ddraw, "Unhandled vertex processing !\n");
592 case D3DOP_TEXTURELOAD: {
593 TRACE(ddraw, "TEXTURELOAD-s (%d)\n", count);
595 instr += count * size;
599 TRACE(ddraw, "EXIT (%d)\n", count);
600 /* We did this instruction */
606 case D3DOP_BRANCHFORWARD: {
608 TRACE(ddraw, "BRANCHFORWARD (%d)\n", count);
610 for (i = 0; i < count; i++) {
611 LPD3DBRANCH ci = (LPD3DBRANCH) instr;
613 if ((lpBuff->data.dsStatus.dwStatus & ci->dwMask) == ci->dwValue) {
615 TRACE(ddraw," Should branch to %ld\n", ci->dwOffset);
619 TRACE(ddraw," Should branch to %ld\n", ci->dwOffset);
628 TRACE(ddraw, "SPAN-s (%d)\n", count);
630 instr += count * size;
633 case D3DOP_SETSTATUS: {
635 TRACE(ddraw, "SETSTATUS (%d)\n", count);
637 for (i = 0; i < count; i++) {
638 LPD3DSTATUS ci = (LPD3DSTATUS) instr;
640 lpBuff->data.dsStatus = *ci;
647 ERR(ddraw, "Unhandled OpCode !!!\n");
648 /* Try to save ... */
649 instr += count * size;
657 /*******************************************************************************
658 * ExecuteBuffer Creation functions
660 LPDIRECT3DEXECUTEBUFFER d3dexecutebuffer_create(LPDIRECT3DDEVICE d3ddev, LPD3DEXECUTEBUFFERDESC lpDesc)
662 LPDIRECT3DEXECUTEBUFFER eb;
664 eb = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DExecuteBuffer));
666 eb->lpvtbl = &executebuffer_vtable;
669 /* Initializes memory */
672 /* No buffer given */
673 if (!(eb->desc.dwFlags & D3DDEB_LPDATA))
674 eb->desc.lpData = NULL;
676 /* No buffer size given */
677 if (!(lpDesc->dwFlags & D3DDEB_BUFSIZE))
678 eb->desc.dwBufferSize = 0;
680 /* Create buffer if asked */
681 if ((eb->desc.lpData == NULL) && (eb->desc.dwBufferSize > 0)) {
682 eb->need_free = TRUE;
683 eb->desc.lpData = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,eb->desc.dwBufferSize);
685 eb->need_free = FALSE;
688 /* No vertices for the moment */
689 eb->vertex_data = NULL;
691 eb->desc.dwFlags |= D3DDEB_LPDATA;
693 eb->execute = execute;
698 /*******************************************************************************
699 * IDirect3DLight methods
702 static HRESULT WINAPI IDirect3DExecuteBuffer_QueryInterface(LPDIRECT3DEXECUTEBUFFER this,
708 WINE_StringFromCLSID((LPCLSID)riid,xrefiid);
709 FIXME(ddraw, "(%p)->(%s,%p): stub\n", this, xrefiid,ppvObj);
716 static ULONG WINAPI IDirect3DExecuteBuffer_AddRef(LPDIRECT3DEXECUTEBUFFER this)
718 TRACE(ddraw, "(%p)->()incrementing from %lu.\n", this, this->ref );
720 return ++(this->ref);
725 static ULONG WINAPI IDirect3DExecuteBuffer_Release(LPDIRECT3DEXECUTEBUFFER this)
727 FIXME( ddraw, "(%p)->() decrementing from %lu.\n", this, this->ref );
729 if (!--(this->ref)) {
730 if ((this->desc.lpData != NULL) && this->need_free)
731 HeapFree(GetProcessHeap(),0,this->desc.lpData);
733 if (this->vertex_data != NULL)
734 HeapFree(GetProcessHeap(),0,this->vertex_data);
736 HeapFree(GetProcessHeap(),0,this);
743 static HRESULT WINAPI IDirect3DExecuteBuffer_Initialize(LPDIRECT3DEXECUTEBUFFER this,
744 LPDIRECT3DDEVICE lpDirect3DDevice,
745 LPD3DEXECUTEBUFFERDESC lpDesc)
747 FIXME(ddraw, "(%p)->(%p,%p): stub\n", this, lpDirect3DDevice, lpDesc);
752 static HRESULT WINAPI IDirect3DExecuteBuffer_Lock(LPDIRECT3DEXECUTEBUFFER this,
753 LPD3DEXECUTEBUFFERDESC lpDesc)
755 TRACE(ddraw, "(%p)->(%p)\n", this, lpDesc);
757 /* Copies the buffer description */
758 *lpDesc = this->desc;
763 static HRESULT WINAPI IDirect3DExecuteBuffer_Unlock(LPDIRECT3DEXECUTEBUFFER this)
765 TRACE(ddraw, "(%p)->()\n", this);
770 static HRESULT WINAPI IDirect3DExecuteBuffer_SetExecuteData(LPDIRECT3DEXECUTEBUFFER this,
771 LPD3DEXECUTEDATA lpData)
775 TRACE(ddraw, "(%p)->(%p)\n", this, lpData);
777 this->data = *lpData;
779 /* Get the number of vertices in the execute buffer */
780 nbvert = this->data.dwVertexCount;
782 /* Prepares the transformed vertex buffer */
783 if (this->vertex_data != NULL)
784 HeapFree(GetProcessHeap(), 0, this->vertex_data);
785 this->vertex_data = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,nbvert * sizeof(OGL_Vertex));
788 if (TRACE_ON(ddraw)) {
789 _dump_executedata(lpData);
795 static HRESULT WINAPI IDirect3DExecuteBuffer_GetExecuteData(LPDIRECT3DEXECUTEBUFFER this,
796 LPD3DEXECUTEDATA lpData)
798 TRACE(ddraw, "(%p)->(%p): stub\n", this, lpData);
800 *lpData = this->data;
805 static HRESULT WINAPI IDirect3DExecuteBuffer_Validate(LPDIRECT3DEXECUTEBUFFER this,
807 LPD3DVALIDATECALLBACK lpFunc,
811 TRACE(ddraw, "(%p)->(%p,%p,%p,%lu)\n", this, lpdwOffset, lpFunc, lpUserArg, dwReserved);
816 static HRESULT WINAPI IDirect3DExecuteBuffer_Optimize(LPDIRECT3DEXECUTEBUFFER this,
819 TRACE(ddraw, "(%p)->(%lu)\n", this, dwReserved);
825 /*******************************************************************************
826 * IDirect3DLight VTable
828 static IDirect3DExecuteBuffer_VTable executebuffer_vtable = {
829 /*** IUnknown methods ***/
830 IDirect3DExecuteBuffer_QueryInterface,
831 IDirect3DExecuteBuffer_AddRef,
832 IDirect3DExecuteBuffer_Release,
833 /*** IDirect3DExecuteBuffer methods ***/
834 IDirect3DExecuteBuffer_Initialize,
835 IDirect3DExecuteBuffer_Lock,
836 IDirect3DExecuteBuffer_Unlock,
837 IDirect3DExecuteBuffer_SetExecuteData,
838 IDirect3DExecuteBuffer_GetExecuteData,
839 IDirect3DExecuteBuffer_Validate,
840 IDirect3DExecuteBuffer_Optimize
843 #endif /* HAVE_MESAGL */