[DDRAW] Implement Begin/Vertex/End rendering functions

Christian Costa titan.costa at wanadoo.fr
Sun Sep 25 04:44:17 CDT 2005


Hi,

A glide wrapper requires this to work.

Changelog:
Implement Begin/Vertex/End rendering functions.

Christian Costa   titan.costa at wanadoo.fr

-------------- next part --------------
Index: dlls/ddraw/d3d_private.h
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/d3d_private.h,v
retrieving revision 1.46
diff -u -r1.46 d3d_private.h
--- dlls/ddraw/d3d_private.h	11 Jul 2005 13:21:17 -0000	1.46
+++ dlls/ddraw/d3d_private.h	25 Sep 2005 08:20:21 -0000
@@ -1,6 +1,8 @@
-/* Direct3D private include file
- * Copyright (c) 1998-2004 Lionel ULMER
- * Copyright (c) 2002-2004 Christian Costa
+/*
+ * Direct3D private include file
+ *
+ * Copyright (c) 1998-2004 Lionel Ulmer
+ * Copyright (c) 2002-2005 Christian Costa
  *
  * This file contains all the structure that are not exported
  * through d3d.h and all common macros.
@@ -230,7 +232,7 @@
     LPD3DLIGHT7 light_parameters;
     DWORD *active_lights;
 
-    /* clipping planes */
+    /* Clipping planes */
     DWORD max_clipping_planes;
     d3d7clippingplane *clipping_planes;
     
@@ -251,6 +253,15 @@
 
     /* Used to prevent locks and rendering to overlap */
     CRITICAL_SECTION crit;
+
+    /* Rendering functions */
+    D3DPRIMITIVETYPE primitive_type;
+    DWORD vertex_type;
+    DWORD render_flags;
+    DWORD nb_vertices;
+    LPBYTE vertex_buffer;
+    DWORD vertex_size;
+    DWORD buffer_size;
 };
 
 /*****************************************************************************
Index: dlls/ddraw/device_main.c
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/device_main.c,v
retrieving revision 1.2
diff -u -r1.2 device_main.c
--- dlls/ddraw/device_main.c	7 Jun 2005 21:34:40 -0000	1.2
+++ dlls/ddraw/device_main.c	25 Sep 2005 08:20:28 -0000
@@ -1,6 +1,8 @@
-/* Direct3D Device
- * Copyright (c) 1998-2004 Lionel ULMER
- * Copyright (c) 2002-2004 Christian Costa
+/*
+ * Direct3D Device
+ *
+ * Copyright (c) 1998-2004 Lionel Ulmer
+ * Copyright (c) 2002-2005 Christian Costa
  *
  * This file contains all the common stuff for D3D devices.
  *
@@ -284,7 +286,7 @@
 	    if (This->current_texture[i] != NULL)
 	        IDirect3DTexture2_Release(ICOM_INTERFACE(This->current_texture[i], IDirect3DTexture2));
 	}
-	    	  
+	HeapFree(GetProcessHeap(), 0, This->vertex_buffer);
 	HeapFree(GetProcessHeap(), 0, This);
 	return 0;
     }
@@ -1175,8 +1177,15 @@
                                  DWORD dwFlags)
 {
     ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
-    FIXME("(%p/%p)->(%08x,%08lx,%08lx): stub!\n", This, iface, d3dptPrimitiveType, dwVertexTypeDesc, dwFlags);
-    return DD_OK;
+    TRACE("(%p/%p)->(%08x,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, dwVertexTypeDesc, dwFlags);
+
+    This->primitive_type = d3dptPrimitiveType;
+    This->vertex_type = dwVertexTypeDesc;
+    This->render_flags = dwFlags;
+    This->vertex_size = get_flexible_vertex_size(This->vertex_type);
+    This->nb_vertices = 0;
+
+    return D3D_OK;
 }
 
 HRESULT WINAPI
@@ -1197,8 +1206,24 @@
                                      LPVOID lpVertexType)
 {
     ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
-    FIXME("(%p/%p)->(%p): stub!\n", This, iface, lpVertexType);
-    return DD_OK;
+    TRACE("(%p/%p)->(%p)\n", This, iface, lpVertexType);
+
+    if ((This->nb_vertices+1)*This->vertex_size > This->buffer_size)
+    {
+	LPBYTE old_buffer;
+	This->buffer_size = This->buffer_size ? This->buffer_size * 2 : This->vertex_size * 3;
+	old_buffer = This->vertex_buffer;
+	This->vertex_buffer = HeapAlloc(GetProcessHeap(), 0, This->buffer_size);
+	if (old_buffer)
+	{
+	    CopyMemory(This->vertex_buffer, old_buffer, This->nb_vertices * This->vertex_size);
+	    HeapFree(GetProcessHeap(), 0, old_buffer);
+	}
+    }
+
+    CopyMemory(This->vertex_buffer + This->nb_vertices++ * This->vertex_size, lpVertexType, This->vertex_size);
+
+    return D3D_OK;
 }
 
 HRESULT WINAPI
@@ -1215,8 +1240,11 @@
                                   DWORD dwFlags)
 {
     ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
-    FIXME("(%p/%p)->(%08lx): stub!\n", This, iface, dwFlags);
-    return DD_OK;
+    TRACE("(%p/%p)->(%08lx)\n", This, iface, dwFlags);
+
+    IDirect3DDevice3_DrawPrimitive(iface, This->primitive_type, This->vertex_type, This->vertex_buffer, This->nb_vertices, This->render_flags);
+
+    return D3D_OK;
 }
 
 HRESULT WINAPI
Index: dlls/ddraw/device_opengl.c
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/device_opengl.c,v
retrieving revision 1.8
diff -u -r1.8 device_opengl.c
--- dlls/ddraw/device_opengl.c	22 Aug 2005 18:58:27 -0000	1.8
+++ dlls/ddraw/device_opengl.c	25 Sep 2005 08:20:40 -0000
@@ -1,6 +1,8 @@
-/* Direct3D Device
- * Copyright (c) 1998-2004 Lionel ULMER
- * Copyright (c) 2002-2004 Christian Costa
+/*
+ * Direct3D Device
+ *
+ * Copyright (c) 1998-2004 Lionel Ulmer
+ * Copyright (c) 2002-2005 Christian Costa
  *
  * This file contains the MESA implementation of all the D3D devices that
  * Wine supports.
@@ -427,16 +429,14 @@
 	This->d3d->d3d_removed_device(This->d3d, This);
 
         /* Free light arrays */
-        if (This->light_parameters)
-            HeapFree(GetProcessHeap(), 0, This->light_parameters);
+        HeapFree(GetProcessHeap(), 0, This->light_parameters);
         HeapFree(GetProcessHeap(), 0, This->active_lights);
 
 	HeapFree(GetProcessHeap(), 0, This->world_mat);
 	HeapFree(GetProcessHeap(), 0, This->view_mat);
 	HeapFree(GetProcessHeap(), 0, This->proj_mat);
 
-	if (glThis->surface_ptr)
-	    HeapFree(GetProcessHeap(), 0, glThis->surface_ptr);
+	HeapFree(GetProcessHeap(), 0, glThis->surface_ptr);
 
 	DeleteCriticalSection(&(This->crit));
 	
@@ -446,6 +446,7 @@
 	glXDestroyContext(glThis->display, glThis->gl_context);
 	LEAVE_GL();
 	HeapFree(GetProcessHeap(), 0, This->clipping_planes);
+	HeapFree(GetProcessHeap(), 0, This->vertex_buffer);
 
 	HeapFree(GetProcessHeap(), 0, This);
 	return 0;


More information about the wine-patches mailing list