Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
0114945b
Commit
0114945b
authored
Jan 03, 2003
by
Lionel Ulmer
Committed by
Alexandre Julliard
Jan 03, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- create a function to set the various transformation matrices to
factorize the code between the various code path - fixed some logging stuff
parent
74c95ec0
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
217 additions
and
256 deletions
+217
-256
d3d_private.h
dlls/ddraw/d3d_private.h
+12
-7
d3dcommon.c
dlls/ddraw/d3dcommon.c
+71
-0
main.c
dlls/ddraw/d3ddevice/main.c
+49
-8
mesa.c
dlls/ddraw/d3ddevice/mesa.c
+36
-155
d3dexecutebuffer.c
dlls/ddraw/d3dexecutebuffer.c
+6
-6
d3dlight.c
dlls/ddraw/d3dlight.c
+8
-10
d3dmaterial.c
dlls/ddraw/d3dmaterial.c
+27
-27
mesa_private.h
dlls/ddraw/mesa_private.h
+8
-43
No files found.
dlls/ddraw/d3d_private.h
View file @
0114945b
...
...
@@ -168,6 +168,10 @@ struct IDirect3DExecuteBufferImpl
#define MAX_TEXTURES 8
#define MAX_LIGHTS 16
#define WORLDMAT_CHANGED (0x00000001 << 0)
#define VIEWMAT_CHANGED (0x00000001 << 1)
#define PROJMAT_CHANGED (0x00000001 << 2)
struct
IDirect3DDeviceImpl
{
ICOM_VFIELD_MULTI
(
IDirect3DDevice7
);
...
...
@@ -205,6 +209,9 @@ struct IDirect3DDeviceImpl
DWORD
dwColor
,
D3DVALUE
dvZ
,
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
;
};
/* Various dump functions */
/* Various dump
and helper
functions */
extern
const
char
*
_get_renderstate
(
D3DRENDERSTATETYPE
type
);
extern
void
dump_D3DMATERIAL7
(
LPD3DMATERIAL7
lpMat
);
extern
void
dump_D3DCOLORVALUE
(
D3DCOLORVALUE
*
lpCol
);
extern
void
dump_D3DLIGHT7
(
LPD3DLIGHT7
lpLight
);
extern
void
dump_DPFLAGS
(
DWORD
dwFlags
);
#define dump_mat(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);
extern
void
dump_D3DMATRIX
(
D3DMATRIX
*
mat
);
extern
void
dump_D3DVECTOR
(
D3DVECTOR
*
lpVec
);
extern
void
dump_flexible_vertex
(
DWORD
d3dvtVertexType
);
extern
DWORD
get_flexible_vertex_size
(
DWORD
d3dvtVertexType
,
DWORD
*
elements
);
#endif
/* __GRAPHICS_WINE_D3D_PRIVATE_H */
dlls/ddraw/d3dcommon.c
View file @
0114945b
...
...
@@ -219,3 +219,74 @@ dump_DPFLAGS(DWORD dwFlags)
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
"
);
}
dlls/ddraw/d3ddevice/main.c
View file @
0114945b
...
...
@@ -206,7 +206,42 @@ Main_IDirect3DDeviceImpl_7_3T_2T_SetTransform(LPDIRECT3DDEVICE7 iface,
LPD3DMATRIX
lpD3DMatrix
)
{
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
;
}
...
...
@@ -220,21 +255,27 @@ Main_IDirect3DDeviceImpl_7_3T_2T_GetTransform(LPDIRECT3DDEVICE7 iface,
switch
(
dtstTransformStateType
)
{
case
D3DTRANSFORMSTATE_WORLD
:
{
TRACE
(
" returning D3DTRANSFORMSTATE_WORLD :
\n
"
);
if
(
TRACE_ON
(
ddraw
))
{
TRACE
(
" returning D3DTRANSFORMSTATE_WORLD :
\n
"
);
dump_D3DMATRIX
(
lpD3DMatrix
);
}
memcpy
(
lpD3DMatrix
,
This
->
world_mat
,
16
*
sizeof
(
D3DVALUE
));
dump_mat
(
lpD3DMatrix
);
}
break
;
case
D3DTRANSFORMSTATE_VIEW
:
{
TRACE
(
" returning D3DTRANSFORMSTATE_VIEW :
\n
"
);
if
(
TRACE_ON
(
ddraw
))
{
TRACE
(
" returning D3DTRANSFORMSTATE_VIEW :
\n
"
);
dump_D3DMATRIX
(
lpD3DMatrix
);
}
memcpy
(
lpD3DMatrix
,
This
->
world_mat
,
16
*
sizeof
(
D3DVALUE
));
dump_mat
(
lpD3DMatrix
);
}
break
;
case
D3DTRANSFORMSTATE_PROJECTION
:
{
TRACE
(
" returning D3DTRANSFORMSTATE_PROJECTION :
\n
"
);
if
(
TRACE_ON
(
ddraw
))
{
TRACE
(
" returning D3DTRANSFORMSTATE_PROJECTION :
\n
"
);
dump_D3DMATRIX
(
lpD3DMatrix
);
}
memcpy
(
lpD3DMatrix
,
This
->
world_mat
,
16
*
sizeof
(
D3DVALUE
));
dump_mat
(
lpD3DMatrix
);
}
break
;
default:
...
...
@@ -1098,7 +1139,7 @@ Main_IDirect3DDeviceImpl_1_SetMatrix(LPDIRECT3DDEVICE iface,
ICOM_THIS_FROM
(
IDirect3DDeviceImpl
,
IDirect3DDevice
,
iface
);
TRACE
(
"(%p/%p)->(%08lx,%p)
\n
"
,
This
,
iface
,
(
DWORD
)
D3DMatHandle
,
lpD3DMatrix
);
dump_
mat
(
lpD3DMatrix
);
dump_
D3DMATRIX
(
lpD3DMatrix
);
*
((
D3DMATRIX
*
)
D3DMatHandle
)
=
*
lpD3DMatrix
;
return
DD_OK
;
...
...
dlls/ddraw/d3ddevice/mesa.c
View file @
0114945b
...
...
@@ -588,88 +588,6 @@ GL_IDirect3DDeviceImpl_3_2T_SetLightState(LPDIRECT3DDEVICE3 iface,
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
)
{
switch
(
d3dpt
)
{
...
...
@@ -716,22 +634,23 @@ static void draw_primitive_handle_GL_state(IDirect3DDeviceImpl *This,
/* Puts GL in the correct lighting / transformation mode */
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
vertices to non-transformed ones.
*/
glMatrixMode
(
GL_MODELVIEW
);
glLoadMatrixf
((
float
*
)
This
->
view_mat
);
glMultMatrixf
((
float
*
)
This
->
world_mat
);
glMatrixMode
(
GL_PROJECTION
);
glLoadMatrixf
((
float
*
)
This
->
proj_mat
);
This
->
set_matrices
(
This
,
VIEWMAT_CHANGED
|
WORLDMAT_CHANGED
|
PROJMAT_CHANGED
,
This
->
world_mat
,
This
->
view_mat
,
This
->
proj_mat
);
glThis
->
transform_state
=
GL_TRANSFORM_NORMAL
;
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
)
&&
(
glThis
->
last_vertices_transformed
==
FALSE
))
{
(
glThis
->
transform_state
!=
GL_TRANSFORM_ORTHO
))
{
GLfloat
height
,
width
;
GLfloat
trans_mat
[
16
];
glThis
->
transform_state
=
GL_TRANSFORM_ORTHO
;
width
=
glThis
->
parent
.
surface
->
surface_desc
.
dwWidth
;
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
;
}
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 */
inline
static
void
handle_xyz
(
D3DVALUE
*
coords
)
{
glVertex3fv
(
coords
);
...
...
@@ -1745,7 +1600,7 @@ ICOM_VTABLE(IDirect3DDevice7) VTABLE_IDirect3DDevice7 =
XCAST
(
SetRenderTarget
)
Main_IDirect3DDeviceImpl_7_3T_2T_SetRenderTarget
,
XCAST
(
GetRenderTarget
)
Main_IDirect3DDeviceImpl_7_3T_2T_GetRenderTarget
,
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
(
SetViewport
)
Main_IDirect3DDeviceImpl_7_SetViewport
,
XCAST
(
MultiplyTransform
)
Main_IDirect3DDeviceImpl_7_3T_2T_MultiplyTransform
,
...
...
@@ -2035,6 +1890,30 @@ d3ddevice_bltfast(IDirectDrawSurfaceImpl *This, DWORD dstx,
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 :
- 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
->
set_context
=
set_context
;
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
);
...
...
dlls/ddraw/d3dexecutebuffer.c
View file @
0114945b
...
...
@@ -244,9 +244,9 @@ static void execute(IDirect3DExecuteBufferImpl *This,
transformation phase */
glMatrixMode
(
GL_PROJECTION
);
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
);
dump_
mat
(
lpDevice
->
view_mat
);
dump_
D3DMATRIX
(
lpDevice
->
view_mat
);
/* 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
...
...
@@ -266,9 +266,9 @@ static void execute(IDirect3DExecuteBufferImpl *This,
glMatrixMode
(
GL_PROJECTION
);
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
);
dump_
mat
(
lpDevice
->
view_mat
);
dump_
D3DMATRIX
(
lpDevice
->
view_mat
);
/* 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
...
...
@@ -535,7 +535,7 @@ static void execute(IDirect3DExecuteBufferImpl *This,
D3DMATRIX
*
mat
=
lpDevice
->
world_mat
;
TRACE
(
" World Matrix : (%p)
\n
"
,
mat
);
dump_
mat
(
mat
);
dump_
D3DMATRIX
(
mat
);
This
->
vertex_type
=
D3DVT_VERTEX
;
...
...
@@ -564,7 +564,7 @@ static void execute(IDirect3DExecuteBufferImpl *This,
D3DMATRIX
*
mat
=
lpDevice
->
world_mat
;
TRACE
(
" World Matrix : (%p)
\n
"
,
mat
);
dump_
mat
(
mat
);
dump_
D3DMATRIX
(
mat
);
This
->
vertex_type
=
D3DVT_LVERTEX
;
...
...
dlls/ddraw/d3dlight.c
View file @
0114945b
...
...
@@ -120,23 +120,21 @@ static void update(IDirect3DLightImpl* This) {
ENTER_GL
();
switch
(
glThis
->
parent
.
light
.
dltType
)
{
case
D3DLIGHT_POINT
:
/* 1 */
TRACE
(
"Activating POINT
\n
"
);
FIXME
(
"Activating POINT - not supported yet
\n
"
);
break
;
case
D3DLIGHT_SPOT
:
/* 2 */
TRACE
(
"Activating SPOT
\n
"
);
FIXME
(
"Activating SPOT - not supported yet
\n
"
);
break
;
case
D3DLIGHT_DIRECTIONAL
:
{
/* 3 */
float
direction
[
4
];
TRACE
(
"Activating DIRECTIONAL
\n
"
);
TRACE
(
" direction : %f %f %f
\n
"
,
glThis
->
parent
.
light
.
dvDirection
.
u1
.
x
,
glThis
->
parent
.
light
.
dvDirection
.
u2
.
y
,
glThis
->
parent
.
light
.
dvDirection
.
u3
.
z
);
_dump_colorvalue
(
" color "
,
glThis
->
parent
.
light
.
dcvColor
);
if
(
TRACE_ON
(
ddraw
))
{
TRACE
(
"Activating DIRECTIONAL
\n
"
);
DPRINTF
(
" - direction : "
);
dump_D3DVECTOR
(
&
(
glThis
->
parent
.
light
.
dvDirection
));
DPRINTF
(
"
\n
"
);
DPRINTF
(
" - color : "
);
dump_D3DCOLORVALUE
(
&
(
glThis
->
parent
.
light
.
dcvColor
));
DPRINTF
(
"
\n
"
);
}
glLightfv
(
glThis
->
light_num
,
GL_AMBIENT
,
(
float
*
)
zero_value
);
glLightfv
(
glThis
->
light_num
,
GL_DIFFUSE
,
(
float
*
)
&
(
glThis
->
parent
.
light
.
dcvColor
));
...
...
@@ -149,7 +147,7 @@ static void update(IDirect3DLightImpl* This) {
}
break
;
case
D3DLIGHT_PARALLELPOINT
:
/* 4 */
TRACE
(
"Activating PARRALLEL-POINT
\n
"
);
FIXME
(
"Activating PARRALLEL-POINT - not supported yet
\n
"
);
break
;
default:
...
...
dlls/ddraw/d3dmaterial.c
View file @
0114945b
...
...
@@ -284,33 +284,33 @@ Thunk_IDirect3DMaterialImpl_1_GetMaterial(LPDIRECT3DMATERIAL iface,
* Matrial2 static functions
*/
static
void
activate
(
IDirect3DMaterialImpl
*
This
)
{
TRACE
(
"Activating material %p
\n
"
,
This
);
ENTER_GL
();
/* Set the current Material */
_dump_colorvalue
(
"Diffuse"
,
This
->
mat
.
u
.
diffuse
);
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_DIFFUSE
,
(
float
*
)
&
(
This
->
mat
.
u
.
diffuse
));
_dump_colorvalue
(
"Ambient"
,
This
->
mat
.
u1
.
ambient
);
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT
,
(
float
*
)
&
(
This
->
mat
.
u1
.
ambient
));
_dump_colorvalue
(
"Specular"
,
This
->
mat
.
u2
.
specular
);
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_SPECULAR
,
(
float
*
)
&
(
This
->
mat
.
u2
.
specular
)
);
_dump_colorvalue
(
"Emissive"
,
This
->
mat
.
u3
.
emissive
);
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_EMISSION
,
(
float
*
)
&
(
This
->
mat
.
u3
.
emissive
)
);
TRACE
(
"Size : %ld
\n
"
,
This
->
mat
.
dwSize
);
TRACE
(
"Power : %f
\n
"
,
This
->
mat
.
u4
.
power
);
TRACE
(
"T
exture handle : %08lx
\n
"
,
(
DWORD
)
This
->
mat
.
hTexture
);
LEAVE_GL
();
TRACE
(
"Activating material %p
\n
"
,
This
);
/* Set the current Material */
ENTER_GL
();
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_DIFFUSE
,
(
float
*
)
&
(
This
->
mat
.
u
.
diffuse
));
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT
,
(
float
*
)
&
(
This
->
mat
.
u1
.
ambient
)
);
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_SPECULAR
,
(
float
*
)
&
(
This
->
mat
.
u2
.
specular
));
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_EMISSION
,
(
float
*
)
&
(
This
->
mat
.
u3
.
emissive
));
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
(
" - t
exture handle : %08lx
\n
"
,
(
DWORD
)
This
->
mat
.
hTexture
);
}
return
;
}
...
...
dlls/ddraw/mesa_private.h
View file @
0114945b
...
...
@@ -114,6 +114,13 @@ typedef struct IDirect3DTextureGLImpl
void
(
*
set_palette
)(
IDirectDrawSurfaceImpl
*
This
,
IDirectDrawPaletteImpl
*
pal
);
}
IDirect3DTextureGLImpl
;
typedef
enum
{
GL_TRANSFORM_NONE
=
0
,
GL_TRANSFORM_ORTHO
,
GL_TRANSFORM_NORMAL
,
GL_TRANSFORM_VERTEXBUFFER
}
GL_TRANSFORM_STATE
;
typedef
struct
IDirect3DDeviceGLImpl
{
struct
IDirect3DDeviceImpl
parent
;
...
...
@@ -124,7 +131,7 @@ typedef struct IDirect3DDeviceGLImpl
RenderState
render_state
;
/* The last type of vertex drawn */
BOOLEAN
last_vertices_transformed
;
GL_TRANSFORM_STATE
transform_state
;
Display
*
display
;
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_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
that are used by Wine */
typedef
struct
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment