Commit 40a45dc8 authored by gbazin's avatar gbazin
Browse files

* modules/video_output/x11/glx.c: OpenGL context is initialized in pf_init()...

* modules/video_output/x11/glx.c: OpenGL context is initialized in pf_init() because of threading issues.
parent 32b211e4
......@@ -122,6 +122,7 @@ static int CreateVout( vlc_object_t *p_this )
msg_Err( p_vout, "out of memory" );
return VLC_ENOMEM;
}
vlc_object_attach( p_sys->p_vout, p_this );
p_sys->p_vout->i_window_width = p_vout->i_window_width;
p_sys->p_vout->i_window_height = p_vout->i_window_height;
......@@ -136,10 +137,10 @@ static int CreateVout( vlc_object_t *p_this )
if( p_sys->p_vout->p_module == NULL )
{
msg_Err( p_vout, "No OpenGL provider found" );
vlc_object_detach( p_sys->p_vout );
vlc_object_destroy( p_sys->p_vout );
return VLC_ENOOBJ;
}
vlc_object_attach( p_sys->p_vout, p_this );
p_vout->pf_init = Init;
p_vout->pf_end = End;
......@@ -158,6 +159,8 @@ static int Init( vout_thread_t *p_vout )
vout_sys_t *p_sys = p_vout->p_sys;
int i_pixel_pitch;
p_sys->p_vout->pf_init( p_sys->p_vout );
/* No YUV textures :( */
#if VLCGL_RGB_FORMAT == GL_RGB
......
......@@ -70,6 +70,7 @@
*****************************************************************************/
static int CreateOpenGL ( vlc_object_t * );
static void DestroyOpenGL( vlc_object_t * );
static int InitOpenGL ( vout_thread_t * );
static void SwapBuffers ( vout_thread_t * );
/*****************************************************************************
......@@ -115,28 +116,10 @@ static int CreateOpenGL( vlc_object_t *p_this )
}
/* Set the function pointer */
p_vout->pf_init = InitOpenGL;
p_vout->pf_swap = SwapBuffers;
p_vout->p_sys->b_glx13 = b_glx13;
/* Initialize GLX */
if( !b_glx13 )
{
if( InitGLX12( p_vout ) != VLC_SUCCESS )
{
return VLC_EGENERIC;
}
}
else
{
if( InitGLX13( p_vout ) != VLC_SUCCESS )
{
return VLC_EGENERIC;
}
}
/* Set the OpenGL context _for the current thread_ */
SwitchContext( p_vout );
return VLC_SUCCESS;
}
......@@ -211,6 +194,33 @@ static int CheckGLX( vlc_object_t *p_this, vlc_bool_t *b_glx13 )
return VLC_SUCCESS;
}
/*****************************************************************************
* InitOpenGL: initializes OpenGL provider
*****************************************************************************/
static int InitOpenGL( vout_thread_t *p_vout )
{
/* Initialize GLX */
if( !p_vout->p_sys->b_glx13 )
{
if( InitGLX12( p_vout ) != VLC_SUCCESS )
{
return VLC_EGENERIC;
}
}
else
{
if( InitGLX13( p_vout ) != VLC_SUCCESS )
{
return VLC_EGENERIC;
}
}
/* Set the OpenGL context _for the current thread_ */
SwitchContext( p_vout );
return VLC_SUCCESS;
}
int InitGLX12( vout_thread_t *p_vout )
{
vout_sys_t *p_sys = p_vout->p_sys;
......
......@@ -206,6 +206,7 @@ static void Thread( vlc_object_t *p_this )
msg_Err( p_thread, "out of memory" );
return;
}
vlc_object_attach( p_thread->p_opengl, p_this );
p_thread->p_opengl->i_window_width = p_thread->i_width;
p_thread->p_opengl->i_window_height = p_thread->i_height;
......@@ -218,11 +219,12 @@ static void Thread( vlc_object_t *p_this )
if( p_thread->p_module == NULL )
{
msg_Err( p_thread, "No OpenGL provider found" );
vlc_object_detach( p_thread->p_opengl );
vlc_object_destroy( p_thread->p_opengl );
return;
}
vlc_object_attach( p_thread->p_opengl, p_this );
p_thread->p_opengl->pf_init( p_thread->p_opengl );
setup_opengl( p_thread->i_width, p_thread->i_height );
CreateRenderTarget(512, &RenderTargetTextureID, NULL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment