]> git.sesse.net Git - vlc/commitdiff
* modules/video_output/x11/glx.c: OpenGL context is initialized in pf_init() because...
authorGildas Bazin <gbazin@videolan.org>
Thu, 22 Jul 2004 22:36:16 +0000 (22:36 +0000)
committerGildas Bazin <gbazin@videolan.org>
Thu, 22 Jul 2004 22:36:16 +0000 (22:36 +0000)
modules/video_output/opengl.c
modules/video_output/x11/glx.c
modules/visualization/galaktos/plugin.c

index 35770e78bd887a905dca99997eb5bfbc1a4386c5..02dff369c5f04b633856bd42a88c9c37273a188d 100644 (file)
@@ -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
index 1c4fde69f93da83a4b8b70a68a32755c9df1542b..918306eb23aa5bf9a75982d9443c4bed633037ce 100644 (file)
@@ -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;
index a62bea1ce2ac4c5480a8d4f34e9cb53c84fbbfc7..3c7792b9abfca41147a2fac633ceb9b56296aec5 100644 (file)
@@ -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);