]> git.sesse.net Git - vlc/commitdiff
macosx/* : added --macosx-opengl-effect, current possible values are
authorEric Petit <titer@videolan.org>
Mon, 9 Feb 2004 13:28:32 +0000 (13:28 +0000)
committerEric Petit <titer@videolan.org>
Mon, 9 Feb 2004 13:28:32 +0000 (13:28 +0000)
   "none" and "cube". Sorry, couldn't resist ;)

modules/gui/macosx/macosx.m
modules/gui/macosx/vout.h
modules/gui/macosx/vout.m

index b75f8f5953c17843ae6cac2fe0cd7e6f401a87c0..68ededb12dbf435e5ce9a238ce0e24fda7f9fc31 100644 (file)
@@ -2,7 +2,7 @@
  * macosx.m: MacOS X module for vlc
  *****************************************************************************
  * Copyright (C) 2001-2003 VideoLAN
- * $Id: macosx.m,v 1.19 2004/01/26 18:30:37 titer Exp $
+ * $Id: macosx.m,v 1.20 2004/02/09 13:28:31 titer Exp $
  *
  * Authors: Colin Delacroix <colin@zoy.org>
  *          Eugenio Jarosiewicz <ej0@cise.ufl.edu>
@@ -55,8 +55,16 @@ void E_(CloseVideo)   ( vlc_object_t * );
     "0 is fully transparent.")
 
 #define OPENGL_TEXT N_("Use OpenGL")
-#define OPENGL_LONGTEXT N_( \
-    "Use OpenGL instead of QuickTime to render the video on the screen." )
+#define OPENGL_LONGTEXT N_("Use OpenGL instead of QuickTime to " \
+        "render the video on the screen.")
+
+#define OPENGL_EFFECT_TEXT N_("OpenGL effect")
+#define OPENGL_EFFECT_LONGTEXT N_("Use 'None' to display the video " \
+        "without any fantasy, 'Cube' to let the video play on " \
+        "transparent faces of a rotating cube")
+
+static char * effect_list[] = { "none", "cube" };
+static char * effect_list_text[] = { N_("None"), N_("Cube") };
     
 vlc_module_begin();
     set_description( _("MacOS X interface, sound and video") );
@@ -71,5 +79,9 @@ vlc_module_begin();
                 OPAQUENESS_TEXT, OPAQUENESS_LONGTEXT, VLC_TRUE );
         add_bool( "macosx-opengl", 0, NULL, OPENGL_TEXT,
                   OPENGL_LONGTEXT, VLC_TRUE );
+        add_string( "macosx-opengl-effect", "none", NULL,
+                    OPENGL_EFFECT_TEXT, OPENGL_EFFECT_LONGTEXT,
+                    VLC_TRUE );
+        change_string_list( effect_list, effect_list_text, 0 );
 vlc_module_end();
 
index fc72e264f75e9cf9c38dccea36979a9be4f0a82d..07903b13482fa0cd5f22416242d46907c9866daa 100644 (file)
@@ -2,7 +2,7 @@
  * vout.h: MacOS X interface module
  *****************************************************************************
  * Copyright (C) 2001-2003 VideoLAN
- * $Id: vout.h,v 1.22 2004/02/03 13:00:27 titer Exp $
+ * $Id: vout.h,v 1.23 2004/02/09 13:28:32 titer Exp $
  *
  * Authors: Colin Delacroix <colin@zoy.org>
  *          Florian G. Pflug <fgp@phlo.org>
@@ -60,6 +60,7 @@
 @interface VLCGLView : NSOpenGLView
 {
     vout_thread_t * p_vout;
+    int             i_effect;
     int             b_init_done;
     unsigned long   i_texture;
     float           f_x;
index 7ec30c617c26646f9e1391df6e9877a7064a775a..2506da4d624dabec4dd3975df4e24d9b43e30ca7 100644 (file)
@@ -2,7 +2,7 @@
  * vout.m: MacOS X video output module
  *****************************************************************************
  * Copyright (C) 2001-2003 VideoLAN
- * $Id: vout.m,v 1.77 2004/02/03 13:00:27 titer Exp $
+ * $Id: vout.m,v 1.78 2004/02/09 13:28:32 titer Exp $
  *
  * Authors: Colin Delacroix <colin@zoy.org>
  *          Florian G. Pflug <fgp@phlo.org>
@@ -46,6 +46,9 @@
 #define QT_MAX_DIRECTBUFFERS 10
 #define VL_MAX_DISPLAYS 16
 
+#define OPENGL_EFFECT_NONE 1
+#define OPENGL_EFFECT_CUBE 2
+
 struct picture_sys_t
 {
     void *p_info;
@@ -1275,6 +1278,7 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
 
 - (id) initWithFrame: (NSRect) frame vout: (vout_thread_t*) _p_vout
 {
+    char * psz_effect;
     p_vout = _p_vout;
     
     NSOpenGLPixelFormatAttribute attribs[] =
@@ -1300,8 +1304,37 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
     [[self openGLContext] makeCurrentContext];
     [[self openGLContext] update];
 
+
+    /* Black bacjground */
     glClearColor( 0.0, 0.0, 0.0, 0.0 );
 
