Implement Begin/Vertex/End rendering functions.

This commit is contained in:
Christian Costa 2005-09-25 15:18:18 +00:00 committed by Alexandre Julliard
parent 240e7624c6
commit 3d6154aa33
3 changed files with 61 additions and 21 deletions

View File

@ -1,6 +1,8 @@
/* Direct3D private include file /*
* Copyright (c) 1998-2004 Lionel ULMER * Direct3D private include file
* Copyright (c) 2002-2004 Christian Costa *
* Copyright (c) 1998-2004 Lionel Ulmer
* Copyright (c) 2002-2005 Christian Costa
* *
* This file contains all the structure that are not exported * This file contains all the structure that are not exported
* through d3d.h and all common macros. * through d3d.h and all common macros.
@ -230,7 +232,7 @@ struct IDirect3DDeviceImpl
LPD3DLIGHT7 light_parameters; LPD3DLIGHT7 light_parameters;
DWORD *active_lights; DWORD *active_lights;
/* clipping planes */ /* Clipping planes */
DWORD max_clipping_planes; DWORD max_clipping_planes;
d3d7clippingplane *clipping_planes; d3d7clippingplane *clipping_planes;
@ -251,6 +253,15 @@ struct IDirect3DDeviceImpl
/* Used to prevent locks and rendering to overlap */ /* Used to prevent locks and rendering to overlap */
CRITICAL_SECTION crit; 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;
}; };
/***************************************************************************** /*****************************************************************************

View File

@ -1,6 +1,8 @@
/* Direct3D Device /*
* Copyright (c) 1998-2004 Lionel ULMER * Direct3D Device
* Copyright (c) 2002-2004 Christian Costa *
* Copyright (c) 1998-2004 Lionel Ulmer
* Copyright (c) 2002-2005 Christian Costa
* *
* This file contains all the common stuff for D3D devices. * This file contains all the common stuff for D3D devices.
* *
@ -284,7 +286,7 @@ Main_IDirect3DDeviceImpl_7_3T_2T_1T_Release(LPDIRECT3DDEVICE7 iface)
if (This->current_texture[i] != NULL) if (This->current_texture[i] != NULL)
IDirect3DTexture2_Release(ICOM_INTERFACE(This->current_texture[i], IDirect3DTexture2)); IDirect3DTexture2_Release(ICOM_INTERFACE(This->current_texture[i], IDirect3DTexture2));
} }
HeapFree(GetProcessHeap(), 0, This->vertex_buffer);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
return 0; return 0;
} }
@ -1175,8 +1177,15 @@ Main_IDirect3DDeviceImpl_3_Begin(LPDIRECT3DDEVICE3 iface,
DWORD dwFlags) DWORD dwFlags)
{ {
ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
FIXME("(%p/%p)->(%08x,%08lx,%08lx): stub!\n", This, iface, d3dptPrimitiveType, dwVertexTypeDesc, dwFlags); TRACE("(%p/%p)->(%08x,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, dwVertexTypeDesc, dwFlags);
return DD_OK;
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 HRESULT WINAPI
@ -1197,8 +1206,24 @@ Main_IDirect3DDeviceImpl_3_2T_Vertex(LPDIRECT3DDEVICE3 iface,
LPVOID lpVertexType) LPVOID lpVertexType)
{ {
ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
FIXME("(%p/%p)->(%p): stub!\n", This, iface, lpVertexType); TRACE("(%p/%p)->(%p)\n", This, iface, lpVertexType);
return DD_OK;
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 HRESULT WINAPI
@ -1215,8 +1240,11 @@ Main_IDirect3DDeviceImpl_3_2T_End(LPDIRECT3DDEVICE3 iface,
DWORD dwFlags) DWORD dwFlags)
{ {
ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
FIXME("(%p/%p)->(%08lx): stub!\n", This, iface, dwFlags); TRACE("(%p/%p)->(%08lx)\n", This, iface, dwFlags);
return DD_OK;
IDirect3DDevice3_DrawPrimitive(iface, This->primitive_type, This->vertex_type, This->vertex_buffer, This->nb_vertices, This->render_flags);
return D3D_OK;
} }
HRESULT WINAPI HRESULT WINAPI

View File

@ -1,6 +1,8 @@
/* Direct3D Device /*
* Copyright (c) 1998-2004 Lionel ULMER * Direct3D Device
* Copyright (c) 2002-2004 Christian Costa *
* Copyright (c) 1998-2004 Lionel Ulmer
* Copyright (c) 2002-2005 Christian Costa
* *
* This file contains the MESA implementation of all the D3D devices that * This file contains the MESA implementation of all the D3D devices that
* Wine supports. * Wine supports.
@ -427,16 +429,14 @@ GL_IDirect3DDeviceImpl_7_3T_2T_1T_Release(LPDIRECT3DDEVICE7 iface)
This->d3d->d3d_removed_device(This->d3d, This); This->d3d->d3d_removed_device(This->d3d, This);
/* Free light arrays */ /* 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->active_lights);
HeapFree(GetProcessHeap(), 0, This->world_mat); HeapFree(GetProcessHeap(), 0, This->world_mat);
HeapFree(GetProcessHeap(), 0, This->view_mat); HeapFree(GetProcessHeap(), 0, This->view_mat);
HeapFree(GetProcessHeap(), 0, This->proj_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)); DeleteCriticalSection(&(This->crit));
@ -446,6 +446,7 @@ GL_IDirect3DDeviceImpl_7_3T_2T_1T_Release(LPDIRECT3DDEVICE7 iface)
glXDestroyContext(glThis->display, glThis->gl_context); glXDestroyContext(glThis->display, glThis->gl_context);
LEAVE_GL(); LEAVE_GL();
HeapFree(GetProcessHeap(), 0, This->clipping_planes); HeapFree(GetProcessHeap(), 0, This->clipping_planes);
HeapFree(GetProcessHeap(), 0, This->vertex_buffer);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
return 0; return 0;