]> git.sesse.net Git - vlc/commitdiff
macosx/vout.m: swap OpenGL buffers only during the vertical retrace of
authorEric Petit <titer@videolan.org>
Wed, 28 Jan 2004 14:36:53 +0000 (14:36 +0000)
committerEric Petit <titer@videolan.org>
Wed, 28 Jan 2004 14:36:53 +0000 (14:36 +0000)
   the monitor (fixed flickering effect)

modules/gui/macosx/vout.m

index 402210a85e16c2f45a25b16797695fcef91685dd..04aa77743aa2f12742f6785c6ffae4b805850b5c 100644 (file)
@@ -2,7 +2,7 @@
  * vout.m: MacOS X video output module
  *****************************************************************************
  * Copyright (C) 2001-2003 VideoLAN
- * $Id: vout.m,v 1.72 2004/01/27 12:11:48 titer Exp $
+ * $Id: vout.m,v 1.73 2004/01/28 14:36:53 titer Exp $
  *
  * Authors: Colin Delacroix <colin@zoy.org>
  *          Florian G. Pflug <fgp@phlo.org>
@@ -33,6 +33,7 @@
 
 #include <QuickTime/QuickTime.h>
 
+#include <OpenGL/OpenGL.h>
 #include <OpenGL/gl.h>
 #include <OpenGL/glext.h>
 
@@ -1271,12 +1272,19 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
         NSOpenGLPFAAccelerated,
         NSOpenGLPFANoRecovery,
         NSOpenGLPFADoubleBuffer,
+        NSOpenGLPFAWindow,
         0
     };
 
     NSOpenGLPixelFormat * fmt = [[NSOpenGLPixelFormat alloc]
         initWithAttributes: attribs];
 
+    if( !fmt )
+    {
+        fprintf( stderr, "Cannot create NSOpenGLPixelFormat\n" );
+        return self;
+    }
+
     self = [super initWithFrame:frame pixelFormat: fmt];
 
     [[self openGLContext] makeCurrentContext];
@@ -1296,7 +1304,8 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
 {
     [[self openGLContext] update];
     NSRect bounds = [self bounds];
-    glViewport( 0, 0, (GLint) bounds.size.width, (GLint) bounds.size.height );
+    glViewport( 0, 0, (GLint) bounds.size.width,
+                (GLint) bounds.size.height );
 }
 
 - (void)drawRect:(NSRect)rect
@@ -1305,10 +1314,15 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
     id o_window = [self window];
     p_vout = (vout_thread_t *)[o_window getVout];
 
-
     /* Make this current context */
     [[self openGLContext] makeCurrentContext];
 
+    /* http://developer.apple.com/documentation/GraphicsImaging/
+       Conceptual/OpenGL/chap5/chapter_5_section_44.html */
+    long params[] = { 1 };
+    CGLSetParameter( CGLGetCurrentContext(), kCGLCPSwapInterval,
+                     params );
+
     /* Black background */
     glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );