Commit c5f38756 authored by Lionel Ulmer's avatar Lionel Ulmer Committed by Alexandre Julliard

- actually use the VertexBuffer stubs

- implement Lock function to prevent crash when the stubs are used
parent f4b941e8
......@@ -194,6 +194,9 @@ struct IDirect3DVertexBufferImpl
ICOM_VFIELD_MULTI(IDirect3DVertexBuffer);
DWORD ref;
IDirect3DImpl *d3d;
D3DVERTEXBUFFERDESC desc;
LPVOID *vertices;
DWORD vertex_buffer_size;
};
/* Various dump functions */
......
......@@ -241,7 +241,7 @@ static void fill_opengl_caps_7(D3DDEVICEDESC7 *d)
d->dvMaxVertexW = 100000000.0; /* No idea exactly what to put here... */
d->deviceGUID = IID_IDirect3DTnLHalDevice;
d->wMaxUserClipPlanes = 1;
d->wMaxVertexBlendMatrices = 1;
d->wMaxVertexBlendMatrices = 0;
d->dwVertexProcessingCaps = D3DVTXPCAPS_TEXGEN | D3DVTXPCAPS_MATERIALSOURCE7 | D3DVTXPCAPS_VERTEXFOG | D3DVTXPCAPS_DIRECTIONALLIGHTS |
D3DVTXPCAPS_POSITIONALLIGHTS | D3DVTXPCAPS_LOCALVIEWER;
d->dwReserved1 = 0;
......@@ -883,7 +883,24 @@ GL_IDirect3DDeviceImpl_1_CreateExecuteBuffer(LPDIRECT3DDEVICE iface,
return ret_value;
}
static void dump_flexible_vertex(DWORD d3dvtVertexType)
DWORD get_flexible_vertex_size(DWORD d3dvtVertexType)
{
DWORD size = 0;
if (d3dvtVertexType & D3DFVF_NORMAL) size += 3 * sizeof(D3DVALUE);
if (d3dvtVertexType & D3DFVF_DIFFUSE) size += sizeof(DWORD);
if (d3dvtVertexType & D3DFVF_SPECULAR) size += sizeof(DWORD);
switch (d3dvtVertexType & D3DFVF_POSITION_MASK) {
case D3DFVF_XYZ: size += 3 * sizeof(D3DVALUE); break;
case D3DFVF_XYZRHW: size += 4 * sizeof(D3DVALUE); break;
default: TRACE(" matrix weighting not handled yet...\n");
}
size += 2 * sizeof(D3DVALUE) * ((d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT);
return size;
}
void dump_flexible_vertex(DWORD d3dvtVertexType)
{
static const flag_info flags[] = {
FE(D3DFVF_NORMAL),
......
......@@ -91,7 +91,16 @@ Main_IDirect3DVertexBufferImpl_7_1T_Lock(LPDIRECT3DVERTEXBUFFER7 iface,
LPDWORD lpdwSize)
{
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface);
FIXME("(%p/%p)->(%08lx,%p,%p): stub!\n", This, iface, dwFlags, lplpData, lpdwSize);
TRACE("(%p/%p)->(%08lx,%p,%p)\n", This, iface, dwFlags, lplpData, lpdwSize);
if (TRACE_ON(ddraw)) {
TRACE(" lock flags : ");
DDRAW_dump_lockflag(dwFlags);
}
if (lpdwSize != NULL) *lpdwSize = This->vertex_buffer_size;
*lplpData = This->vertices;
return DD_OK;
}
......@@ -279,22 +288,36 @@ ICOM_VTABLE(IDirect3DVertexBuffer) VTABLE_IDirect3DVertexBuffer =
#undef XCAST
#endif
HRESULT d3dvertexbuffer_create(IDirect3DVertexBufferImpl **obj, IDirect3DImpl *d3d, LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc)
HRESULT d3dvertexbuffer_create(IDirect3DVertexBufferImpl **obj, IDirect3DImpl *d3d, LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc, DWORD dwFlags)
{
IDirect3DVertexBufferImpl *object;
static const flag_info flags[] = {
FE(D3DVBCAPS_OPTIMIZED),
FE(D3DVBCAPS_SYSTEMMEMORY),
FE(D3DVBCAPS_WRITEONLY)
};
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVertexBufferImpl));
if (object == NULL) return DDERR_OUTOFMEMORY;
object->ref = 1;
object->d3d = d3d;
object->desc = *lpD3DVertBufDesc;
object->vertex_buffer_size = get_flexible_vertex_size(lpD3DVertBufDesc->dwFVF) * lpD3DVertBufDesc->dwNumVertices;
object->vertices = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->vertex_buffer_size);
ICOM_INIT_INTERFACE(object, IDirect3DVertexBuffer, VTABLE_IDirect3DVertexBuffer);
ICOM_INIT_INTERFACE(object, IDirect3DVertexBuffer7, VTABLE_IDirect3DVertexBuffer7);
*obj = object;
TRACE(" creating implementation at %p.\n", *obj);
if (TRACE_ON(ddraw)) {
TRACE(" creating implementation at %p with description : \n", *obj);
TRACE(" - "); DDRAW_dump_flags_(lpD3DVertBufDesc->dwCaps, flags, sizeof(flags)/sizeof(flags[0]), TRUE);
TRACE(" - "); dump_flexible_vertex(lpD3DVertBufDesc->dwFVF);
TRACE(" - %ld\n", lpD3DVertBufDesc->dwNumVertices);
}
return D3D_OK;
}
......@@ -320,6 +320,25 @@ GL_IDirect3DImpl_7_CreateDevice(LPDIRECT3D7 iface,
return create_device_helper(This, rclsid, ddsurfaceimpl, (void **) lplpD3DDevice, 7);
}
HRESULT WINAPI
GL_IDirect3DImpl_7_3T_CreateVertexBuffer(LPDIRECT3D7 iface,
LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc,
LPDIRECT3DVERTEXBUFFER7* lplpD3DVertBuf,
DWORD dwFlags)
{
ICOM_THIS_FROM(IDirect3DImpl, IDirect3D7, iface);
IDirect3DVertexBufferImpl *vbimpl;
HRESULT res;
TRACE("(%p/%p)->(%p,%p,%08lx)\n", This, iface, lpD3DVertBufDesc, lplpD3DVertBuf, dwFlags);
res = d3dvertexbuffer_create(&vbimpl, This, lpD3DVertBufDesc, dwFlags);
*lplpD3DVertBuf = ICOM_INTERFACE(vbimpl, IDirect3DVertexBuffer7);
return res;
}
static void light_released(IDirect3DImpl *This, GLenum light_num)
{
IDirect3DGLImpl *glThis = (IDirect3DGLImpl *) This;
......@@ -340,7 +359,7 @@ ICOM_VTABLE(IDirect3D7) VTABLE_IDirect3D7 =
XCAST(Release) Main_IDirect3DImpl_7_3T_2T_1T_Release,
XCAST(EnumDevices) GL_IDirect3DImpl_7_EnumDevices,
XCAST(CreateDevice) GL_IDirect3DImpl_7_CreateDevice,
XCAST(CreateVertexBuffer) Main_IDirect3DImpl_7_3T_CreateVertexBuffer,
XCAST(CreateVertexBuffer) GL_IDirect3DImpl_7_3T_CreateVertexBuffer,
XCAST(EnumZBufferFormats) GL_IDirect3DImpl_7_3T_EnumZBufferFormats,
XCAST(EvictManagedTextures) Main_IDirect3DImpl_7_3T_EvictManagedTextures,
};
......
......@@ -315,7 +315,9 @@ void DDRAW_dump_lockflag(DWORD lockflag)
FE(DDLOCK_EVENT),
FE(DDLOCK_READONLY),
FE(DDLOCK_WRITEONLY),
FE(DDLOCK_NOSYSLOCK)
FE(DDLOCK_NOSYSLOCK),
FE(DDLOCK_DISCARDCONTENTS),
FE(DDLOCK_NOOVERWRITE)
};
DDRAW_dump_flags(lockflag, flags, sizeof(flags)/sizeof(flags[0]));
......
......@@ -119,7 +119,7 @@ extern HRESULT d3dlight_create(IDirect3DLightImpl **obj, IDirect3DImpl *d3d, GLe
extern HRESULT d3dexecutebuffer_create(IDirect3DExecuteBufferImpl **obj, IDirect3DImpl *d3d, IDirect3DDeviceImpl *d3ddev, LPD3DEXECUTEBUFFERDESC lpDesc);
extern HRESULT d3dmaterial_create(IDirect3DMaterialImpl **obj, IDirect3DImpl *d3d);
extern HRESULT d3dviewport_create(IDirect3DViewportImpl **obj, IDirect3DImpl *d3d);
extern HRESULT d3dvertexbuffer_create(IDirect3DVertexBufferImpl **obj, IDirect3DImpl *d3d, LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc);
extern HRESULT d3dvertexbuffer_create(IDirect3DVertexBufferImpl **obj, IDirect3DImpl *d3d, LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc, DWORD dwFlags);
extern HRESULT d3ddevice_create(IDirect3DDeviceImpl **obj, IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *surface);
/* Used for Direct3D to request the device to enumerate itself */
......@@ -127,6 +127,10 @@ extern HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context,
extern HRESULT d3ddevice_enumerate7(LPD3DENUMDEVICESCALLBACK7 cb, LPVOID context) ;
extern HRESULT d3ddevice_find(IDirect3DImpl *d3d, LPD3DFINDDEVICESEARCH lpD3DDFS, LPD3DFINDDEVICERESULT lplpD3DDevice, DWORD interface_version);
/* Some helper functions.. Would need to put them in a better place */
extern void dump_flexible_vertex(DWORD d3dvtVertexType);
extern DWORD get_flexible_vertex_size(DWORD d3dvtVertexType);
/* Matrix copy WITH transposition */
#define conv_mat2(mat,gl_mat) \
{ \
......
......@@ -1319,6 +1319,8 @@ ICOM_DEFINE(IDirectDraw,IUnknown)
#define DDLOCK_READONLY 0x00000010
#define DDLOCK_WRITEONLY 0x00000020
#define DDLOCK_NOSYSLOCK 0x00000800
#define DDLOCK_NOOVERWRITE 0x00001000
#define DDLOCK_DISCARDCONTENTS 0x00002000
/*****************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment