Commit 1392c77d authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

Remove all openGL calls in execute buffers and use the Direct3D7 APIs.

Enable retrieving the render target surface of a device through its QueryInterface method. Avoid lights updating when a viewport and a device have not been associated to them. Clear the Z buffer only when we're asked to by Checking D3DBTL_FILL flag.
parent 3da6ff75
......@@ -175,7 +175,8 @@ struct IDirect3DExecuteBufferImpl
/* This buffer will store the transformed vertices */
void* vertex_data;
D3DVERTEXTYPE vertex_type;
WORD* indices;
int nb_indices;
/* This flags is set to TRUE if we allocated ourselves the
data buffer */
......@@ -290,6 +291,7 @@ extern DWORD get_flexible_vertex_size(DWORD d3dvtVertexType);
extern void convert_FVF_to_strided_data(DWORD d3dvtVertexType, LPVOID lpvVertices, D3DDRAWPRIMITIVESTRIDEDDATA *strided, DWORD dwStartVertex);
extern void dump_D3DVOP(DWORD dwVertexOp);
extern void dump_D3DPV(DWORD dwFlags);
extern void multiply_matrix(LPD3DMATRIX,LPD3DMATRIX,LPD3DMATRIX);
extern const float id_mat[16];
......
......@@ -353,3 +353,33 @@ dump_D3DPV(DWORD dwFlags)
else if (dwFlags != 0) DPRINTF("Unknown !!!\n");
else DPRINTF("\n");
}
void multiply_matrix(LPD3DMATRIX dest, LPD3DMATRIX src1, LPD3DMATRIX src2)
{
D3DMATRIX temp;
/* Now do the multiplication 'by hand'.
I know that all this could be optimised, but this will be done later :-) */
temp._11 = (src1->_11 * src2->_11) + (src1->_21 * src2->_12) + (src1->_31 * src2->_13) + (src1->_41 * src2->_14);
temp._21 = (src1->_11 * src2->_21) + (src1->_21 * src2->_22) + (src1->_31 * src2->_23) + (src1->_41 * src2->_24);
temp._31 = (src1->_11 * src2->_31) + (src1->_21 * src2->_32) + (src1->_31 * src2->_33) + (src1->_41 * src2->_34);
temp._41 = (src1->_11 * src2->_41) + (src1->_21 * src2->_42) + (src1->_31 * src2->_43) + (src1->_41 * src2->_44);
temp._12 = (src1->_12 * src2->_11) + (src1->_22 * src2->_12) + (src1->_32 * src2->_13) + (src1->_42 * src2->_14);
temp._22 = (src1->_12 * src2->_21) + (src1->_22 * src2->_22) + (src1->_32 * src2->_23) + (src1->_42 * src2->_24);
temp._32 = (src1->_12 * src2->_31) + (src1->_22 * src2->_32) + (src1->_32 * src2->_33) + (src1->_42 * src2->_34);
temp._42 = (src1->_12 * src2->_41) + (src1->_22 * src2->_42) + (src1->_32 * src2->_43) + (src1->_42 * src2->_44);
temp._13 = (src1->_13 * src2->_11) + (src1->_23 * src2->_12) + (src1->_33 * src2->_13) + (src1->_43 * src2->_14);
temp._23 = (src1->_13 * src2->_21) + (src1->_23 * src2->_22) + (src1->_33 * src2->_23) + (src1->_43 * src2->_24);
temp._33 = (src1->_13 * src2->_31) + (src1->_23 * src2->_32) + (src1->_33 * src2->_33) + (src1->_43 * src2->_34);
temp._43 = (src1->_13 * src2->_41) + (src1->_23 * src2->_42) + (src1->_33 * src2->_43) + (src1->_43 * src2->_44);
temp._14 = (src1->_14 * src2->_11) + (src1->_24 * src2->_12) + (src1->_34 * src2->_13) + (src1->_44 * src2->_14);
temp._24 = (src1->_14 * src2->_21) + (src1->_24 * src2->_22) + (src1->_34 * src2->_23) + (src1->_44 * src2->_24);
temp._34 = (src1->_14 * src2->_31) + (src1->_24 * src2->_32) + (src1->_34 * src2->_33) + (src1->_44 * src2->_34);
temp._44 = (src1->_14 * src2->_41) + (src1->_24 * src2->_42) + (src1->_34 * src2->_43) + (src1->_44 * src2->_44);
/* And copy the new matrix in the good storage.. */
memcpy(dest, &temp, 16 * sizeof(D3DVALUE));
}
......@@ -233,6 +233,21 @@ Main_IDirect3DDeviceImpl_7_3T_2T_1T_QueryInterface(LPDIRECT3DDEVICE7 iface,
TRACE(" Creating IDirect3DDevice7 interface %p\n", *obp);
return S_OK;
}
if ( IsEqualGUID( &IID_IDirectDrawSurface, riid ) ||
IsEqualGUID( &IID_IDirectDrawSurface2, riid ) ||
IsEqualGUID( &IID_IDirectDrawSurface3, riid ) ) {
IDirectDrawSurface7_AddRef(ICOM_INTERFACE(This->surface, IDirectDrawSurface7));
*obp = ICOM_INTERFACE(This->surface, IDirectDrawSurface3);
TRACE(" Return IDirectDrawSurface3 interface %p\n", *obp);
return S_OK;
}
if ( IsEqualGUID( &IID_IDirectDrawSurface3, riid ) ||
IsEqualGUID( &IID_IDirectDrawSurface7, riid ) ) {
IDirectDrawSurface7_AddRef(ICOM_INTERFACE(This->surface, IDirectDrawSurface7));
*obp = ICOM_INTERFACE(This->surface, IDirectDrawSurface7);
TRACE(" Return IDirectDrawSurface7 interface %p\n", *obp);
return S_OK;
}
FIXME("(%p): interface for IID %s NOT found!\n", This, debugstr_guid(riid));
return OLE_E_ENUM_NOMORE;
}
......@@ -484,7 +499,6 @@ Main_IDirect3DDeviceImpl_7_3T_2T_MultiplyTransform(LPDIRECT3DDEVICE7 iface,
{
ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
LPD3DMATRIX mat;
D3DMATRIX temp;
DWORD matrix_changed = 0x00000000;
TRACE("(%p/%p)->(%08x,%p)\n", This, iface, dtstTransformStateType, lpD3DMatrix);
......@@ -539,31 +553,8 @@ Main_IDirect3DDeviceImpl_7_3T_2T_MultiplyTransform(LPDIRECT3DDEVICE7 iface,
return DDERR_INVALIDPARAMS;
}
/* Now do the multiplication 'by hand'.
I know that all this could be optimised, but this will be done later :-) */
temp._11 = (mat->_11 * lpD3DMatrix->_11) + (mat->_21 * lpD3DMatrix->_12) + (mat->_31 * lpD3DMatrix->_13) + (mat->_41 * lpD3DMatrix->_14);
temp._21 = (mat->_11 * lpD3DMatrix->_21) + (mat->_21 * lpD3DMatrix->_22) + (mat->_31 * lpD3DMatrix->_23) + (mat->_41 * lpD3DMatrix->_24);
temp._31 = (mat->_11 * lpD3DMatrix->_31) + (mat->_21 * lpD3DMatrix->_32) + (mat->_31 * lpD3DMatrix->_33) + (mat->_41 * lpD3DMatrix->_34);
temp._41 = (mat->_11 * lpD3DMatrix->_41) + (mat->_21 * lpD3DMatrix->_42) + (mat->_31 * lpD3DMatrix->_43) + (mat->_41 * lpD3DMatrix->_44);
temp._12 = (mat->_12 * lpD3DMatrix->_11) + (mat->_22 * lpD3DMatrix->_12) + (mat->_32 * lpD3DMatrix->_13) + (mat->_42 * lpD3DMatrix->_14);
temp._22 = (mat->_12 * lpD3DMatrix->_21) + (mat->_22 * lpD3DMatrix->_22) + (mat->_32 * lpD3DMatrix->_23) + (mat->_42 * lpD3DMatrix->_24);
temp._32 = (mat->_12 * lpD3DMatrix->_31) + (mat->_22 * lpD3DMatrix->_32) + (mat->_32 * lpD3DMatrix->_33) + (mat->_42 * lpD3DMatrix->_34);
temp._42 = (mat->_12 * lpD3DMatrix->_41) + (mat->_22 * lpD3DMatrix->_42) + (mat->_32 * lpD3DMatrix->_43) + (mat->_42 * lpD3DMatrix->_44);
temp._13 = (mat->_13 * lpD3DMatrix->_11) + (mat->_23 * lpD3DMatrix->_12) + (mat->_33 * lpD3DMatrix->_13) + (mat->_43 * lpD3DMatrix->_14);
temp._23 = (mat->_13 * lpD3DMatrix->_21) + (mat->_23 * lpD3DMatrix->_22) + (mat->_33 * lpD3DMatrix->_23) + (mat->_43 * lpD3DMatrix->_24);
temp._33 = (mat->_13 * lpD3DMatrix->_31) + (mat->_23 * lpD3DMatrix->_32) + (mat->_33 * lpD3DMatrix->_33) + (mat->_43 * lpD3DMatrix->_34);
temp._43 = (mat->_13 * lpD3DMatrix->_41) + (mat->_23 * lpD3DMatrix->_42) + (mat->_33 * lpD3DMatrix->_43) + (mat->_43 * lpD3DMatrix->_44);
temp._14 = (mat->_14 * lpD3DMatrix->_11) + (mat->_24 * lpD3DMatrix->_12) + (mat->_34 * lpD3DMatrix->_13) + (mat->_44 * lpD3DMatrix->_14);
temp._24 = (mat->_14 * lpD3DMatrix->_21) + (mat->_24 * lpD3DMatrix->_22) + (mat->_34 * lpD3DMatrix->_23) + (mat->_44 * lpD3DMatrix->_24);
temp._34 = (mat->_14 * lpD3DMatrix->_31) + (mat->_24 * lpD3DMatrix->_32) + (mat->_34 * lpD3DMatrix->_33) + (mat->_44 * lpD3DMatrix->_34);
temp._44 = (mat->_14 * lpD3DMatrix->_41) + (mat->_24 * lpD3DMatrix->_42) + (mat->_34 * lpD3DMatrix->_43) + (mat->_44 * lpD3DMatrix->_44);
multiply_matrix(mat,mat,lpD3DMatrix);
/* And copy the new matrix in the good storage.. */
memcpy(mat, &temp, 16 * sizeof(D3DVALUE));
if (TRACE_ON(ddraw)) {
dump_D3DMATRIX(mat);
}
......
......@@ -145,7 +145,10 @@ Main_IDirect3DLightImpl_1_GetLight(LPDIRECT3DLIGHT iface,
*/
static void update(IDirect3DLightImpl* This) {
IDirect3DDeviceImpl* device = This->active_viewport->active_device;
IDirect3DDeviceImpl* device;
if (!This->active_viewport||!This->active_viewport->active_device)
return;
device = This->active_viewport->active_device;
IDirect3DDevice7_SetLight(ICOM_INTERFACE(device,IDirect3DDevice7),This->dwLightIndex,&(This->light7));
}
......
......@@ -132,7 +132,7 @@ FakeZBuffer_DirectDrawSurface_Blt(LPDIRECTDRAWSURFACE7 iface, LPRECT rdst,
}
/* We only support the BLT with DEPTH_FILL for now */
if (This->ddraw_owner->d3d != NULL) {
if ((dwFlags & DDBLT_DEPTHFILL) && This->ddraw_owner->d3d != NULL) {
if (This->ddraw_owner->d3d->current_device != NULL) {
This->ddraw_owner->d3d->current_device->clear(This->ddraw_owner->d3d->current_device,
0, NULL, /* Clear the whole screen */
......
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