- create a function to set the various transformation matrices to

factorize the code between the various code path
- fixed some logging stuff
This commit is contained in:
Lionel Ulmer 2003-01-03 21:05:38 +00:00 committed by Alexandre Julliard
parent 74c95ec008
commit 0114945b6d
8 changed files with 215 additions and 254 deletions

View File

@ -168,6 +168,10 @@ struct IDirect3DExecuteBufferImpl
#define MAX_TEXTURES 8 #define MAX_TEXTURES 8
#define MAX_LIGHTS 16 #define MAX_LIGHTS 16
#define WORLDMAT_CHANGED (0x00000001 << 0)
#define VIEWMAT_CHANGED (0x00000001 << 1)
#define PROJMAT_CHANGED (0x00000001 << 2)
struct IDirect3DDeviceImpl struct IDirect3DDeviceImpl
{ {
ICOM_VFIELD_MULTI(IDirect3DDevice7); ICOM_VFIELD_MULTI(IDirect3DDevice7);
@ -205,6 +209,9 @@ struct IDirect3DDeviceImpl
DWORD dwColor, DWORD dwColor,
D3DVALUE dvZ, D3DVALUE dvZ,
DWORD dwStencil); DWORD dwStencil);
void (*matrices_updated)(IDirect3DDeviceImpl *This, DWORD matrices);
void (*set_matrices)(IDirect3DDeviceImpl *This, DWORD matrices,
D3DMATRIX *world_mat, D3DMATRIX *view_mat, D3DMATRIX *proj_mat);
}; };
/***************************************************************************** /*****************************************************************************
@ -221,17 +228,15 @@ struct IDirect3DVertexBufferImpl
DWORD vertex_buffer_size; DWORD vertex_buffer_size;
}; };
/* Various dump functions */ /* Various dump and helper functions */
extern const char *_get_renderstate(D3DRENDERSTATETYPE type); extern const char *_get_renderstate(D3DRENDERSTATETYPE type);
extern void dump_D3DMATERIAL7(LPD3DMATERIAL7 lpMat); extern void dump_D3DMATERIAL7(LPD3DMATERIAL7 lpMat);
extern void dump_D3DCOLORVALUE(D3DCOLORVALUE *lpCol); extern void dump_D3DCOLORVALUE(D3DCOLORVALUE *lpCol);
extern void dump_D3DLIGHT7(LPD3DLIGHT7 lpLight); extern void dump_D3DLIGHT7(LPD3DLIGHT7 lpLight);
extern void dump_DPFLAGS(DWORD dwFlags); extern void dump_DPFLAGS(DWORD dwFlags);
extern void dump_D3DMATRIX(D3DMATRIX *mat);
#define dump_mat(mat) \ extern void dump_D3DVECTOR(D3DVECTOR *lpVec);
TRACE("%f %f %f %f\n", (mat)->_11, (mat)->_12, (mat)->_13, (mat)->_14); \ extern void dump_flexible_vertex(DWORD d3dvtVertexType);
TRACE("%f %f %f %f\n", (mat)->_21, (mat)->_22, (mat)->_23, (mat)->_24); \ extern DWORD get_flexible_vertex_size(DWORD d3dvtVertexType, DWORD *elements);
TRACE("%f %f %f %f\n", (mat)->_31, (mat)->_32, (mat)->_33, (mat)->_34); \
TRACE("%f %f %f %f\n", (mat)->_41, (mat)->_42, (mat)->_43, (mat)->_44);
#endif /* __GRAPHICS_WINE_D3D_PRIVATE_H */ #endif /* __GRAPHICS_WINE_D3D_PRIVATE_H */

View File