+    /* Check if the user asked for useless visual effects */
+    psz_effect = config_GetPsz( p_vout, "macosx-opengl-effect" );
+    if( !strcmp( psz_effect, "none" ) )
+    {
+        i_effect = OPENGL_EFFECT_NONE;
+    }
+    else if( !strcmp( psz_effect, "cube" ) )
+    {
+        i_effect = OPENGL_EFFECT_CUBE;
+        glMatrixMode( GL_PROJECTION );
+        glLoadIdentity();
+        glFrustum( -1.0, 1.0, -1.0, 1.0, 3.0, 20.0 );
+        glMatrixMode( GL_MODELVIEW );
+        glLoadIdentity();
+        glTranslatef( 0.0, 0.0, - 5.0 );
+        glBlendFunc( GL_SRC_ALPHA, GL_ONE );
+        glEnable( GL_BLEND );
+        glEnable( GL_POLYGON_SMOOTH );
+        glDisable( GL_DEPTH_TEST );
+    }
+    else
+    {
+        msg_Warn( p_vout, "no valid opengl effect provided, using "
+                  "\"none\"" );
+        i_effect = OPENGL_EFFECT_NONE;
+    }
+
     b_init_done = 0;
 
     return self;
@@ -1389,6 +1422,95 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
             PP_OUTPUTPICTURE[0]->p_data );
 }
 
