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
19199bc5
Commit
19199bc5
authored
Feb 23, 2012
by
Henri Verbeet
Committed by
Alexandre Julliard
Feb 24, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ddraw/tests: Add tests for z-clipping with D3DRENDERSTATE_ZENABLE disabled.
parent
d17f037f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
490 additions
and
0 deletions
+490
-0
ddraw1.c
dlls/ddraw/tests/ddraw1.c
+214
-0
ddraw2.c
dlls/ddraw/tests/ddraw2.c
+118
-0
ddraw4.c
dlls/ddraw/tests/ddraw4.c
+95
-0
ddraw7.c
dlls/ddraw/tests/ddraw7.c
+63
-0
No files found.
dlls/ddraw/tests/ddraw1.c
View file @
19199bc5
...
...
@@ -118,6 +118,74 @@ static D3DCOLOR get_surface_color(IDirectDrawSurface *surface, UINT x, UINT y)
return
color
;
}
static
void
emit_process_vertices
(
void
**
ptr
,
DWORD
vertex_count
)
{
D3DINSTRUCTION
*
inst
=
*
ptr
;
D3DPROCESSVERTICES
*
pv
=
(
D3DPROCESSVERTICES
*
)(
inst
+
1
);
inst
->
bOpcode
=
D3DOP_PROCESSVERTICES
;
inst
->
bSize
=
sizeof
(
*
pv
);
inst
->
wCount
=
1
;
pv
->
dwFlags
=
D3DPROCESSVERTICES_COPY
;
pv
->
wStart
=
0
;
pv
->
wDest
=
0
;
pv
->
dwCount
=
vertex_count
;
pv
->
dwReserved
=
0
;
*
ptr
=
pv
+
1
;
}
static
void
emit_set_rs
(
void
**
ptr
,
D3DRENDERSTATETYPE
state
,
DWORD
value
)
{
D3DINSTRUCTION
*
inst
=
*
ptr
;
D3DSTATE
*
rs
=
(
D3DSTATE
*
)(
inst
+
1
);
inst
->
bOpcode
=
D3DOP_STATERENDER
;
inst
->
bSize
=
sizeof
(
*
rs
);
inst
->
wCount
=
1
;
U1
(
*
rs
).
drstRenderStateType
=
state
;
U2
(
*
rs
).
dwArg
[
0
]
=
value
;
*
ptr
=
rs
+
1
;
}
static
void
emit_tquad
(
void
**
ptr
,
WORD
base_idx
)
{
D3DINSTRUCTION
*
inst
=
*
ptr
;
D3DTRIANGLE
*
tri
=
(
D3DTRIANGLE
*
)(
inst
+
1
);
inst
->
bOpcode
=
D3DOP_TRIANGLE
;
inst
->
bSize
=
sizeof
(
*
tri
);
inst
->
wCount
=
2
;
tri
->
v1
=
base_idx
;
tri
->
v2
=
base_idx
+
1
;
tri
->
v3
=
base_idx
+
2
;
tri
->
wFlags
=
D3DTRIFLAG_START
;
++
tri
;
tri
->
v1
=
base_idx
+
2
;
tri
->
v2
=
base_idx
+
1
;
tri
->
v3
=
base_idx
+
3
;
tri
->
wFlags
=
D3DTRIFLAG_ODD
;
++
tri
;
*
ptr
=
tri
;
}
static
void
emit_end
(
void
**
ptr
)
{
D3DINSTRUCTION
*
inst
=
*
ptr
;
inst
->
bOpcode
=
D3DOP_EXIT
;
inst
->
bSize
=
0
;
inst
->
wCount
=
0
;
*
ptr
=
inst
+
1
;
}
static
HRESULT
CALLBACK
enum_z_fmt
(
GUID
*
guid
,
char
*
description
,
char
*
name
,
D3DDEVICEDESC
*
hal_desc
,
D3DDEVICEDESC
*
hel_desc
,
void
*
ctx
)
{
...
...
@@ -906,6 +974,151 @@ static void test_viewport_interfaces(void)
IDirectDraw_Release
(
ddraw
);
}
static
void
test_zenable
(
void
)
{
static
D3DRECT
clear_rect
=
{{
0
},
{
0
},
{
640
},
{
480
}};
static
D3DTLVERTEX
tquad
[]
=
{
{{
0
.
0
f
},
{
480
.
0
f
},
{
-
0
.
5
f
},
{
1
.
0
f
},
{
0xff00ff00
},
{
0x00000000
},
{
0
.
0
f
},
{
0
.
0
f
}},
{{
0
.
0
f
},
{
0
.
0
f
},
{
-
0
.
5
f
},
{
1
.
0
f
},
{
0xff00ff00
},
{
0x00000000
},
{
0
.
0
f
},
{
0
.
0
f
}},
{{
640
.
0
f
},
{
480
.
0
f
},
{
1
.
5
f
},
{
1
.
0
f
},
{
0xff00ff00
},
{
0x00000000
},
{
0
.
0
f
},
{
0
.
0
f
}},
{{
640
.
0
f
},
{
0
.
0
f
},
{
1
.
5
f
},
{
1
.
0
f
},
{
0xff00ff00
},
{
0x00000000
},
{
0
.
0
f
},
{
0
.
0
f
}},
};
IDirect3DExecuteBuffer
*
execute_buffer
;
D3DMATERIALHANDLE
background_handle
;
D3DEXECUTEBUFFERDESC
exec_desc
;
IDirect3DMaterial
*
background
;
IDirect3DViewport
*
viewport
;
D3DEXECUTEDATA
exec_data
;
IDirect3DDevice
*
device
;
IDirectDrawSurface
*
rt
;
D3DMATERIAL
material
;
IDirectDraw
*
ddraw
;
UINT
inst_length
;
D3DVIEWPORT
vp
;
IDirect3D
*
d3d
;
D3DCOLOR
color
;
HWND
window
;
HRESULT
hr
;
UINT
x
,
y
;
UINT
i
,
j
;
void
*
ptr
;
window
=
CreateWindowA
(
"static"
,
"ddraw_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
480
,
0
,
0
,
0
,
0
);
if
(
!
(
ddraw
=
create_ddraw
()))
{
skip
(
"Failed to create ddraw object, skipping test.
\n
"
);
DestroyWindow
(
window
);
return
;
}
if
(
!
(
device
=
create_device
(
ddraw
,
window
,
DDSCL_NORMAL
)))
{
skip
(
"Failed to create D3D device, skipping test.
\n
"
);
IDirectDraw_Release
(
ddraw
);
DestroyWindow
(
window
);
return
;
}
hr
=
IDirect3DDevice_GetDirect3D
(
device
,
&
d3d
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get d3d interface, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3D_CreateMaterial
(
d3d
,
&
background
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create material, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3D_CreateViewport
(
d3d
,
&
viewport
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create viewport, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice_AddViewport
(
device
,
viewport
);
ok
(
SUCCEEDED
(
hr
),
"Failed to add viewport, hr %#x.
\n
"
,
hr
);
memset
(
&
vp
,
0
,
sizeof
(
vp
));
vp
.
dwSize
=
sizeof
(
vp
);
vp
.
dwX
=
0
;
vp
.
dwY
=
0
;
vp
.
dwWidth
=
640
;
vp
.
dwHeight
=
480
;
vp
.
dvScaleX
=
320
.
0
f
;
vp
.
dvScaleY
=
240
.
0
f
;
vp
.
dvMaxX
=
1
.
0
f
;
vp
.
dvMaxY
=
1
.
0
f
;
vp
.
dvMinZ
=
0
.
0
f
;
vp
.
dvMaxZ
=
1
.
0
f
;
hr
=
IDirect3DViewport_SetViewport
(
viewport
,
&
vp
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set viewport data, hr %#x.
\n
"
,
hr
);
memset
(
&
material
,
0
,
sizeof
(
material
));
material
.
dwSize
=
sizeof
(
material
);
U1
(
U
(
material
).
diffuse
).
r
=
1
.
0
f
;
U2
(
U
(
material
).
diffuse
).
g
=
0
.
0
f
;
U3
(
U
(
material
).
diffuse
).
b
=
0
.
0
f
;
U4
(
U
(
material
).
diffuse
).
a
=
1
.
0
f
;
hr
=
IDirect3DMaterial_SetMaterial
(
background
,
&
material
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set material data, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DMaterial_GetHandle
(
background
,
device
,
&
background_handle
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get material handle, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DViewport_SetBackground
(
viewport
,
background_handle
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set viewport background, hr %#x.
\n
"
,
hr
);
memset
(
&
exec_desc
,
0
,
sizeof
(
exec_desc
));
exec_desc
.
dwSize
=
sizeof
(
exec_desc
);
exec_desc
.
dwFlags
=
D3DDEB_BUFSIZE
|
D3DDEB_CAPS
;
exec_desc
.
dwBufferSize
=
1024
;
exec_desc
.
dwCaps
=
D3DDEBCAPS_SYSTEMMEMORY
;
hr
=
IDirect3DDevice_CreateExecuteBuffer
(
device
,
&
exec_desc
,
&
execute_buffer
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create execute buffer, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DExecuteBuffer_Lock
(
execute_buffer
,
&
exec_desc
);
ok
(
SUCCEEDED
(
hr
),
"Failed to lock execute buffer, hr %#x.
\n
"
,
hr
);
memcpy
(
exec_desc
.
lpData
,
tquad
,
sizeof
(
tquad
));
ptr
=
((
BYTE
*
)
exec_desc
.
lpData
)
+
sizeof
(
tquad
);
emit_process_vertices
(
&
ptr
,
4
);
emit_set_rs
(
&
ptr
,
D3DRENDERSTATE_ZENABLE
,
D3DZB_FALSE
);
emit_tquad
(
&
ptr
,
0
);
emit_end
(
&
ptr
);
inst_length
=
(
BYTE
*
)
ptr
-
(
BYTE
*
)
exec_desc
.
lpData
;
inst_length
-=
sizeof
(
tquad
);
hr
=
IDirect3DExecuteBuffer_Unlock
(
execute_buffer
);
ok
(
SUCCEEDED
(
hr
),
"Failed to unlock execute buffer, hr %#x.
\n
"
,
hr
);
memset
(
&
exec_data
,
0
,
sizeof
(
exec_data
));
exec_data
.
dwSize
=
sizeof
(
exec_data
);
exec_data
.
dwVertexCount
=
4
;
exec_data
.
dwInstructionOffset
=
sizeof
(
tquad
);
exec_data
.
dwInstructionLength
=
inst_length
;
hr
=
IDirect3DExecuteBuffer_SetExecuteData
(
execute_buffer
,
&
exec_data
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set execute data, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DViewport_Clear
(
viewport
,
1
,
&
clear_rect
,
D3DCLEAR_TARGET
);
ok
(
SUCCEEDED
(
hr
),
"Failed to clear viewport, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice_BeginScene
(
device
);
ok
(
SUCCEEDED
(
hr
),
"Failed to begin scene, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice_Execute
(
device
,
execute_buffer
,
viewport
,
D3DEXECUTE_CLIPPED
);
ok
(
SUCCEEDED
(
hr
),
"Failed to execute exec buffer, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice_EndScene
(
device
);
ok
(
SUCCEEDED
(
hr
),
"Failed to end scene, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice_QueryInterface
(
device
,
&
IID_IDirectDrawSurface
,
(
void
**
)
&
rt
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get render target, hr %#x.
\n
"
,
hr
);
for
(
i
=
0
;
i
<
4
;
++
i
)
{
for
(
j
=
0
;
j
<
4
;
++
j
)
{
x
=
80
*
((
2
*
j
)
+
1
);
y
=
60
*
((
2
*
i
)
+
1
);
color
=
get_surface_color
(
rt
,
x
,
y
);
ok
(
compare_color
(
color
,
0x0000ff00
,
1
),
"Expected color 0x0000ff00 at %u, %u, got 0x%08x.
\n
"
,
x
,
y
,
color
);
}
}
IDirectDrawSurface_Release
(
rt
);
IDirect3DExecuteBuffer_Release
(
execute_buffer
);
IDirect3DMaterial_Release
(
background
);
IDirect3DViewport_Release
(
viewport
);
IDirect3D_Release
(
d3d
);
IDirect3DDevice_Release
(
device
);
IDirectDraw_Release
(
ddraw
);
DestroyWindow
(
window
);
}
START_TEST
(
ddraw1
)
{
test_coop_level_create_device_window
();
...
...
@@ -914,4 +1127,5 @@ START_TEST(ddraw1)
test_surface_interface_mismatch
();
test_coop_level_threaded
();
test_viewport_interfaces
();
test_zenable
();
}
dlls/ddraw/tests/ddraw2.c
View file @
19199bc5
...
...
@@ -1266,6 +1266,123 @@ static void test_viewport_interfaces(void)
IDirectDraw2_Release
(
ddraw
);
}
static
void
test_zenable
(
void
)
{
static
D3DRECT
clear_rect
=
{{
0
},
{
0
},
{
640
},
{
480
}};
static
D3DTLVERTEX
tquad
[]
=
{
{{
0
.
0
f
},
{
480
.
0
f
},
{
-
0
.
5
f
},
{
1
.
0
f
},
{
0xff00ff00
},
{
0x00000000
},
{
0
.
0
f
},
{
0
.
0
f
}},
{{
0
.
0
f
},
{
0
.
0
f
},
{
-
0
.
5
f
},
{
1
.
0
f
},
{
0xff00ff00
},
{
0x00000000
},
{
0
.
0
f
},
{
0
.
0
f
}},
{{
640
.
0
f
},
{
480
.
0
f
},
{
1
.
5
f
},
{
1
.
0
f
},
{
0xff00ff00
},
{
0x00000000
},
{
0
.
0
f
},
{
0
.
0
f
}},
{{
640
.
0
f
},
{
0
.
0
f
},
{
1
.
5
f
},
{
1
.
0
f
},
{
0xff00ff00
},
{
0x00000000
},
{
0
.
0
f
},
{
0
.
0
f
}},
};
D3DMATERIALHANDLE
background_handle
;
IDirect3DMaterial2
*
background
;
IDirect3DViewport2
*
viewport
;
IDirect3DDevice2
*
device
;
IDirectDrawSurface
*
rt
;
D3DMATERIAL
material
;
IDirectDraw2
*
ddraw
;
D3DVIEWPORT2
vp
;
IDirect3D2
*
d3d
;
D3DCOLOR
color
;
HWND
window
;
HRESULT
hr
;
UINT
x
,
y
;
UINT
i
,
j
;
window
=
CreateWindowA
(
"static"
,
"ddraw_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
480
,
0
,
0
,
0
,
0
);
if
(
!
(
ddraw
=
create_ddraw
()))
{
skip
(
"Failed to create ddraw object, skipping test.
\n
"
);
DestroyWindow
(
window
);
return
;
}
if
(
!
(
device
=
create_device
(
ddraw
,
window
,
DDSCL_NORMAL
)))
{
skip
(
"Failed to create D3D device, skipping test.
\n
"
);
IDirectDraw2_Release
(
ddraw
);
DestroyWindow
(
window
);
return
;
}
hr
=
IDirect3DDevice2_GetDirect3D
(
device
,
&
d3d
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get d3d interface, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3D2_CreateMaterial
(
d3d
,
&
background
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create material, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3D2_CreateViewport
(
d3d
,
&
viewport
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create viewport, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice2_AddViewport
(
device
,
viewport
);
ok
(
SUCCEEDED
(
hr
),
"Failed to add viewport, hr %#x.
\n
"
,
hr
);
memset
(
&
vp
,
0
,
sizeof
(
vp
));
vp
.
dwSize
=
sizeof
(
vp
);
vp
.
dwX
=
0
;
vp
.
dwY
=
0
;
vp
.
dwWidth
=
640
;
vp
.
dwHeight
=
480
;
vp
.
dvClipX
=
-
1
.
0
f
;
vp
.
dvClipY
=
1
.
0
f
;
vp
.
dvClipWidth
=
2
.
0
f
;
vp
.
dvClipHeight
=
2
.
0
f
;
vp
.
dvMinZ
=
0
.
0
f
;
vp
.
dvMaxZ
=
1
.
0
f
;
hr
=
IDirect3DViewport2_SetViewport2
(
viewport
,
&
vp
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set viewport data, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice2_SetCurrentViewport
(
device
,
viewport
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set current viewport, hr %#x.
\n
"
,
hr
);
memset
(
&
material
,
0
,
sizeof
(
material
));
material
.
dwSize
=
sizeof
(
material
);
U1
(
U
(
material
).
diffuse
).
r
=
1
.
0
f
;
U2
(
U
(
material
).
diffuse
).
g
=
0
.
0
f
;
U3
(
U
(
material
).
diffuse
).
b
=
0
.
0
f
;
U4
(
U
(
material
).
diffuse
).
a
=
1
.
0
f
;
hr
=
IDirect3DMaterial2_SetMaterial
(
background
,
&
material
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set material data, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DMaterial2_GetHandle
(
background
,
device
,
&
background_handle
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get material handle, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DViewport2_SetBackground
(
viewport
,
background_handle
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set viewport background, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice2_SetRenderState
(
device
,
D3DRENDERSTATE_ZENABLE
,
D3DZB_FALSE
);
ok
(
SUCCEEDED
(
hr
),
"Failed to disable z-buffering, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DViewport2_Clear
(
viewport
,
1
,
&
clear_rect
,
D3DCLEAR_TARGET
);
ok
(
SUCCEEDED
(
hr
),
"Failed to clear viewport, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice2_BeginScene
(
device
);
ok
(
SUCCEEDED
(
hr
),
"Failed to begin scene, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice2_DrawPrimitive
(
device
,
D3DPT_TRIANGLESTRIP
,
D3DVT_TLVERTEX
,
tquad
,
4
,
0
);
ok
(
SUCCEEDED
(
hr
),
"Failed to draw, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice2_EndScene
(
device
);
ok
(
SUCCEEDED
(
hr
),
"Failed to end scene, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice2_GetRenderTarget
(
device
,
&
rt
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get render target, hr %#x.
\n
"
,
hr
);
for
(
i
=
0
;
i
<
4
;
++
i
)
{
for
(
j
=
0
;
j
<
4
;
++
j
)
{
x
=
80
*
((
2
*
j
)
+
1
);
y
=
60
*
((
2
*
i
)
+
1
);
color
=
get_surface_color
(
rt
,
x
,
y
);
ok
(
compare_color
(
color
,
0x0000ff00
,
1
),
"Expected color 0x0000ff00 at %u, %u, got 0x%08x.
\n
"
,
x
,
y
,
color
);
}
}
IDirectDrawSurface_Release
(
rt
);
IDirect3DMaterial2_Release
(
background
);
hr
=
IDirect3DDevice2_DeleteViewport
(
device
,
viewport
);
ok
(
SUCCEEDED
(
hr
),
"Failed to delete viewport, hr %#x.
\n
"
,
hr
);
IDirect3DViewport2_Release
(
viewport
);
IDirect3D2_Release
(
d3d
);
IDirect3DDevice2_Release
(
device
);
IDirectDraw2_Release
(
ddraw
);
DestroyWindow
(
window
);
}
START_TEST
(
ddraw2
)
{
test_coop_level_create_device_window
();
...
...
@@ -1276,4 +1393,5 @@ START_TEST(ddraw2)
test_depth_blit
();
test_texture_load_ckey
();
test_viewport_interfaces
();
test_zenable
();
}
dlls/ddraw/tests/ddraw4.c
View file @
19199bc5
...
...
@@ -1396,6 +1396,100 @@ static void test_viewport_interfaces(void)
IDirectDraw4_Release
(
ddraw
);
}
static
void
test_zenable
(
void
)
{
static
D3DRECT
clear_rect
=
{{
0
},
{
0
},
{
640
},
{
480
}};
static
struct
{
struct
vec4
position
;
D3DCOLOR
diffuse
;
}
tquad
[]
=
{
{{
0
.
0
f
,
480
.
0
f
,
-
0
.
5
f
,
1
.
0
f
},
0xff00ff00
},
{{
0
.
0
f
,
0
.
0
f
,
-
0
.
5
f
,
1
.
0
f
},
0xff00ff00
},
{{
640
.
0
f
,
480
.
0
f
,
1
.
5
f
,
1
.
0
f
},
0xff00ff00
},
{{
640
.
0
f
,
0
.
0
f
,
1
.
5
f
,
1
.
0
f
},
0xff00ff00
},
};
IDirect3DViewport3
*
viewport
;
IDirect3DDevice3
*
device
;
IDirectDrawSurface4
*
rt
;
D3DVIEWPORT2
vp
;
IDirect3D3
*
d3d
;
D3DCOLOR
color
;
HWND
window
;
HRESULT
hr
;
UINT
x
,
y
;
UINT
i
,
j
;
window
=
CreateWindowA
(
"static"
,
"ddraw_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
480
,
0
,
0
,
0
,
0
);
if
(
!
(
device
=
create_device
(
window
,
DDSCL_NORMAL
)))
{
skip
(
"Failed to create D3D device, skipping test.
\n
"
);
DestroyWindow
(
window
);
return
;
}
hr
=
IDirect3DDevice3_GetDirect3D
(
device
,
&
d3d
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get d3d interface, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3D3_CreateViewport
(
d3d
,
&
viewport
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create viewport, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice3_AddViewport
(
device
,
viewport
);
ok
(
SUCCEEDED
(
hr
),
"Failed to add viewport, hr %#x.
\n
"
,
hr
);
memset
(
&
vp
,
0
,
sizeof
(
vp
));
vp
.
dwSize
=
sizeof
(
vp
);
vp
.
dwX
=
0
;
vp
.
dwY
=
0
;
vp
.
dwWidth
=
640
;
vp
.
dwHeight
=
480
;
vp
.
dvClipX
=
-
1
.
0
f
;
vp
.
dvClipY
=
1
.
0
f
;
vp
.
dvClipWidth
=
2
.
0
f
;
vp
.
dvClipHeight
=
2
.
0
f
;
vp
.
dvMinZ
=
0
.
0
f
;
vp
.
dvMaxZ
=
1
.
0
f
;
hr
=
IDirect3DViewport3_SetViewport2
(
viewport
,
&
vp
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set viewport data, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice3_SetCurrentViewport
(
device
,
viewport
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set current viewport, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice3_SetRenderState
(
device
,
D3DRENDERSTATE_ZENABLE
,
D3DZB_FALSE
);
ok
(
SUCCEEDED
(
hr
),
"Failed to disable z-buffering, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DViewport3_Clear2
(
viewport
,
1
,
&
clear_rect
,
D3DCLEAR_TARGET
|
D3DCLEAR_ZBUFFER
,
0xffff0000
,
0
.
0
f
,
0
);
ok
(
SUCCEEDED
(
hr
),
"Failed to clear viewport, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice3_BeginScene
(
device
);
ok
(
SUCCEEDED
(
hr
),
"Failed to begin scene, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice3_DrawPrimitive
(
device
,
D3DPT_TRIANGLESTRIP
,
D3DFVF_XYZRHW
|
D3DFVF_DIFFUSE
,
tquad
,
4
,
0
);
ok
(
SUCCEEDED
(
hr
),
"Failed to draw, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice3_EndScene
(
device
);
ok
(
SUCCEEDED
(
hr
),
"Failed to end scene, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice3_GetRenderTarget
(
device
,
&
rt
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get render target, hr %#x.
\n
"
,
hr
);
for
(
i
=
0
;
i
<
4
;
++
i
)
{
for
(
j
=
0
;
j
<
4
;
++
j
)
{
x
=
80
*
((
2
*
j
)
+
1
);
y
=
60
*
((
2
*
i
)
+
1
);
color
=
get_surface_color
(
rt
,
x
,
y
);
ok
(
compare_color
(
color
,
0x0000ff00
,
1
),
"Expected color 0x0000ff00 at %u, %u, got 0x%08x.
\n
"
,
x
,
y
,
color
);
}
}
IDirectDrawSurface4_Release
(
rt
);
hr
=
IDirect3DDevice3_DeleteViewport
(
device
,
viewport
);
ok
(
SUCCEEDED
(
hr
),
"Failed to delete viewport, hr %#x.
\n
"
,
hr
);
IDirect3DViewport3_Release
(
viewport
);
IDirect3D3_Release
(
d3d
);
IDirect3DDevice3_Release
(
device
);
DestroyWindow
(
window
);
}
START_TEST
(
ddraw4
)
{
test_process_vertices
();
...
...
@@ -1407,4 +1501,5 @@ START_TEST(ddraw4)
test_depth_blit
();
test_texture_load_ckey
();
test_viewport_interfaces
();
test_zenable
();
}
dlls/ddraw/tests/ddraw7.c
View file @
19199bc5
...
...
@@ -1215,6 +1215,68 @@ static void test_texture_load_ckey(void)
IDirect3DDevice7_Release
(
device
);
}
static
void
test_zenable
(
void
)
{
static
struct
{
struct
vec4
position
;
D3DCOLOR
diffuse
;
}
tquad
[]
=
{
{{
0
.
0
f
,
480
.
0
f
,
-
0
.
5
f
,
1
.
0
f
},
0xff00ff00
},
{{
0
.
0
f
,
0
.
0
f
,
-
0
.
5
f
,
1
.
0
f
},
0xff00ff00
},
{{
640
.
0
f
,
480
.
0
f
,
1
.
5
f
,
1
.
0
f
},
0xff00ff00
},
{{
640
.
0
f
,
0
.
0
f
,
1
.
5
f
,
1
.
0
f
},
0xff00ff00
},
};
IDirect3DDevice7
*
device
;
IDirectDrawSurface7
*
rt
;
D3DCOLOR
color
;
HWND
window
;
HRESULT
hr
;
UINT
x
,
y
;
UINT
i
,
j
;
window
=
CreateWindowA
(
"static"
,
"ddraw_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
480
,
0
,
0
,
0
,
0
);
if
(
!
(
device
=
create_device
(
window
,
DDSCL_NORMAL
)))
{
skip
(
"Failed to create D3D device, skipping test.
\n
"
);
DestroyWindow
(
window
);
return
;
}
hr
=
IDirect3DDevice7_SetRenderState
(
device
,
D3DRENDERSTATE_ZENABLE
,
D3DZB_FALSE
);
ok
(
SUCCEEDED
(
hr
),
"Failed to disable z-buffering, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice7_Clear
(
device
,
0
,
NULL
,
D3DCLEAR_TARGET
|
D3DCLEAR_ZBUFFER
,
0xffff0000
,
0
.
0
f
,
0
);
ok
(
SUCCEEDED
(
hr
),
"Failed to clear render target, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice7_BeginScene
(
device
);
ok
(
SUCCEEDED
(
hr
),
"Failed to begin scene, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice7_DrawPrimitive
(
device
,
D3DPT_TRIANGLESTRIP
,
D3DFVF_XYZRHW
|
D3DFVF_DIFFUSE
,
tquad
,
4
,
0
);
ok
(
SUCCEEDED
(
hr
),
"Failed to draw, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice7_EndScene
(
device
);
ok
(
SUCCEEDED
(
hr
),
"Failed to end scene, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice7_GetRenderTarget
(
device
,
&
rt
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get render target, hr %#x.
\n
"
,
hr
);
for
(
i
=
0
;
i
<
4
;
++
i
)
{
for
(
j
=
0
;
j
<
4
;
++
j
)
{
x
=
80
*
((
2
*
j
)
+
1
);
y
=
60
*
((
2
*
i
)
+
1
);
color
=
get_surface_color
(
rt
,
x
,
y
);
ok
(
compare_color
(
color
,
0x0000ff00
,
1
),
"Expected color 0x0000ff00 at %u, %u, got 0x%08x.
\n
"
,
x
,
y
,
color
);
}
}
IDirectDrawSurface7_Release
(
rt
);
IDirect3DDevice7_Release
(
device
);
DestroyWindow
(
window
);
}
START_TEST
(
ddraw7
)
{
HMODULE
module
=
GetModuleHandleA
(
"ddraw.dll"
);
...
...
@@ -1233,4 +1295,5 @@ START_TEST(ddraw7)
test_coop_level_threaded
();
test_depth_blit
();
test_texture_load_ckey
();
test_zenable
();
}
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