Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
8edf3ea9
Commit
8edf3ea9
authored
Dec 07, 2009
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converted glwin32 to vout display.
parent
1930ef7e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
145 additions
and
134 deletions
+145
-134
modules/video_output/msw/Modules.am
modules/video_output/msw/Modules.am
+4
-4
modules/video_output/msw/common.c
modules/video_output/msw/common.c
+1
-1
modules/video_output/msw/common.h
modules/video_output/msw/common.h
+5
-2
modules/video_output/msw/events.c
modules/video_output/msw/events.c
+1
-1
modules/video_output/msw/glwin32.c
modules/video_output/msw/glwin32.c
+134
-126
No files found.
modules/video_output/msw/Modules.am
View file @
8edf3ea9
...
...
@@ -16,10 +16,10 @@ SOURCES_direct3d = \
SOURCES_glwin32 = \
glwin32.c \
vout
.h \
events
_vo
.h \
events
_vo
.c \
common
_vo
.c \
common
.h \
events.h \
events.c \
common.c \
$(NULL)
SOURCES_wingdi = \
...
...
modules/video_output/msw/common.c
View file @
8edf3ea9
...
...
@@ -46,7 +46,7 @@
#include <d3d9.h>
#endif
#ifdef MODULE_NAME_IS_glwin32
#include
<GL/gl.h>
#include
"../opengl.h"
#endif
#include "common.h"
...
...
modules/video_output/msw/common.h
View file @
8edf3ea9
...
...
@@ -148,8 +148,11 @@ struct vout_display_sys_t
#endif
#ifdef MODULE_NAME_IS_glwin32
HDC
hGLDC
;
HGLRC
hGLRC
;
HDC
hGLDC
;
HGLRC
hGLRC
;
vout_opengl_t
gl
;
vout_display_opengl_t
vgl
;
picture_pool_t
*
pool
;
#endif
#ifdef MODULE_NAME_IS_direct3d
...
...
modules/video_output/msw/events.c
View file @
8edf3ea9
...
...
@@ -47,7 +47,7 @@
#include <d3d9.h>
#endif
#ifdef MODULE_NAME_IS_glwin32
#include
<GL/gl.h>
#include
"../opengl.h"
#endif
#include <vlc_keys.h>
...
...
modules/video_output/msw/glwin32.c
View file @
8edf3ea9
...
...
@@ -26,7 +26,7 @@
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_vout.h>
#include <vlc_vout
_display
.h>
#include <windows.h>
#include <ddraw.h>
...
...
@@ -39,185 +39,193 @@
# define MONITOR_DEFAULTTONEAREST 2
#endif
#include <GL/gl.h>
#include "vout.h"
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
static
int
OpenVideo
(
vlc_object_t
*
);
static
void
CloseVideo
(
vlc_object_t
*
);
static
int
Init
(
vout_thread_t
*
);
static
void
End
(
vout_thread_t
*
);
static
int
Manage
(
vout_thread_t
*
);
static
void
GLSwapBuffers
(
vout_thread_t
*
);
static
void
FirstSwap
(
vout_thread_t
*
);
#include "../opengl.h"
#include "common.h"
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
()
set_category
(
CAT_VIDEO
)
set_subcategory
(
SUBCAT_VIDEO_VOUT
)
set_shortname
(
"OpenGL"
)
set_description
(
N_
(
"OpenGL video output"
)
)
set_capability
(
"opengl provider"
,
100
)
add_shortcut
(
"glwin32"
)
set_callbacks
(
OpenVideo
,
CloseVideo
)
static
int
Open
(
vlc_object_t
*
);
static
void
Close
(
vlc_object_t
*
);
vlc_module_begin
()
set_category
(
CAT_VIDEO
)
set_subcategory
(
SUBCAT_VIDEO_VOUT
)
set_shortname
(
"OpenGL"
)
set_description
(
N_
(
"OpenGL video output"
))
set_capability
(
"vout display"
,
20
)
add_shortcut
(
"glwin32"
)
set_callbacks
(
Open
,
Close
)
/* FIXME: Hack to avoid unregistering our window class */
linked_with_a_crap_library_which_uses_atexit
()
vlc_module_end
()
vlc_module_end
()
#if 0 /* FIXME */
/* check if we registered a window class because we need to
* unregister it */
WNDCLASS wndclass;
if(
GetClassInfo( GetModuleHandle(NULL), "VLC DirectX", &wndclass )
)
UnregisterClass(
"VLC DirectX", GetModuleHandle(NULL)
);
if(
GetClassInfo(GetModuleHandle(NULL), "VLC DirectX", &wndclass)
)
UnregisterClass(
"VLC DirectX", GetModuleHandle(NULL)
);
#endif
/*****************************************************************************
* OpenVideo: allocate OpenGL provider
*****************************************************************************
* This function creates and initializes a video window.
* Local prototypes.
*****************************************************************************/
static
int
OpenVideo
(
vlc_object_t
*
p_this
)
static
picture_t
*
Get
(
vout_display_t
*
);
static
void
Prepare
(
vout_display_t
*
,
picture_t
*
);
static
void
Display
(
vout_display_t
*
,
picture_t
*
);
static
int
Control
(
vout_display_t
*
,
int
,
va_list
);
static
void
Manage
(
vout_display_t
*
);
static
void
Swap
(
vout_opengl_t
*
);
/**
* It creates an OpenGL vout display.
*/
static
int
Open
(
vlc_object_t
*
object
)
{
vout_thread_t
*
p_vout
=
(
vout_thread_t
*
)
p_this
;
vout_display_t
*
vd
=
(
vout_display_t
*
)
object
;
vout_display_sys_t
*
sys
;
/* Allocate structure */
p_vout
->
p_sys
=
calloc
(
1
,
sizeof
(
vout_sys_t
)
);
if
(
p_vout
->
p_sys
==
NULL
)
vd
->
sys
=
sys
=
calloc
(
1
,
sizeof
(
*
sys
)
);
if
(
!
sys
)
return
VLC_ENOMEM
;
/* Initialisations */
p_vout
->
pf_init
=
Init
;
p_vout
->
pf_end
=
End
;
p_vout
->
pf_manage
=
Manage
;
p_vout
->
pf_swap
=
FirstSwap
;
p_vout
->
pf_control
=
Control
;
if
(
CommonInit
(
p_vout
)
)
/* */
if
(
CommonInit
(
vd
))
goto
error
;
return
VLC_SUCCESS
;
error:
CloseVideo
(
VLC_OBJECT
(
p_vout
)
);
return
VLC_EGENERIC
;
}
/*****************************************************************************
* Init: initialize video thread output method
*****************************************************************************/
static
int
Init
(
vout_thread_t
*
p_vout
)
{
PIXELFORMATDESCRIPTOR
pfd
;
int
iFormat
;
/* Change the window title bar text */
EventThreadUpdateTitle
(
p_vout
->
p_sys
->
p_event
,
VOUT_TITLE
" (OpenGL output)"
);
EventThreadUpdateTitle
(
sys
->
event
,
VOUT_TITLE
" (OpenGL output)"
);
p_vout
->
p_sys
->
hGLDC
=
GetDC
(
p_vout
->
p_sys
->
hvideownd
);
/* */
sys
->
hGLDC
=
GetDC
(
sys
->
hvideownd
);
/* Set the pixel format for the DC */
memset
(
&
pfd
,
0
,
sizeof
(
pfd
)
);
pfd
.
nSize
=
sizeof
(
pfd
);
PIXELFORMATDESCRIPTOR
pfd
;
memset
(
&
pfd
,
0
,
sizeof
(
pfd
));
pfd
.
nSize
=
sizeof
(
pfd
);
pfd
.
nVersion
=
1
;
pfd
.
dwFlags
=
PFD_DRAW_TO_WINDOW
|
PFD_SUPPORT_OPENGL
|
PFD_DOUBLEBUFFER
;
pfd
.
iPixelType
=
PFD_TYPE_RGBA
;
pfd
.
cColorBits
=
24
;
pfd
.
cDepthBits
=
16
;
pfd
.
iLayerType
=
PFD_MAIN_PLANE
;
iFormat
=
ChoosePixelFormat
(
p_vout
->
p_sys
->
hGLDC
,
&
pfd
);
SetPixelFormat
(
p_vout
->
p_sys
->
hGLDC
,
iFormat
,
&
pfd
);
SetPixelFormat
(
sys
->
hGLDC
,
ChoosePixelFormat
(
sys
->
hGLDC
,
&
pfd
),
&
pfd
);
/* Create and enable the render context */
p_vout
->
p_sys
->
hGLRC
=
wglCreateContext
(
p_vout
->
p_sys
->
hGLDC
);
wglMakeCurrent
(
p_vout
->
p_sys
->
hGLDC
,
p_vout
->
p_sys
->
hGLRC
);
sys
->
hGLRC
=
wglCreateContext
(
sys
->
hGLDC
);
wglMakeCurrent
(
sys
->
hGLDC
,
sys
->
hGLRC
);
/* */
sys
->
gl
.
lock
=
NULL
;
sys
->
gl
.
unlock
=
NULL
;
sys
->
gl
.
swap
=
Swap
;
sys
->
gl
.
sys
=
vd
;
video_format_t
fmt
=
vd
->
fmt
;
if
(
vout_display_opengl_Init
(
&
sys
->
vgl
,
&
fmt
,
&
sys
->
gl
))
goto
error
;
vout_display_info_t
info
=
vd
->
info
;
info
.
has_double_click
=
true
;
info
.
has_hide_mouse
=
true
;
info
.
has_pictures_invalid
=
true
;
/* Setup vout_display now that everything is fine */
vd
->
fmt
=
fmt
;
vd
->
info
=
info
;
vd
->
get
=
Get
;
vd
->
prepare
=
Prepare
;
vd
->
display
=
Display
;
vd
->
control
=
Control
;
vd
->
manage
=
Manage
;
return
VLC_SUCCESS
;
error:
Close
(
object
);
return
VLC_EGENERIC
;
}
/*****************************************************************************
* End: terminate Sys video thread output method
*****************************************************************************
* Terminate an output method created by Create.
* It is called at the end of the thread.
*****************************************************************************/
static
void
End
(
vout_thread_t
*
p_vout
)
/**
* It destroys an OpenGL vout display.
*/
static
void
Close
(
vlc_object_t
*
object
)
{
wglMakeCurrent
(
NULL
,
NULL
);
wglDeleteContext
(
p_vout
->
p_sys
->
hGLRC
);
ReleaseDC
(
p_vout
->
p_sys
->
hvideownd
,
p_vout
->
p_sys
->
hGLDC
);
return
;
vout_display_t
*
vd
=
(
vout_display_t
*
)
object
;
vout_display_sys_t
*
sys
=
vd
->
sys
;
if
(
sys
->
vgl
.
gl
)
vout_display_opengl_Clean
(
&
sys
->
vgl
);
if
(
sys
->
hGLDC
&&
sys
->
hGLRC
)
wglMakeCurrent
(
NULL
,
NULL
);
if
(
sys
->
hGLRC
)
wglDeleteContext
(
sys
->
hGLRC
);
if
(
sys
->
hGLDC
)
ReleaseDC
(
sys
->
hvideownd
,
sys
->
hGLDC
);
CommonClean
(
vd
);
free
(
sys
);
}
/*****************************************************************************
* CloseVideo: destroy Sys video thread output method
*****************************************************************************
* Terminate an output method created by Create
*****************************************************************************/
static
void
CloseVideo
(
vlc_object_t
*
p_this
)
/* */
static
picture_t
*
Get
(
vout_display_t
*
vd
)
{
vout_thread_t
*
p_vout
=
(
vout_thread_t
*
)
p_this
;
vout_display_sys_t
*
sys
=
vd
->
sys
;
if
(
!
sys
->
pool
)
{
sys
->
pool
=
vout_display_opengl_GetPool
(
&
sys
->
vgl
);
if
(
!
sys
->
pool
)
return
NULL
;
}
return
picture_pool_Get
(
sys
->
pool
);
}
CommonClean
(
p_vout
);
static
void
Prepare
(
vout_display_t
*
vd
,
picture_t
*
picture
)
{
vout_display_sys_t
*
sys
=
vd
->
sys
;
free
(
p_vout
->
p_sys
);
vout_display_opengl_Prepare
(
&
sys
->
vgl
,
picture
);
}
/*****************************************************************************
* Manage: handle Sys events
*****************************************************************************
* This function should be called regularly by the video output thread.
* It returns a non null value if an error occurred.
*****************************************************************************/
static
int
Manage
(
vout_thread_t
*
p_vout
)
static
void
Display
(
vout_display_t
*
vd
,
picture_t
*
picture
)
{
vout_
sys_t
*
p_sys
=
p_vout
->
p_
sys
;
vout_
display_sys_t
*
sys
=
vd
->
sys
;
const
int
i_width
=
p_sys
->
rect_dest
.
right
-
p_sys
->
rect_dest
.
left
;
const
int
i_height
=
p_sys
->
rect_dest
.
bottom
-
p_sys
->
rect_dest
.
top
;
glViewport
(
0
,
0
,
i_width
,
i_height
);
vout_display_opengl_Display
(
&
sys
->
vgl
,
&
vd
->
source
);
CommonManage
(
p_vout
);
return
VLC_SUCCESS
;
picture_Release
(
picture
);
CommonDisplay
(
vd
);
}
/*****************************************************************************
* GLSwapBuffers: swap front/back buffers
*****************************************************************************/
static
void
GLSwapBuffers
(
vout_thread_t
*
p_vout
)
static
int
Control
(
vout_display_t
*
vd
,
int
query
,
va_list
args
)
{
SwapBuffers
(
p_vout
->
p_sys
->
hGLDC
);
return
CommonControl
(
vd
,
query
,
args
);
}
/*
** this function is only used once when the first picture is received
** this function will show the video window once a picture is ready
*/
static
void
Manage
(
vout_display_t
*
vd
)
{
vout_display_sys_t
*
sys
=
vd
->
sys
;
CommonManage
(
vd
);
static
void
FirstSwap
(
vout_thread_t
*
p_vout
)
const
int
width
=
sys
->
rect_dest
.
right
-
sys
->
rect_dest
.
left
;
const
int
height
=
sys
->
rect_dest
.
bottom
-
sys
->
rect_dest
.
top
;
glViewport
(
0
,
0
,
width
,
height
);
}
static
void
Swap
(
vout_opengl_t
*
gl
)
{
/* get initial picture buffer swapped to front buffer */
GLSwapBuffers
(
p_vout
);
/*
** Video window is initially hidden, show it now since we got a
** picture to show.
*/
SetWindowPos
(
p_vout
->
p_sys
->
hvideownd
,
NULL
,
0
,
0
,
0
,
0
,
SWP_ASYNCWINDOWPOS
|
SWP_FRAMECHANGED
|
SWP_SHOWWINDOW
|
SWP_NOMOVE
|
SWP_NOSIZE
|
SWP_NOZORDER
);
/* use and restores proper swap function for further pictures */
p_vout
->
pf_swap
=
GLSwapBuffers
;
vout_display_t
*
vd
=
gl
->
sys
;
SwapBuffers
(
vd
->
sys
->
hGLDC
);
}
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