]> git.sesse.net Git - vlc/blobdiff - modules/video_output/glx.c
macosx: remove unneeded performSelectorOnMainThread
[vlc] / modules / video_output / glx.c
index 8aa1e088b7dd17c8346a099d57eced733c524c46..9fc13f5cdf4375b5d5829e23de808f3b9aaa3b82 100644 (file)
@@ -12,7 +12,7 @@
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public License
@@ -55,6 +55,7 @@ typedef struct vlc_gl_sys_t
 } vlc_gl_sys_t;
 
 static int MakeCurrent (vlc_gl_t *);
+static void ReleaseCurrent (vlc_gl_t *);
 static void SwapBuffers (vlc_gl_t *);
 static void *GetSymbol(vlc_gl_t *, const char *);
 
@@ -100,7 +101,7 @@ static int Open (vlc_object_t *obj)
 {
     vlc_gl_t *gl = (vlc_gl_t *)obj;
 
-    if (!vlc_xlib_init (obj))
+    if (gl->surface->type != VOUT_WINDOW_TYPE_XID || !vlc_xlib_init (obj))
         return VLC_EGENERIC;
 
     /* Initialize GLX display */
@@ -184,8 +185,19 @@ static int Open (vlc_object_t *obj)
         goto error;
     }
 
+    /* Initialize OpenGL callbacks */
+    gl->sys = sys;
+    gl->makeCurrent = MakeCurrent;
+    gl->releaseCurrent = ReleaseCurrent;
+    gl->swap = SwapBuffers;
+    gl->getProcAddress = GetSymbol;
+    gl->lock = NULL;
+    gl->unlock = NULL;
+
 #ifdef GLX_ARB_get_proc_address
     bool is_swap_interval_set = false;
+
+    MakeCurrent (gl);
 # ifdef GLX_SGI_swap_control
     if (!is_swap_interval_set
      && CheckGLXext (dpy, snum, "GLX_SGI_swap_control"))
@@ -207,15 +219,9 @@ static int Open (vlc_object_t *obj)
         is_swap_interval_set = true;
     }
 # endif
+    ReleaseCurrent (gl);
 #endif
 
-    /* Initialize OpenGL callbacks */
-    gl->sys = sys;
-    gl->makeCurrent = MakeCurrent;
-    gl->swap = SwapBuffers;
-    gl->getProcAddress = GetSymbol;
-    gl->lock = NULL;
-    gl->unlock = NULL;
     return VLC_SUCCESS;
 
 error:
@@ -245,6 +251,13 @@ static int MakeCurrent (vlc_gl_t *gl)
     return VLC_SUCCESS;
 }
 
+static void ReleaseCurrent (vlc_gl_t *gl)
+{
+    vlc_gl_sys_t *sys = gl->sys;
+
+    glXMakeContextCurrent (sys->display, None, None, NULL);
+}
+
 static void SwapBuffers (vlc_gl_t *gl)
 {
     vlc_gl_sys_t *sys = gl->sys;