+- (void) drawQuad
+{
+    glBegin( GL_QUADS );
+        /* Top left */
+        glTexCoord2f( 0.0, 0.0 );
+        glVertex3f( - 1.0, 1.0, 1.0 );
+        /* Bottom left */
+        glTexCoord2f( 0.0, (float) p_vout->output.i_height );
+        glVertex3f( - 1.0, - 1.0, 1.0 );
+        /* Bottom right */
+        glTexCoord2f( (float) p_vout->output.i_width,
+                      (float) p_vout->output.i_height );
+        glVertex3f( 1.0, - 1.0, 1.0 );
+        /* Top right */
+        glTexCoord2f( (float) p_vout->output.i_width, 0.0 );
+        glVertex3f( 1.0, 1.0, 1.0 );
+    glEnd();
+}
+
+- (void) drawCube
+{
+    glBegin( GL_QUADS );
+        glTexCoord2f( 0.0, 0.0 );
+        glVertex3f( - 1.0, 1.0, 1.0 );
+        glTexCoord2f( 0.0, (float) p_vout->output.i_height );
+        glVertex3f( - 1.0, - 1.0, 1.0 );
+        glTexCoord2f( (float) p_vout->output.i_width,
+                      (float) p_vout->output.i_height );
+        glVertex3f( 1.0, - 1.0, 1.0 );
+        glTexCoord2f( (float) p_vout->output.i_width, 0.0 );
+        glVertex3f( 1.0, 1.0, 1.0 );
+    glEnd();
+    glBegin( GL_QUADS );
+        glTexCoord2f( 0.0, 0.0 );
+        glVertex3f( - 1.0, 1.0, - 1.0 );
+        glTexCoord2f( 0.0, (float) p_vout->output.i_height );
+        glVertex3f( - 1.0, - 1.0, - 1.0 );
+        glTexCoord2f( (float) p_vout->output.i_width,
+                      (float) p_vout->output.i_height );
+        glVertex3f( - 1.0, - 1.0, 1.0 );
+        glTexCoord2f( (float) p_vout->output.i_width, 0.0 );
+        glVertex3f( - 1.0, 1.0, 1.0 );
+    glEnd();
+    glBegin( GL_QUADS );
+        glTexCoord2f( 0.0, 0.0 );
+        glVertex3f( 1.0, 1.0, - 1.0 );
+        glTexCoord2f( 0.0, (float) p_vout->output.i_height );
+        glVertex3f( 1.0, - 1.0, - 1.0 );
+        glTexCoord2f( (float) p_vout->output.i_width,
+                      (float) p_vout->output.i_height );
+        glVertex3f( - 1.0, - 1.0, - 1.0 );
+        glTexCoord2f( (float) p_vout->output.i_width, 0.0 );
+        glVertex3f( - 1.0, 1.0, - 1.0 );
+    glEnd();
+    glBegin( GL_QUADS );
+        glTexCoord2f( 0.0, 0.0 );
+        glVertex3f( 1.0, 1.0, 1.0 );
+        glTexCoord2f( 0.0, (float) p_vout->output.i_height );
+        glVertex3f( 1.0, - 1.0, 1.0 );
+        glTexCoord2f( (float) p_vout->output.i_width,
+                      (float) p_vout->output.i_height );
+        glVertex3f( 1.0, - 1.0, - 1.0 );
+        glTexCoord2f( (float) p_vout->output.i_width, 0.0 );
+        glVertex3f( 1.0, 1.0, - 1.0 );
+    glEnd();
+    glBegin( GL_QUADS );
+        glTexCoord2f( 0.0, 0.0 );
+        glVertex3f( - 1.0, 1.0, - 1.0 );
+        glTexCoord2f( 0.0, (float) p_vout->output.i_height );
+        glVertex3f( - 1.0, 1.0, 1.0 );
+        glTexCoord2f( (float) p_vout->output.i_width,
+                      (float) p_vout->output.i_height );
+        glVertex3f( 1.0, 1.0, 1.0 );
+        glTexCoord2f( (float) p_vout->output.i_width, 0.0 );
+        glVertex3f( 1.0, 1.0, - 1.0 );
+    glEnd();
+    glBegin( GL_QUADS );
+        glTexCoord2f( 0.0, 0.0 );
+        glVertex3f( - 1.0, - 1.0, 1.0 );
+        glTexCoord2f( 0.0, (float) p_vout->output.i_height );
+        glVertex3f( - 1.0, - 1.0, - 1.0 );
+        glTexCoord2f( (float) p_vout->output.i_width,
+                      (float) p_vout->output.i_height );
+        glVertex3f( 1.0, - 1.0, - 1.0 );
+        glTexCoord2f( (float) p_vout->output.i_width, 0.0 );
+        glVertex3f( 1.0, - 1.0, 1.0 );
+    glEnd();
+}
+
 - (void) drawRect: (NSRect) rect
 {
     [[self openGLContext] makeCurrentContext];
@@ -1409,23 +1531,17 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
         return;
     }
 
-    /* Draw a quad with our texture on it */
+    /* Draw */
     glBindTexture( GL_TEXTURE_RECTANGLE_EXT, i_texture );
-    glBegin( GL_QUADS );
-        /* Top left */
-        glTexCoord2f( 0.0, 0.0 );
-        glVertex2f( - f_x, f_y );
-        /* Bottom left */
-        glTexCoord2f( 0.0, (float) p_vout->output.i_height );
-        glVertex2f( - f_x, - f_y );
-        /* Bottom right */
-        glTexCoord2f( (float) p_vout->output.i_width,
-                      (float) p_vout->output.i_height );
-        glVertex2f( f_x, - f_y );
-        /* Top right */
-        glTexCoord2f( (float) p_vout->output.i_width, 0.0 );
-        glVertex2f( f_x, f_y );
-    glEnd();
+    if( i_effect == OPENGL_EFFECT_CUBE )
+    {
+        glRotatef( 1.0, 0.5, 0.5, 1.0 );
+        [self drawCube];
+    }
+    else
+    {
+        [self drawQuad];
+    }
 
     /* Wait for the job to be done */
     [[self openGLContext] flushBuffer];