@ -219,3 +219,74 @@ dump_DPFLAGS(DWORD dwFlags)
DDRAW_dump_flags(dwFlags, flags, sizeof(flags)/sizeof(flags[0])); DDRAW_dump_flags(dwFlags, flags, sizeof(flags)/sizeof(flags[0]));
} }
void
dump_D3DMATRIX(D3DMATRIX *mat)
{
DPRINTF(" %f %f %f %f\n", mat->_11, mat->_12, mat->_13, mat->_14);
DPRINTF(" %f %f %f %f\n", mat->_21, mat->_22, mat->_23, mat->_24);
DPRINTF(" %f %f %f %f\n", mat->_31, mat->_32, mat->_33, mat->_34);
DPRINTF(" %f %f %f %f\n", mat->_41, mat->_42, mat->_43, mat->_44);
}
DWORD get_flexible_vertex_size(DWORD d3dvtVertexType, DWORD *elements)
{
DWORD size = 0;
DWORD elts = 0;
if (d3dvtVertexType & D3DFVF_NORMAL) { size += 3 * sizeof(D3DVALUE); elts += 1; }
if (d3dvtVertexType & D3DFVF_DIFFUSE) { size += sizeof(DWORD); elts += 1; }
if (d3dvtVertexType & D3DFVF_SPECULAR) { size += sizeof(DWORD); elts += 1; }
switch (d3dvtVertexType & D3DFVF_POSITION_MASK) {
case D3DFVF_XYZ: size += 3 * sizeof(D3DVALUE); elts += 1; break;
case D3DFVF_XYZRHW: size += 4 * sizeof(D3DVALUE); elts += 1; break;
default: TRACE(" matrix weighting not handled yet...\n");
}
size += 2 * sizeof(D3DVALUE) * ((d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT);
elts += (d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
if (elements) *elements = elts;
return size;
}
void dump_flexible_vertex(DWORD d3dvtVertexType)
{
static const flag_info flags[] = {
FE(D3DFVF_NORMAL),
FE(D3DFVF_RESERVED1),
FE(D3DFVF_DIFFUSE),
FE(D3DFVF_SPECULAR)
};
int i;
if (d3dvtVertexType & D3DFVF_RESERVED0) DPRINTF("D3DFVF_RESERVED0 ");
switch (d3dvtVertexType & D3DFVF_POSITION_MASK) {
#define GEN_CASE(a) case a: DPRINTF(#a " "); break
GEN_CASE(D3DFVF_XYZ);
GEN_CASE(D3DFVF_XYZRHW);
GEN_CASE(D3DFVF_XYZB1);
GEN_CASE(D3DFVF_XYZB2);
GEN_CASE(D3DFVF_XYZB3);
GEN_CASE(D3DFVF_XYZB4);
GEN_CASE(D3DFVF_XYZB5);
}
DDRAW_dump_flags_(d3dvtVertexType, flags, sizeof(flags)/sizeof(flags[0]), FALSE);
switch (d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) {
GEN_CASE(D3DFVF_TEX0);
GEN_CASE(D3DFVF_TEX1);
GEN_CASE(D3DFVF_TEX2);
GEN_CASE(D3DFVF_TEX3);
GEN_CASE(D3DFVF_TEX4);
GEN_CASE(D3DFVF_TEX5);
GEN_CASE(D3DFVF_TEX6);
GEN_CASE(D3DFVF_TEX7);
GEN_CASE(D3DFVF_TEX8);
}
#undef GEN_CASE
for (i = 0; i < ((d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT); i++) {
DPRINTF(" T%d-s%ld", i + 1, (((d3dvtVertexType >> (16 + (2 * i))) + 1) & 0x03) + 1);
}
DPRINTF("\n");
}

View File

@ -206,7 +206,42 @@ Main_IDirect3DDeviceImpl_7_3T_2T_SetTransform(LPDIRECT3DDEVICE7 iface,
LPD3DMATRIX lpD3DMatrix) LPD3DMATRIX lpD3DMatrix)
{ {
ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
FIXME("(%p/%p)->(%08x,%p): stub!\n", This, iface, dtstTransformStateType, lpD3DMatrix); DWORD matrix_changed = 0x00000000;
TRACE("(%p/%p)->(%08x,%p)\n", This, iface, dtstTransformStateType, lpD3DMatrix);
switch (dtstTransformStateType) {
case D3DTRANSFORMSTATE_WORLD: {
if (TRACE_ON(ddraw)) {
TRACE(" D3DTRANSFORMSTATE_WORLD :\n"); dump_D3DMATRIX(lpD3DMatrix);
}
memcpy(This->world_mat, lpD3DMatrix, 16 * sizeof(float));
matrix_changed = WORLDMAT_CHANGED;
} break;
case D3DTRANSFORMSTATE_VIEW: {
if (TRACE_ON(ddraw)) {
TRACE(" D3DTRANSFORMSTATE_VIEW :\n"); dump_D3DMATRIX(lpD3DMatrix);
}
memcpy(This->view_mat, lpD3DMatrix, 16 * sizeof(float));
matrix_changed = VIEWMAT_CHANGED;
} break;
case D3DTRANSFORMSTATE_PROJECTION: {
if (TRACE_ON(ddraw)) {
TRACE(" D3DTRANSFORMSTATE_PROJECTION :\n"); dump_D3DMATRIX(lpD3DMatrix);
}
memcpy(This->proj_mat, lpD3DMatrix, 16 * sizeof(float));
matrix_changed = PROJMAT_CHANGED;
} break;
default:
ERR("Unknown transform type %08x !!!\n", dtstTransformStateType);
break;
}
if (matrix_changed != 0x00000000) This->matrices_updated(This, matrix_changed);
return DD_OK; return DD_OK;
} }
@ -220,21 +255,27 @@ Main_IDirect3DDeviceImpl_7_3T_2T_GetTransform(LPDIRECT3DDEVICE7 iface,
switch (dtstTransformStateType) { switch (dtstTransformStateType) {
case D3DTRANSFORMSTATE_WORLD: { case D3DTRANSFORMSTATE_WORLD: {
if (TRACE_ON(ddraw)) {
TRACE(" returning D3DTRANSFORMSTATE_WORLD :\n"); TRACE(" returning D3DTRANSFORMSTATE_WORLD :\n");
dump_D3DMATRIX(lpD3DMatrix);
}
memcpy(lpD3DMatrix, This->world_mat, 16 * sizeof(D3DVALUE)); memcpy(lpD3DMatrix, This->world_mat, 16 * sizeof(D3DVALUE));
dump_mat(lpD3DMatrix);
} break; } break;
case D3DTRANSFORMSTATE_VIEW: { case D3DTRANSFORMSTATE_VIEW: {
if (TRACE_ON(ddraw)) {
TRACE(" returning D3DTRANSFORMSTATE_VIEW :\n"); TRACE(" returning D3DTRANSFORMSTATE_VIEW :\n");
dump_D3DMATRIX(lpD3DMatrix);
}
memcpy(lpD3DMatrix, This->world_mat, 16 * sizeof(D3DVALUE)); memcpy(lpD3DMatrix, This->world_mat, 16 * sizeof(D3DVALUE));
dump_mat(lpD3DMatrix);
} break; } break;
case D3DTRANSFORMSTATE_PROJECTION: { case D3DTRANSFORMSTATE_PROJECTION: {
if (TRACE_ON(ddraw)) {
TRACE(" returning D3DTRANSFORMSTATE_PROJECTION :\n"); TRACE(" returning D3DTRANSFORMSTATE_PROJECTION :\n");
dump_D3DMATRIX(lpD3DMatrix);
}
memcpy(lpD3DMatrix, This->world_mat, 16 * sizeof(D3DVALUE)); memcpy(lpD3DMatrix, This->world_mat, 16 * sizeof(D3DVALUE));
dump_mat(lpD3DMatrix);
} break; } break;
default: default:
@ -1098,7 +1139,7 @@ Main_IDirect3DDeviceImpl_1_SetMatrix(LPDIRECT3DDEVICE iface,
ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface); ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface);
TRACE("(%p/%p)->(%08lx,%p)\n", This, iface, (DWORD) D3DMatHandle, lpD3DMatrix); TRACE("(%p/%p)->(%08lx,%p)\n", This, iface, (DWORD) D3DMatHandle, lpD3DMatrix);
dump_mat(lpD3DMatrix); dump_D3DMATRIX(lpD3DMatrix);
*((D3DMATRIX *) D3DMatHandle) = *lpD3DMatrix; *((D3DMATRIX *) D3DMatHandle) = *lpD3DMatrix;
return DD_OK; return DD_OK;

View File

@ -588,88 +588,6 @@ GL_IDirect3DDeviceImpl_3_2T_SetLightState(LPDIRECT3DDEVICE3 iface,
return DD_OK; return DD_OK;
} }
HRESULT WINAPI
GL_IDirect3DDeviceImpl_7_3T_2T_SetTransform(LPDIRECT3DDEVICE7 iface,
D3DTRANSFORMSTATETYPE dtstTransformStateType,
LPD3DMATRIX lpD3DMatrix)
{
ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
IDirect3DDeviceGLImpl *glThis = (IDirect3DDeviceGLImpl *) This;
TRACE("(%p/%p)->(%08x,%p)\n", This, iface, dtstTransformStateType, lpD3DMatrix);
ENTER_GL();
/* Using a trial and failure approach, I found that the order of
Direct3D transformations that works best is :
ScreenCoord = ProjectionMat * ViewMat * WorldMat * ObjectCoord
As OpenGL uses only two matrices, I combined PROJECTION and VIEW into
OpenGL's GL_PROJECTION matrix and the WORLD into GL_MODELVIEW.
If anyone has a good explanation of the three different matrices in
the SDK online documentation, feel free to point it to me. For example,
which matrices transform lights ? In OpenGL only the PROJECTION matrix
transform the lights, not the MODELVIEW. Using the matrix names, I
supposed that PROJECTION and VIEW (all 'camera' related names) do
transform lights, but WORLD do not. It may be wrong though... */
/* After reading through both OpenGL and Direct3D documentations, I
thought that D3D matrices were written in 'line major mode' transposed
from OpenGL's 'column major mode'. But I found out that a simple memcpy
works fine to transfer one matrix format to the other (it did not work
when transposing)....
So :
1) are the documentations wrong
2) does the matrix work even if they are not read correctly
3) is Mesa's implementation of OpenGL not compliant regarding Matrix
loading using glLoadMatrix ?
Anyway, I always use 'conv_mat' to transfer the matrices from one format
to the other so that if I ever find out that I need to transpose them, I
will able to do it quickly, only by changing the macro conv_mat. */
switch (dtstTransformStateType) {
case D3DTRANSFORMSTATE_WORLD: {
TRACE(" D3DTRANSFORMSTATE_WORLD :\n");
conv_mat(lpD3DMatrix, This->world_mat);
if (glThis->last_vertices_transformed == FALSE) {
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf((float *) This->view_mat);
glMultMatrixf((float *) This->world_mat);
}
} break;
case D3DTRANSFORMSTATE_VIEW: {
TRACE(" D3DTRANSFORMSTATE_VIEW :\n");
conv_mat(lpD3DMatrix, This->view_mat);
if (glThis->last_vertices_transformed == FALSE) {
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf((float *) This->view_mat);
glMultMatrixf((float *) This->world_mat);
}
} break;
case D3DTRANSFORMSTATE_PROJECTION: {
TRACE(" D3DTRANSFORMSTATE_PROJECTION :\n");
conv_mat(lpD3DMatrix, This->proj_mat);
if (glThis->last_vertices_transformed == FALSE) {
glMatrixMode(GL_PROJECTION);
glLoadMatrixf((float *) This->proj_mat);
}
} break;
default:
ERR("Unknown transform type %08x !!!\n", dtstTransformStateType);
break;
}
LEAVE_GL();
return DD_OK;
}
static void draw_primitive_start_GL(D3DPRIMITIVETYPE d3dpt) static void draw_primitive_start_GL(D3DPRIMITIVETYPE d3dpt)
{ {
switch (d3dpt) { switch (d3dpt) {
@ -716,22 +634,23 @@ static void draw_primitive_handle_GL_state(IDirect3DDeviceImpl *This,
/* Puts GL in the correct lighting / transformation mode */ /* Puts GL in the correct lighting / transformation mode */
if ((vertex_transformed == FALSE) && if ((vertex_transformed == FALSE) &&
(glThis->last_vertices_transformed == TRUE)) { (glThis->transform_state != GL_TRANSFORM_NORMAL)) {
/* Need to put the correct transformation again if we go from Transformed /* Need to put the correct transformation again if we go from Transformed
vertices to non-transformed ones. vertices to non-transformed ones.
*/ */
glMatrixMode(GL_MODELVIEW); This->set_matrices(This, VIEWMAT_CHANGED|WORLDMAT_CHANGED|PROJMAT_CHANGED,
glLoadMatrixf((float *) This->view_mat); This->world_mat, This->view_mat, This->proj_mat);
glMultMatrixf((float *) This->world_mat); glThis->transform_state = GL_TRANSFORM_NORMAL;
glMatrixMode(GL_PROJECTION);
glLoadMatrixf((float *) This->proj_mat);
if (glThis->render_state.fog_on == TRUE) glEnable(GL_FOG); if (glThis->render_state.fog_on == TRUE)
glEnable(GL_FOG);
} else if ((vertex_transformed == TRUE) && } else if ((vertex_transformed == TRUE) &&
(glThis->last_vertices_transformed == FALSE)) { (glThis->transform_state != GL_TRANSFORM_ORTHO)) {
GLfloat height, width; GLfloat height, width;
GLfloat trans_mat[16]; GLfloat trans_mat[16];
glThis->transform_state = GL_TRANSFORM_ORTHO;
width = glThis->parent.surface->surface_desc.dwWidth; width = glThis->parent.surface->surface_desc.dwWidth;
height = glThis->parent.surface->surface_desc.dwHeight; height = glThis->parent.surface->surface_desc.dwHeight;
@ -770,9 +689,6 @@ static void draw_primitive_handle_GL_state(IDirect3DDeviceImpl *This,
} }
} }
} }
/* And save the current state */
glThis->last_vertices_transformed = vertex_transformed;
} }
@ -883,67 +799,6 @@ GL_IDirect3DDeviceImpl_1_CreateExecuteBuffer(LPDIRECT3DDEVICE iface,
return ret_value; return ret_value;
} }
DWORD get_flexible_vertex_size(DWORD d3dvtVertexType, DWORD *elements)
{
DWORD size = 0;
DWORD elts = 0;
if (d3dvtVertexType & D3DFVF_NORMAL) { size += 3 * sizeof(D3DVALUE); elts += 1; }
if (d3dvtVertexType & D3DFVF_DIFFUSE) { size += sizeof(DWORD); elts += 1; }
if (d3dvtVertexType & D3DFVF_SPECULAR) { size += sizeof(DWORD); elts += 1; }
switch (d3dvtVertexType & D3DFVF_POSITION_MASK) {
case D3DFVF_XYZ: size += 3 * sizeof(D3DVALUE); elts += 1; break;
case D3DFVF_XYZRHW: size += 4 * sizeof(D3DVALUE); elts += 1; break;
default: TRACE(" matrix weighting not handled yet...\n");
}
size += 2 * sizeof(D3DVALUE) * ((d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT);
elts += (d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
if (elements) *elements = elts;
return size;
}
void dump_flexible_vertex(DWORD d3dvtVertexType)
{
static const flag_info flags[] = {
FE(D3DFVF_NORMAL),
FE(D3DFVF_RESERVED1),
FE(D3DFVF_DIFFUSE),
FE(D3DFVF_SPECULAR)
};
int i;
if (d3dvtVertexType & D3DFVF_RESERVED0) DPRINTF("D3DFVF_RESERVED0 ");
switch (d3dvtVertexType & D3DFVF_POSITION_MASK) {
#define GEN_CASE(a) case a: DPRINTF(#a " "); break
GEN_CASE(D3DFVF_XYZ);
GEN_CASE(D3DFVF_XYZRHW);
GEN_CASE(D3DFVF_XYZB1);
GEN_CASE(D3DFVF_XYZB2);
GEN_CASE(D3DFVF_XYZB3);
GEN_CASE(D3DFVF_XYZB4);
GEN_CASE(D3DFVF_XYZB5);
}
DDRAW_dump_flags_(d3dvtVertexType, flags, sizeof(flags)/sizeof(flags[0]), FALSE);
switch (d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) {
GEN_CASE(D3DFVF_TEX0);
GEN_CASE(D3DFVF_TEX1);
GEN_CASE(D3DFVF_TEX2);
GEN_CASE(D3DFVF_TEX3);
GEN_CASE(D3DFVF_TEX4);
GEN_CASE(D3DFVF_TEX5);
GEN_CASE(D3DFVF_TEX6);
GEN_CASE(D3DFVF_TEX7);
GEN_CASE(D3DFVF_TEX8);
}
#undef GEN_CASE
for (i = 0; i < ((d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT); i++) {
DPRINTF(" T%d-s%ld", i + 1, (((d3dvtVertexType >> (16 + (2 * i))) + 1) & 0x03) + 1);
}
DPRINTF("\n");
}
/* These are the various handler used in the generic path */ /* These are the various handler used in the generic path */
inline static void handle_xyz(D3DVALUE *coords) { inline static void handle_xyz(D3DVALUE *coords) {
glVertex3fv(coords); glVertex3fv(coords);
@ -1745,7 +1600,7 @@ ICOM_VTABLE(IDirect3DDevice7) VTABLE_IDirect3DDevice7 =
XCAST(SetRenderTarget) Main_IDirect3DDeviceImpl_7_3T_2T_SetRenderTarget, XCAST(SetRenderTarget) Main_IDirect3DDeviceImpl_7_3T_2T_SetRenderTarget,
XCAST(GetRenderTarget) Main_IDirect3DDeviceImpl_7_3T_2T_GetRenderTarget, XCAST(GetRenderTarget) Main_IDirect3DDeviceImpl_7_3T_2T_GetRenderTarget,
XCAST(Clear) Main_IDirect3DDeviceImpl_7_Clear, XCAST(Clear) Main_IDirect3DDeviceImpl_7_Clear,
XCAST(SetTransform) GL_IDirect3DDeviceImpl_7_3T_2T_SetTransform, XCAST(SetTransform) Main_IDirect3DDeviceImpl_7_3T_2T_SetTransform,
XCAST(GetTransform) Main_IDirect3DDeviceImpl_7_3T_2T_GetTransform, XCAST(GetTransform) Main_IDirect3DDeviceImpl_7_3T_2T_GetTransform,
XCAST(SetViewport) Main_IDirect3DDeviceImpl_7_SetViewport, XCAST(SetViewport) Main_IDirect3DDeviceImpl_7_SetViewport,
XCAST(MultiplyTransform) Main_IDirect3DDeviceImpl_7_3T_2T_MultiplyTransform, XCAST(MultiplyTransform) Main_IDirect3DDeviceImpl_7_3T_2T_MultiplyTransform,
@ -2035,6 +1890,30 @@ d3ddevice_bltfast(IDirectDrawSurfaceImpl *This, DWORD dstx,
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
} }
void
d3ddevice_set_matrices(IDirect3DDeviceImpl *This, DWORD matrices,
D3DMATRIX *world_mat, D3DMATRIX *view_mat, D3DMATRIX *proj_mat)
{
if ((matrices & (VIEWMAT_CHANGED|WORLDMAT_CHANGED)) != 0) {
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf((float *) view_mat);
glMultMatrixf((float *) world_mat);
}
if ((matrices & PROJMAT_CHANGED) != 0) {
glMatrixMode(GL_PROJECTION);
glLoadMatrixf((float *) proj_mat);
}
}
void
d3ddevice_matrices_updated(IDirect3DDeviceImpl *This, DWORD matrices)
{
IDirect3DDeviceGLImpl *glThis = (IDirect3DDeviceGLImpl *) This;
if (glThis->transform_state == GL_TRANSFORM_NORMAL) {
/* This will force an update of the transform state at the next drawing. */
glThis->transform_state = GL_TRANSFORM_NONE;
}
}
/* TODO for both these functions : /* TODO for both these functions :
- change / restore OpenGL parameters for pictures transfers in case they are ever modified - change / restore OpenGL parameters for pictures transfers in case they are ever modified
@ -2152,6 +2031,8 @@ d3ddevice_create(IDirect3DDeviceImpl **obj, IDirect3DImpl *d3d, IDirectDrawSurfa
object->surface = surface; object->surface = surface;
object->set_context = set_context; object->set_context = set_context;
object->clear = d3ddevice_clear; object->clear = d3ddevice_clear;
object->set_matrices = d3ddevice_set_matrices;
object->matrices_updated = d3ddevice_matrices_updated;
TRACE(" creating OpenGL device for surface = %p, d3d = %p\n", surface, d3d); TRACE(" creating OpenGL device for surface = %p, d3d = %p\n", surface, d3d);

View File

@ -244,9 +244,9 @@ static void execute(IDirect3DExecuteBufferImpl *This,
transformation phase */ transformation phase */
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
TRACE(" Projection Matrix : (%p)\n", lpDevice->proj_mat); TRACE(" Projection Matrix : (%p)\n", lpDevice->proj_mat);
dump_mat(lpDevice->proj_mat); dump_D3DMATRIX(lpDevice->proj_mat);
TRACE(" View Matrix : (%p)\n", lpDevice->view_mat); TRACE(" View Matrix : (%p)\n", lpDevice->view_mat);
dump_mat(lpDevice->view_mat); dump_D3DMATRIX(lpDevice->view_mat);
/* Although z axis is inverted between OpenGL and Direct3D, the z projected coordinates /* Although z axis is inverted between OpenGL and Direct3D, the z projected coordinates
are always 0.0 at the front viewing volume and 1.0 at the back with Direct 3D and with are always 0.0 at the front viewing volume and 1.0 at the back with Direct 3D and with
@ -266,9 +266,9 @@ static void execute(IDirect3DExecuteBufferImpl *This,
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
TRACE(" Projection Matrix : (%p)\n", lpDevice->proj_mat); TRACE(" Projection Matrix : (%p)\n", lpDevice->proj_mat);
dump_mat(lpDevice->proj_mat); dump_D3DMATRIX(lpDevice->proj_mat);
TRACE(" View Matrix : (%p)\n", lpDevice->view_mat); TRACE(" View Matrix : (%p)\n", lpDevice->view_mat);
dump_mat(lpDevice->view_mat); dump_D3DMATRIX(lpDevice->view_mat);
/* Although z axis is inverted between OpenGL and Direct3D, the z projected coordinates /* Although z axis is inverted between OpenGL and Direct3D, the z projected coordinates
are always 0 at the front viewing volume and 1 at the back with Direct 3D and with are always 0 at the front viewing volume and 1 at the back with Direct 3D and with
@ -535,7 +535,7 @@ static void execute(IDirect3DExecuteBufferImpl *This,
D3DMATRIX *mat = lpDevice->world_mat; D3DMATRIX *mat = lpDevice->world_mat;
TRACE(" World Matrix : (%p)\n", mat); TRACE(" World Matrix : (%p)\n", mat);
dump_mat(mat); dump_D3DMATRIX(mat);
This->vertex_type = D3DVT_VERTEX; This->vertex_type = D3DVT_VERTEX;
@ -564,7 +564,7 @@ static void execute(IDirect3DExecuteBufferImpl *This,
D3DMATRIX *mat = lpDevice->world_mat; D3DMATRIX *mat = lpDevice->world_mat;
TRACE(" World Matrix : (%p)\n", mat); TRACE(" World Matrix : (%p)\n", mat);
dump_mat(mat); dump_D3DMATRIX(mat);
This->vertex_type = D3DVT_LVERTEX; This->vertex_type = D3DVT_LVERTEX;

View File

@ -120,23 +120,21 @@ static void update(IDirect3DLightImpl* This) {
ENTER_GL(); ENTER_GL();
switch (glThis->parent.light.dltType) { switch (glThis->parent.light.dltType) {
case D3DLIGHT_POINT: /* 1 */ case D3DLIGHT_POINT: /* 1 */
TRACE("Activating POINT\n"); FIXME("Activating POINT - not supported yet\n");
break; break;
case D3DLIGHT_SPOT: /* 2 */ case D3DLIGHT_SPOT: /* 2 */
TRACE("Activating SPOT\n"); FIXME("Activating SPOT - not supported yet\n");
break; break;
case D3DLIGHT_DIRECTIONAL: { /* 3 */ case D3DLIGHT_DIRECTIONAL: { /* 3 */
float direction[4]; float direction[4];
if (TRACE_ON(ddraw)) {
TRACE("Activating DIRECTIONAL\n"); TRACE("Activating DIRECTIONAL\n");
TRACE(" direction : %f %f %f\n", DPRINTF(" - direction : "); dump_D3DVECTOR(&(glThis->parent.light.dvDirection)); DPRINTF("\n");
glThis->parent.light.dvDirection.u1.x, DPRINTF(" - color : "); dump_D3DCOLORVALUE(&(glThis->parent.light.dcvColor)); DPRINTF("\n");
glThis->parent.light.dvDirection.u2.y, }
glThis->parent.light.dvDirection.u3.z);
_dump_colorvalue(" color ", glThis->parent.light.dcvColor);
glLightfv(glThis->light_num, GL_AMBIENT, (float *) zero_value); glLightfv(glThis->light_num, GL_AMBIENT, (float *) zero_value);
glLightfv(glThis->light_num, GL_DIFFUSE, (float *) &(glThis->parent.light.dcvColor)); glLightfv(glThis->light_num, GL_DIFFUSE, (float *) &(glThis->parent.light.dcvColor));
@ -149,7 +147,7 @@ static void update(IDirect3DLightImpl* This) {
} break; } break;
case D3DLIGHT_PARALLELPOINT: /* 4 */ case D3DLIGHT_PARALLELPOINT: /* 4 */
TRACE("Activating PARRALLEL-POINT\n"); FIXME("Activating PARRALLEL-POINT - not supported yet\n");
break; break;
default: default:

View File

@ -286,32 +286,32 @@ Thunk_IDirect3DMaterialImpl_1_GetMaterial(LPDIRECT3DMATERIAL iface,
static void activate(IDirect3DMaterialImpl* This) { static void activate(IDirect3DMaterialImpl* This) {
TRACE("Activating material %p\n", This); TRACE("Activating material %p\n", This);
ENTER_GL();
/* Set the current Material */ /* Set the current Material */
_dump_colorvalue("Diffuse", This->mat.u.diffuse); ENTER_GL();
glMaterialfv(GL_FRONT_AND_BACK, glMaterialfv(GL_FRONT_AND_BACK,
GL_DIFFUSE, GL_DIFFUSE,
(float *) &(This->mat.u.diffuse)); (float *) &(This->mat.u.diffuse));
_dump_colorvalue("Ambient", This->mat.u1.ambient);
glMaterialfv(GL_FRONT_AND_BACK, glMaterialfv(GL_FRONT_AND_BACK,
GL_AMBIENT, GL_AMBIENT,
(float *) &(This->mat.u1.ambient)); (float *) &(This->mat.u1.ambient));
_dump_colorvalue("Specular", This->mat.u2.specular);
glMaterialfv(GL_FRONT_AND_BACK, glMaterialfv(GL_FRONT_AND_BACK,
GL_SPECULAR, GL_SPECULAR,
(float *) &(This->mat.u2.specular)); (float *) &(This->mat.u2.specular));
_dump_colorvalue("Emissive", This->mat.u3.emissive);
glMaterialfv(GL_FRONT_AND_BACK, glMaterialfv(GL_FRONT_AND_BACK,
GL_EMISSION, GL_EMISSION,
(float *) &(This->mat.u3.emissive)); (float *) &(This->mat.u3.emissive));
TRACE("Size : %ld\n", This->mat.dwSize);
TRACE("Power : %f\n", This->mat.u4.power);
TRACE("Texture handle : %08lx\n", (DWORD)This->mat.hTexture);
LEAVE_GL(); LEAVE_GL();
if (TRACE_ON(ddraw)) {
DPRINTF(" - size : %ld\n", This->mat.dwSize);
DPRINTF(" - diffuse : "); dump_D3DCOLORVALUE(&(This->mat.u.diffuse)); DPRINTF("\n");
DPRINTF(" - ambient : "); dump_D3DCOLORVALUE(&(This->mat.u1.ambient)); DPRINTF("\n");
DPRINTF(" - specular: "); dump_D3DCOLORVALUE(&(This->mat.u2.specular)); DPRINTF("\n");
DPRINTF(" - emissive: "); dump_D3DCOLORVALUE(&(This->mat.u3.emissive)); DPRINTF("\n");
DPRINTF(" - power : %f\n", This->mat.u4.power);
DPRINTF(" - texture handle : %08lx\n", (DWORD)This->mat.hTexture);
}
return ; return ;
} }

View File

@ -114,6 +114,13 @@ typedef struct IDirect3DTextureGLImpl
void (*set_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal); void (*set_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal);
} IDirect3DTextureGLImpl; } IDirect3DTextureGLImpl;
typedef enum {
GL_TRANSFORM_NONE = 0,
GL_TRANSFORM_ORTHO,
GL_TRANSFORM_NORMAL,
GL_TRANSFORM_VERTEXBUFFER
} GL_TRANSFORM_STATE;
typedef struct IDirect3DDeviceGLImpl typedef struct IDirect3DDeviceGLImpl
{ {
struct IDirect3DDeviceImpl parent; struct IDirect3DDeviceImpl parent;
@ -124,7 +131,7 @@ typedef struct IDirect3DDeviceGLImpl
RenderState render_state; RenderState render_state;
/* The last type of vertex drawn */ /* The last type of vertex drawn */
BOOLEAN last_vertices_transformed; GL_TRANSFORM_STATE transform_state;
Display *display; Display *display;
Drawable drawable; Drawable drawable;
@ -145,48 +152,6 @@ extern HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context)
extern HRESULT d3ddevice_enumerate7(LPD3DENUMDEVICESCALLBACK7 cb, LPVOID context) ; extern HRESULT d3ddevice_enumerate7(LPD3DENUMDEVICESCALLBACK7 cb, LPVOID context) ;
extern HRESULT d3ddevice_find(IDirect3DImpl *d3d, LPD3DFINDDEVICESEARCH lpD3DDFS, LPD3DFINDDEVICERESULT lplpD3DDevice); extern HRESULT d3ddevice_find(IDirect3DImpl *d3d, LPD3DFINDDEVICESEARCH lpD3DDFS, LPD3DFINDDEVICERESULT lplpD3DDevice);
/* 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, DWORD *elements);
/* Matrix copy WITH transposition */
#define conv_mat2(mat,gl_mat) \
{ \
TRACE("%f %f %f %f\n", (mat)->_11, (mat)->_12, (mat)->_13, (mat)->_14); \
TRACE("%f %f %f %f\n", (mat)->_21, (mat)->_22, (mat)->_23, (mat)->_24); \
TRACE("%f %f %f %f\n", (mat)->_31, (mat)->_32, (mat)->_33, (mat)->_34); \
TRACE("%f %f %f %f\n", (mat)->_41, (mat)->_42, (mat)->_43, (mat)->_44); \
(gl_mat)->_11 = (mat)->_11; \
(gl_mat)->_12 = (mat)->_21; \
(gl_mat)->_13 = (mat)->_31; \
(gl_mat)->_14 = (mat)->_41; \
(gl_mat)->_21 = (mat)->_12; \
(gl_mat)->_22 = (mat)->_22; \
(gl_mat)->_23 = (mat)->_32; \
(gl_mat)->_24 = (mat)->_42; \
(gl_mat)->_31 = (mat)->_13; \
(gl_mat)->_32 = (mat)->_23; \
(gl_mat)->_33 = (mat)->_33; \
(gl_mat)->_34 = (mat)->_43; \
(gl_mat)->_41 = (mat)->_14; \
(gl_mat)->_42 = (mat)->_24; \
(gl_mat)->_43 = (mat)->_34; \
(gl_mat)->_44 = (mat)->_44; \
};
/* Matrix copy WITHOUT transposition */
#define conv_mat(mat,gl_mat) \
{ \
TRACE("%f %f %f %f\n", (mat)->_11, (mat)->_12, (mat)->_13, (mat)->_14); \
TRACE("%f %f %f %f\n", (mat)->_21, (mat)->_22, (mat)->_23, (mat)->_24); \
TRACE("%f %f %f %f\n", (mat)->_31, (mat)->_32, (mat)->_33, (mat)->_34); \
TRACE("%f %f %f %f\n", (mat)->_41, (mat)->_42, (mat)->_43, (mat)->_44); \
memcpy(gl_mat, (mat), 16 * sizeof(float)); \
};
#define _dump_colorvalue(s,v) \
DPRINTF(" - " s); dump_D3DCOLORVALUE(&v); DPRINTF("\n");
/* This structure contains all the function pointers to OpenGL extensions /* This structure contains all the function pointers to OpenGL extensions
that are used by Wine */ that are used by Wine */
typedef struct { typedef struct {