Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
758de49d
Commit
758de49d
authored
Apr 07, 2011
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
No functionnal changes (direct3d)
Moved vertices setup and surface rendering into 2 functions.
parent
b8ac593c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
79 deletions
+105
-79
modules/video_output/msw/direct3d.c
modules/video_output/msw/direct3d.c
+105
-79
No files found.
modules/video_output/msw/direct3d.c
View file @
758de49d
...
@@ -1032,6 +1032,104 @@ static void Direct3DDestroyScene(vout_display_t *vd)
...
@@ -1032,6 +1032,104 @@ static void Direct3DDestroyScene(vout_display_t *vd)
msg_Dbg
(
vd
,
"Direct3D scene released successfully"
);
msg_Dbg
(
vd
,
"Direct3D scene released successfully"
);
}
}
static
int
Direct3DSetupVertices
(
vout_display_t
*
vd
,
LPDIRECT3DVERTEXBUFFER9
d3dvtc
,
float
f_x
,
float
f_y
,
float
f_width
,
float
f_height
)
{
HRESULT
hr
;
CUSTOMVERTEX
*
vertices
;
hr
=
IDirect3DVertexBuffer9_Lock
(
d3dvtc
,
0
,
0
,
(
void
**
)
&
vertices
,
D3DLOCK_DISCARD
);
if
(
FAILED
(
hr
))
{
msg_Dbg
(
vd
,
"%s:%d (hr=0x%0lX)"
,
__FUNCTION__
,
__LINE__
,
hr
);
return
-
1
;
}
/* -0.5f is a "feature" of DirectX and it seems to apply to Direct3d also */
/* http://www.sjbrown.co.uk/2003/05/01/fix-directx-rasterisation/ */
vertices
[
0
].
x
=
f_x
-
0
.
5
f
;
// left
vertices
[
0
].
y
=
f_y
-
0
.
5
f
;
// top
vertices
[
0
].
z
=
0
.
0
f
;
vertices
[
0
].
diffuse
=
D3DCOLOR_ARGB
(
255
,
255
,
255
,
255
);
vertices
[
0
].
rhw
=
1
.
0
f
;
vertices
[
0
].
tu
=
0
.
0
f
;
vertices
[
0
].
tv
=
0
.
0
f
;
vertices
[
1
].
x
=
f_x
+
f_width
-
0
.
5
f
;
// right
vertices
[
1
].
y
=
f_y
-
0
.
5
f
;
// top
vertices
[
1
].
z
=
0
.
0
f
;
vertices
[
1
].
diffuse
=
D3DCOLOR_ARGB
(
255
,
255
,
255
,
255
);
vertices
[
1
].
rhw
=
1
.
0
f
;
vertices
[
1
].
tu
=
1
.
0
f
;
vertices
[
1
].
tv
=
0
.
0
f
;
vertices
[
2
].
x
=
f_x
+
f_width
-
0
.
5
f
;
// right
vertices
[
2
].
y
=
f_y
+
f_height
-
0
.
5
f
;
// bottom
vertices
[
2
].
z
=
0
.
0
f
;
vertices
[
2
].
diffuse
=
D3DCOLOR_ARGB
(
255
,
255
,
255
,
255
);
vertices
[
2
].
rhw
=
1
.
0
f
;
vertices
[
2
].
tu
=
1
.
0
f
;
vertices
[
2
].
tv
=
1
.
0
f
;
vertices
[
3
].
x
=
f_x
-
0
.
5
f
;
// left
vertices
[
3
].
y
=
f_y
+
f_height
-
0
.
5
f
;
// bottom
vertices
[
3
].
z
=
0
.
0
f
;
vertices
[
3
].
diffuse
=
D3DCOLOR_ARGB
(
255
,
255
,
255
,
255
);
vertices
[
3
].
rhw
=
1
.
0
f
;
vertices
[
3
].
tu
=
0
.
0
f
;
vertices
[
3
].
tv
=
1
.
0
f
;
hr
=
IDirect3DVertexBuffer9_Unlock
(
d3dvtc
);
if
(
FAILED
(
hr
))
{
msg_Dbg
(
vd
,
"%s:%d (hr=0x%0lX)"
,
__FUNCTION__
,
__LINE__
,
hr
);
return
-
1
;
}
return
0
;
}
static
int
Direct3DRenderTexture
(
vout_display_t
*
vd
,
LPDIRECT3DVERTEXBUFFER9
d3dvtc
,
LPDIRECT3DTEXTURE9
d3dtex
)
{
HRESULT
hr
;
LPDIRECT3DDEVICE9
d3ddev
=
vd
->
sys
->
d3ddev
;
// Setup our texture. Using textures introduces the texture stage states,
// which govern how textures get blended together (in the case of multiple
// textures) and lighting information. In this case, we are modulating
// (blending) our texture with the diffuse color of the vertices.
hr
=
IDirect3DDevice9_SetTexture
(
d3ddev
,
0
,
(
LPDIRECT3DBASETEXTURE9
)
d3dtex
);
if
(
FAILED
(
hr
))
{
msg_Dbg
(
vd
,
"%s:%d (hr=0x%0lX)"
,
__FUNCTION__
,
__LINE__
,
hr
);
return
-
1
;
}
// Render the vertex buffer contents
hr
=
IDirect3DDevice9_SetStreamSource
(
d3ddev
,
0
,
d3dvtc
,
0
,
sizeof
(
CUSTOMVERTEX
));
if
(
FAILED
(
hr
))
{
msg_Dbg
(
vd
,
"%s:%d (hr=0x%0lX)"
,
__FUNCTION__
,
__LINE__
,
hr
);
return
-
1
;
}
// we use FVF instead of vertex shader
hr
=
IDirect3DDevice9_SetFVF
(
d3ddev
,
D3DFVF_CUSTOMVERTEX
);
if
(
FAILED
(
hr
))
{
msg_Dbg
(
vd
,
"%s:%d (hr=0x%0lX)"
,
__FUNCTION__
,
__LINE__
,
hr
);
return
-
1
;
}
// draw rectangle
hr
=
IDirect3DDevice9_DrawPrimitive
(
d3ddev
,
D3DPT_TRIANGLEFAN
,
0
,
2
);
if
(
FAILED
(
hr
))
{
msg_Dbg
(
vd
,
"%s:%d (hr=0x%0lX)"
,
__FUNCTION__
,
__LINE__
,
hr
);
return
-
1
;
}
return
0
;
}
/**
/**
* It copies picture surface into a texture and renders into a scene.
* It copies picture surface into a texture and renders into a scene.
*
*
...
@@ -1091,58 +1189,6 @@ static void Direct3DRenderScene(vout_display_t *vd, LPDIRECT3DSURFACE9 surface)
...
@@ -1091,58 +1189,6 @@ static void Direct3DRenderScene(vout_display_t *vd, LPDIRECT3DSURFACE9 surface)
return
;
return
;
}
}
/* Update the vertex buffer */
CUSTOMVERTEX
*
vertices
;
hr
=
IDirect3DVertexBuffer9_Lock
(
d3dvtc
,
0
,
0
,
(
void
**
)
&
vertices
,
D3DLOCK_DISCARD
);
if
(
FAILED
(
hr
))
{
msg_Dbg
(
vd
,
"%s:%d (hr=0x%0lX)"
,
__FUNCTION__
,
__LINE__
,
hr
);
return
;
}
/* Setup vertices */
const
float
f_width
=
vd
->
sys
->
d3dpp
.
BackBufferWidth
;
const
float
f_height
=
vd
->
sys
->
d3dpp
.
BackBufferHeight
;
/* -0.5f is a "feature" of DirectX and it seems to apply to Direct3d also */
/* http://www.sjbrown.co.uk/2003/05/01/fix-directx-rasterisation/ */
vertices
[
0
].
x
=
-
0
.
5
f
;
// left
vertices
[
0
].
y
=
-
0
.
5
f
;
// top
vertices
[
0
].
z
=
0
.
0
f
;
vertices
[
0
].
diffuse
=
D3DCOLOR_ARGB
(
255
,
255
,
255
,
255
);
vertices
[
0
].
rhw
=
1
.
0
f
;
vertices
[
0
].
tu
=
0
.
0
f
;
vertices
[
0
].
tv
=
0
.
0
f
;
vertices
[
1
].
x
=
f_width
-
0
.
5
f
;
// right
vertices
[
1
].
y
=
-
0
.
5
f
;
// top
vertices
[
1
].
z
=
0
.
0
f
;
vertices
[
1
].
diffuse
=
D3DCOLOR_ARGB
(
255
,
255
,
255
,
255
);
vertices
[
1
].
rhw
=
1
.
0
f
;
vertices
[
1
].
tu
=
1
.
0
f
;
vertices
[
1
].
tv
=
0
.
0
f
;
vertices
[
2
].
x
=
f_width
-
0
.
5
f
;
// right
vertices
[
2
].
y
=
f_height
-
0
.
5
f
;
// bottom
vertices
[
2
].
z
=
0
.
0
f
;
vertices
[
2
].
diffuse
=
D3DCOLOR_ARGB
(
255
,
255
,
255
,
255
);
vertices
[
2
].
rhw
=
1
.
0
f
;
vertices
[
2
].
tu
=
1
.
0
f
;
vertices
[
2
].
tv
=
1
.
0
f
;
vertices
[
3
].
x
=
-
0
.
5
f
;
// left
vertices
[
3
].
y
=
f_height
-
0
.
5
f
;
// bottom
vertices
[
3
].
z
=
0
.
0
f
;
vertices
[
3
].
diffuse
=
D3DCOLOR_ARGB
(
255
,
255
,
255
,
255
);
vertices
[
3
].
rhw
=
1
.
0
f
;
vertices
[
3
].
tu
=
0
.
0
f
;
vertices
[
3
].
tv
=
1
.
0
f
;
hr
=
IDirect3DVertexBuffer9_Unlock
(
d3dvtc
);
if
(
FAILED
(
hr
))
{
msg_Dbg
(
vd
,
"%s:%d (hr=0x%0lX)"
,
__FUNCTION__
,
__LINE__
,
hr
);
return
;
}
// Begin the scene
// Begin the scene
hr
=
IDirect3DDevice9_BeginScene
(
d3ddev
);
hr
=
IDirect3DDevice9_BeginScene
(
d3ddev
);
if
(
FAILED
(
hr
))
{
if
(
FAILED
(
hr
))
{
...
@@ -1150,37 +1196,17 @@ static void Direct3DRenderScene(vout_display_t *vd, LPDIRECT3DSURFACE9 surface)
...
@@ -1150,37 +1196,17 @@ static void Direct3DRenderScene(vout_display_t *vd, LPDIRECT3DSURFACE9 surface)
return
;
return
;
}
}
// Setup our texture. Using textures introduces the texture stage states,
/* Update the vertex buffer */
// which govern how textures get blended together (in the case of multiple
if
(
Direct3DSetupVertices
(
vd
,
d3dvtc
,
// textures) and lighting information. In this case, we are modulating
0
,
0
,
// (blending) our texture with the diffuse color of the vertices.
vd
->
sys
->
d3dpp
.
BackBufferWidth
,
hr
=
IDirect3DDevice9_SetTexture
(
d3ddev
,
0
,
(
LPDIRECT3DBASETEXTURE9
)
d3dtex
);
vd
->
sys
->
d3dpp
.
BackBufferHeight
))
{
if
(
FAILED
(
hr
))
{
msg_Dbg
(
vd
,
"%s:%d (hr=0x%0lX)"
,
__FUNCTION__
,
__LINE__
,
hr
);
IDirect3DDevice9_EndScene
(
d3ddev
);
return
;
}
// Render the vertex buffer contents
hr
=
IDirect3DDevice9_SetStreamSource
(
d3ddev
,
0
,
d3dvtc
,
0
,
sizeof
(
CUSTOMVERTEX
));
if
(
FAILED
(
hr
))
{
msg_Dbg
(
vd
,
"%s:%d (hr=0x%0lX)"
,
__FUNCTION__
,
__LINE__
,
hr
);
IDirect3DDevice9_EndScene
(
d3ddev
);
return
;
}
// we use FVF instead of vertex shader
hr
=
IDirect3DDevice9_SetFVF
(
d3ddev
,
D3DFVF_CUSTOMVERTEX
);
if
(
FAILED
(
hr
))
{
msg_Dbg
(
vd
,
"%s:%d (hr=0x%0lX)"
,
__FUNCTION__
,
__LINE__
,
hr
);
IDirect3DDevice9_EndScene
(
d3ddev
);
IDirect3DDevice9_EndScene
(
d3ddev
);
return
;
return
;
}
}
// draw rectangle
/* Render the texture */
hr
=
IDirect3DDevice9_DrawPrimitive
(
d3ddev
,
D3DPT_TRIANGLEFAN
,
0
,
2
);
if
(
Direct3DRenderTexture
(
vd
,
d3dvtc
,
d3dtex
))
{
if
(
FAILED
(
hr
))
{
msg_Dbg
(
vd
,
"%s:%d (hr=0x%0lX)"
,
__FUNCTION__
,
__LINE__
,
hr
);
IDirect3DDevice9_EndScene
(
d3ddev
);
IDirect3DDevice9_EndScene
(
d3ddev
);
return
;
return
;
}
}
...
...
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