1 /*****************************************************************************
2 * opengl.c: OpenGL video output
3 *****************************************************************************
4 * Copyright (C) 2004 VideoLAN (Centrale Réseaux) and its contributors
7 * Authors: Cyril Deguet <asmax@videolan.org>
8 * Gildas Bazin <gbazin@videolan.org>
9 * Eric Petit <titer@m0k.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 /*****************************************************************************
28 *****************************************************************************/
29 #include <errno.h> /* ENOMEM */
30 #include <stdlib.h> /* malloc(), free() */
37 #include <OpenGL/gl.h>
38 #include <OpenGL/glext.h>
40 /* On OS X, use GL_TEXTURE_RECTANGLE_EXT instead of GL_TEXTURE_2D.
41 This allows sizes which are not powers of 2 */
42 #define VLCGL_TARGET GL_TEXTURE_RECTANGLE_EXT
44 /* OS X OpenGL supports YUV. Hehe. */
45 #define VLCGL_FORMAT GL_YCBCR_422_APPLE
46 #define VLCGL_TYPE GL_UNSIGNED_SHORT_8_8_APPLE
50 #define VLCGL_TARGET GL_TEXTURE_2D
53 #ifndef GL_UNSIGNED_SHORT_5_6_5
54 #define GL_UNSIGNED_SHORT_5_6_5 0x8363
56 //#define VLCGL_RGB_FORMAT GL_RGB
57 //#define VLCGL_RGB_TYPE GL_UNSIGNED_SHORT_5_6_5
60 //#define VLCGL_RGB_FORMAT GL_RGB
61 //#define VLCGL_RGB_TYPE GL_UNSIGNED_BYTE
64 #define VLCGL_RGB_FORMAT GL_RGBA
65 #define VLCGL_RGB_TYPE GL_UNSIGNED_BYTE
67 /* Use RGB on Win32/GLX */
68 #define VLCGL_FORMAT VLCGL_RGB_FORMAT
69 #define VLCGL_TYPE VLCGL_RGB_TYPE
72 #ifndef GL_CLAMP_TO_EDGE
73 # define GL_CLAMP_TO_EDGE 0x812F
77 #define OPENGL_EFFECT_NONE 1
78 #define OPENGL_EFFECT_CUBE 2
79 #define OPENGL_EFFECT_TRANSPARENT_CUBE 4
81 /*****************************************************************************
83 *****************************************************************************/
84 static int CreateVout ( vlc_object_t * );
85 static void DestroyVout ( vlc_object_t * );
86 static int Init ( vout_thread_t * );
87 static void End ( vout_thread_t * );
88 static int Manage ( vout_thread_t * );
89 static void Render ( vout_thread_t *, picture_t * );
90 static void DisplayVideo ( vout_thread_t *, picture_t * );
91 static int Control ( vout_thread_t *, int, va_list );
93 static inline int GetAlignedSize( int );
95 static int InitTextures( vout_thread_t * );
96 static int SendEvents( vlc_object_t *, char const *,
97 vlc_value_t, vlc_value_t, void * );
99 /*****************************************************************************
101 *****************************************************************************/
102 #define SPEED_TEXT N_( "OpenGL cube rotation speed" )
103 /*****************************************************************************
105 *****************************************************************************/
106 #define SPEED_TEXT N_( "OpenGL cube rotation speed" )
107 #define SPEED_LONGTEXT N_( "If the OpenGL cube effect is enabled, this " \
108 "controls its rotation speed." )
110 #define EFFECT_TEXT N_("Select effect")
111 #define EFFECT_LONGTEXT N_( \
112 "Allows you to select different visual effects.")
114 static char *ppsz_effects[] = {
115 "none", "cube", "transparent-cube" };
116 static char *ppsz_effects_text[] = {
117 N_("None"), N_("Cube"), N_("Transparent Cube") };
120 set_shortname( "OpenGL" );
121 set_category( CAT_VIDEO );
122 set_subcategory( SUBCAT_VIDEO_VOUT );
123 set_description( _("OpenGL video output") );
125 set_capability( "video output", 200 );
127 set_capability( "video output", 20 );
129 add_shortcut( "opengl" );
130 add_float( "opengl-cube-speed", 2.0, NULL, SPEED_TEXT,
131 SPEED_LONGTEXT, VLC_TRUE );
132 set_callbacks( CreateVout, DestroyVout );
133 add_string( "opengl-effect", "none", NULL, EFFECT_TEXT,
134 EFFECT_LONGTEXT, VLC_FALSE );
135 change_string_list( ppsz_effects, ppsz_effects_text, 0 );
138 /*****************************************************************************
139 * vout_sys_t: video output method descriptor
140 *****************************************************************************
141 * This structure is part of the video output thread descriptor.
142 * It describes the OpenGL specific properties of the output thread.
143 *****************************************************************************/
146 vout_thread_t *p_vout;
148 uint8_t *pp_buffer[2];
152 GLuint p_textures[2];
159 /*****************************************************************************
160 * CreateVout: This function allocates and initializes the OpenGL vout method.
161 *****************************************************************************/
162 static int CreateVout( vlc_object_t *p_this )
164 vout_thread_t *p_vout = (vout_thread_t *)p_this;
167 /* Allocate structure */
168 p_vout->p_sys = p_sys = malloc( sizeof( vout_sys_t ) );
171 msg_Err( p_vout, "out of memory" );
175 var_Create( p_vout, "opengl-effect", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
179 p_sys->i_tex_width = p_vout->render.i_width;
180 p_sys->i_tex_height = p_vout->render.i_height;
182 /* A texture must have a size aligned on a power of 2 */
183 p_sys->i_tex_width = GetAlignedSize( p_vout->render.i_width );
184 p_sys->i_tex_height = GetAlignedSize( p_vout->render.i_height );
187 msg_Dbg( p_vout, "Texture size: %dx%d", p_sys->i_tex_width,
188 p_sys->i_tex_height );
192 (vout_thread_t *)vlc_object_create( p_this, VLC_OBJECT_OPENGL );
193 if( p_sys->p_vout == NULL )
195 msg_Err( p_vout, "out of memory" );
198 vlc_object_attach( p_sys->p_vout, p_this );
200 p_sys->p_vout->i_window_width = p_vout->i_window_width;
201 p_sys->p_vout->i_window_height = p_vout->i_window_height;
202 p_sys->p_vout->b_fullscreen = p_vout->b_fullscreen;
203 p_sys->p_vout->render.i_width = p_vout->render.i_width;
204 p_sys->p_vout->render.i_height = p_vout->render.i_height;
205 p_sys->p_vout->render.i_aspect = p_vout->render.i_aspect;
206 p_sys->p_vout->b_scale = p_vout->b_scale;
207 p_sys->p_vout->i_alignment = p_vout->i_alignment;
209 p_sys->p_vout->p_module =
210 module_Need( p_sys->p_vout, "opengl provider", NULL, 0 );
211 if( p_sys->p_vout->p_module == NULL )
213 msg_Warn( p_vout, "No OpenGL provider found" );
214 vlc_object_detach( p_sys->p_vout );
215 vlc_object_destroy( p_sys->p_vout );
219 p_sys->f_speed = var_CreateGetFloat( p_vout, "opengl-cube-speed" );
221 p_vout->pf_init = Init;
222 p_vout->pf_end = End;
223 p_vout->pf_manage = Manage;
224 p_vout->pf_render = Render;
225 p_vout->pf_display = DisplayVideo;
226 p_vout->pf_control = Control;
228 /* Forward events from the opengl provider */
229 var_Create( p_sys->p_vout, "mouse-x", VLC_VAR_INTEGER );
230 var_Create( p_sys->p_vout, "mouse-y", VLC_VAR_INTEGER );
231 var_Create( p_sys->p_vout, "mouse-moved", VLC_VAR_BOOL );
232 var_Create( p_sys->p_vout, "mouse-clicked", VLC_VAR_INTEGER );
233 var_Create( p_sys->p_vout, "video-on-top",
234 VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
236 var_AddCallback( p_sys->p_vout, "mouse-x", SendEvents, p_vout );
237 var_AddCallback( p_sys->p_vout, "mouse-y", SendEvents, p_vout );
238 var_AddCallback( p_sys->p_vout, "mouse-moved", SendEvents, p_vout );
239 var_AddCallback( p_sys->p_vout, "mouse-clicked", SendEvents, p_vout );
244 /*****************************************************************************
245 * Init: initialize the OpenGL video thread output method
246 *****************************************************************************/
247 static int Init( vout_thread_t *p_vout )
249 vout_sys_t *p_sys = p_vout->p_sys;
253 p_sys->p_vout->pf_init( p_sys->p_vout );
256 p_vout->output.i_chroma = VLC_FOURCC('Y','U','Y','2');
257 p_vout->output.i_rmask = 0x00ff0000;
258 p_vout->output.i_gmask = 0x0000ff00;
259 p_vout->output.i_bmask = 0x000000ff;
262 #if VLCGL_RGB_FORMAT == GL_RGB
263 # if VLCGL_RGB_TYPE == GL_UNSIGNED_BYTE
264 p_vout->output.i_chroma = VLC_FOURCC('R','V','2','4');
265 p_vout->output.i_rmask = 0x000000ff;
266 p_vout->output.i_gmask = 0x0000ff00;
267 p_vout->output.i_bmask = 0x00ff0000;
270 p_vout->output.i_chroma = VLC_FOURCC('R','V','1','6');
271 p_vout->output.i_rmask = 0xf800;
272 p_vout->output.i_gmask = 0x07e0;
273 p_vout->output.i_bmask = 0x001f;
277 p_vout->output.i_chroma = VLC_FOURCC('R','V','3','2');
278 p_vout->output.i_rmask = 0x000000ff;
279 p_vout->output.i_gmask = 0x0000ff00;
280 p_vout->output.i_bmask = 0x00ff0000;
285 /* Since OpenGL can do rescaling for us, stick to the default
286 * coordinates and aspect. */
287 p_vout->output.i_width = p_vout->render.i_width;
288 p_vout->output.i_height = p_vout->render.i_height;
289 p_vout->output.i_aspect = p_vout->render.i_aspect;
291 /* We know the chroma, allocate one buffer which will be used
292 * directly by the decoder */
293 p_sys->pp_buffer[0] =
294 malloc( p_sys->i_tex_width * p_sys->i_tex_height * i_pixel_pitch );
295 if( !p_sys->pp_buffer[0] )
297 msg_Err( p_vout, "Out of memory" );
300 p_sys->pp_buffer[1] =
301 malloc( p_sys->i_tex_width * p_sys->i_tex_height * i_pixel_pitch );
302 if( !p_sys->pp_buffer[1] )
304 msg_Err( p_vout, "Out of memory" );
308 p_vout->p_picture[0].i_planes = 1;
309 p_vout->p_picture[0].p->p_pixels = p_sys->pp_buffer[0];
310 p_vout->p_picture[0].p->i_lines = p_vout->output.i_height;
311 p_vout->p_picture[0].p->i_visible_lines = p_vout->output.i_height;
312 p_vout->p_picture[0].p->i_pixel_pitch = i_pixel_pitch;
313 p_vout->p_picture[0].p->i_pitch = p_vout->output.i_width *
314 p_vout->p_picture[0].p->i_pixel_pitch;
315 p_vout->p_picture[0].p->i_visible_pitch = p_vout->output.i_width *
316 p_vout->p_picture[0].p->i_pixel_pitch;
318 p_vout->p_picture[0].i_status = DESTROYED_PICTURE;
319 p_vout->p_picture[0].i_type = DIRECT_PICTURE;
321 PP_OUTPUTPICTURE[ 0 ] = &p_vout->p_picture[0];
323 I_OUTPUTPICTURES = 1;
325 if( p_sys->p_vout->pf_lock &&
326 p_sys->p_vout->pf_lock( p_sys->p_vout ) )
328 msg_Warn( p_vout, "could not lock OpenGL provider" );
332 InitTextures( p_vout );
335 glDisable(GL_DEPTH_TEST);
336 glDepthMask(GL_FALSE);
337 glDisable(GL_CULL_FACE);
338 glClear( GL_COLOR_BUFFER_BIT );
340 /* Check if the user asked for useless visual effects */
341 var_Get( p_vout, "opengl-effect", &val );
342 if( !val.psz_string || !strcmp( val.psz_string, "none" ))
344 p_sys->i_effect = OPENGL_EFFECT_NONE;
346 else if( !strcmp( val.psz_string, "cube" ) )
348 p_sys->i_effect = OPENGL_EFFECT_CUBE;
350 glEnable( GL_CULL_FACE);
351 //glEnable( GL_DEPTH_TEST );
353 else if( !strcmp( val.psz_string, "transparent-cube" ) )
355 p_sys->i_effect = OPENGL_EFFECT_TRANSPARENT_CUBE;
357 glDisable( GL_DEPTH_TEST );
358 glEnable( GL_BLEND );
359 glBlendFunc( GL_SRC_ALPHA, GL_ONE );
363 msg_Warn( p_vout, "no valid opengl effect provided, using "
365 p_sys->i_effect = OPENGL_EFFECT_NONE;
367 if( val.psz_string ) free( val.psz_string );
369 if( p_sys->i_effect & ( OPENGL_EFFECT_CUBE |
370 OPENGL_EFFECT_TRANSPARENT_CUBE ) )
372 /* Set the perpective */
373 glMatrixMode( GL_PROJECTION );
375 glFrustum( -1.0, 1.0, -1.0, 1.0, 3.0, 20.0 );
376 glMatrixMode( GL_MODELVIEW );
378 glTranslatef( 0.0, 0.0, - 5.0 );
381 if( p_sys->p_vout->pf_unlock )
383 p_sys->p_vout->pf_unlock( p_sys->p_vout );
389 /*****************************************************************************
390 * End: terminate GLX video thread output method
391 *****************************************************************************/
392 static void End( vout_thread_t *p_vout )
394 vout_sys_t *p_sys = p_vout->p_sys;
396 if( p_sys->p_vout->pf_lock &&
397 p_sys->p_vout->pf_lock( p_sys->p_vout ) )
399 msg_Warn( p_vout, "could not lock OpenGL provider" );
406 if( p_sys->p_vout->pf_unlock )
408 p_sys->p_vout->pf_unlock( p_sys->p_vout );
412 /*****************************************************************************
413 * Destroy: destroy GLX video thread output method
414 *****************************************************************************
415 * Terminate an output method created by CreateVout
416 *****************************************************************************/
417 static void DestroyVout( vlc_object_t *p_this )
419 vout_thread_t *p_vout = (vout_thread_t *)p_this;
420 vout_sys_t *p_sys = p_vout->p_sys;
422 module_Unneed( p_sys->p_vout, p_sys->p_vout->p_module );
423 vlc_object_detach( p_sys->p_vout );
424 vlc_object_destroy( p_sys->p_vout );
426 /* Free the texture buffer*/
427 if( p_sys->pp_buffer[0] ) free( p_sys->pp_buffer[0] );
428 if( p_sys->pp_buffer[1] ) free( p_sys->pp_buffer[1] );
433 /*****************************************************************************
434 * Manage: handle Sys events
435 *****************************************************************************
436 * This function should be called regularly by video output thread. It returns
437 * a non null value if an error occurred.
438 *****************************************************************************/
439 static int Manage( vout_thread_t *p_vout )
441 vout_sys_t *p_sys = p_vout->p_sys;
442 int i_ret, i_fullscreen_change;
444 i_fullscreen_change = ( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE );
446 p_sys->p_vout->i_changes = p_vout->i_changes;
447 i_ret = p_sys->p_vout->pf_manage( p_sys->p_vout );
448 p_vout->i_changes = p_sys->p_vout->i_changes;
451 if( p_sys->p_vout->pf_lock &&
452 p_sys->p_vout->pf_lock( p_sys->p_vout ) )
454 msg_Warn( p_vout, "could not lock OpenGL provider" );
458 /* On OS X, we create the window and the GL view when entering
459 fullscreen - the textures have to be inited again */
460 if( i_fullscreen_change )
462 InitTextures( p_vout );
464 switch( p_sys->i_effect )
466 case OPENGL_EFFECT_CUBE:
467 glEnable( GL_CULL_FACE );
470 case OPENGL_EFFECT_TRANSPARENT_CUBE:
471 glDisable( GL_DEPTH_TEST );
472 glEnable( GL_BLEND );
473 glBlendFunc( GL_SRC_ALPHA, GL_ONE );
477 if( p_sys->i_effect & ( OPENGL_EFFECT_CUBE |
478 OPENGL_EFFECT_TRANSPARENT_CUBE ) )
480 /* Set the perpective */
481 glMatrixMode( GL_PROJECTION );
483 glFrustum( -1.0, 1.0, -1.0, 1.0, 3.0, 20.0 );
484 glMatrixMode( GL_MODELVIEW );
486 glTranslatef( 0.0, 0.0, - 5.0 );
490 if( p_sys->p_vout->pf_unlock )
492 p_sys->p_vout->pf_unlock( p_sys->p_vout );
499 /*****************************************************************************
500 * Render: render previously calculated output
501 *****************************************************************************/
502 static void Render( vout_thread_t *p_vout, picture_t *p_pic )
504 vout_sys_t *p_sys = p_vout->p_sys;
506 /* On Win32/GLX, we do this the usual way:
507 + Fill the buffer with new content,
508 + Reload the texture,
511 On OS X with VRAM or AGP texturing, the order has to be:
512 + Reload the texture,
513 + Fill the buffer with new content,
516 (Thanks to gcc from the Arstechnica forums for the tip)
518 Therefore, we have to use two buffers and textures. On Win32/GLX,
519 we reload the texture to be displayed and use it right away. On
520 OS X, we first render, then reload the texture to be used next
523 if( p_sys->p_vout->pf_lock &&
524 p_sys->p_vout->pf_lock( p_sys->p_vout ) )
526 msg_Warn( p_vout, "could not lock OpenGL provider" );
532 i_new_index = ( p_sys->i_index + 1 ) & 1;
535 /* Update the texture */
536 glBindTexture( VLCGL_TARGET, p_sys->p_textures[i_new_index] );
537 glTexSubImage2D( VLCGL_TARGET, 0, 0, 0, p_sys->i_tex_width,
538 p_sys->i_tex_height, VLCGL_FORMAT, VLCGL_TYPE,
539 p_sys->pp_buffer[i_new_index] );
541 /* Bind to the previous texture for drawing */
542 glBindTexture( VLCGL_TARGET, p_sys->p_textures[p_sys->i_index] );
545 p_sys->i_index = i_new_index;
546 p_pic->p->p_pixels = p_sys->pp_buffer[p_sys->i_index];
549 /* Update the texture */
550 glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0,
551 p_vout->render.i_width, p_vout->render.i_height,
552 VLCGL_RGB_FORMAT, VLCGL_RGB_TYPE, p_sys->pp_buffer[0] );
555 if( p_sys->p_vout->pf_unlock )
557 p_sys->p_vout->pf_unlock( p_sys->p_vout );
561 /*****************************************************************************
562 * DisplayVideo: displays previously rendered output
563 *****************************************************************************/
564 static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic )
566 vout_sys_t *p_sys = p_vout->p_sys;
567 float f_width, f_height;
569 if( p_sys->p_vout->pf_lock &&
570 p_sys->p_vout->pf_lock( p_sys->p_vout ) )
572 msg_Warn( p_vout, "could not lock OpenGL provider" );
576 /* glTexCoord works differently with GL_TEXTURE_2D and
577 GL_TEXTURE_RECTANGLE_EXT */
579 f_width = (float)p_vout->output.i_width;
580 f_height = (float)p_vout->output.i_height;
582 f_width = (float)p_vout->output.i_width / p_sys->i_tex_width;
583 f_height = (float)p_vout->output.i_height / p_sys->i_tex_height;
586 /* Why drawing here and not in Render()? Because this way, the
587 OpenGL providers can call pf_display to force redraw. Currently,
588 the OS X provider uses it to get a smooth window resizing */
590 glClear( GL_COLOR_BUFFER_BIT );
592 if( p_sys->i_effect == OPENGL_EFFECT_NONE )
594 glEnable( VLCGL_TARGET );
595 glBegin( GL_POLYGON );
596 glTexCoord2f( 0.5, 0.5 ); glVertex2f( -1.0, 1.0 );
597 glTexCoord2f( f_width - 0.5, 0.5 ); glVertex2f( 1.0, 1.0 );
598 glTexCoord2f( f_width - 0.5, f_height - 0.5 ); glVertex2f( 1.0, -1.0 );
599 glTexCoord2f( 0.5, f_height - 0.5 ); glVertex2f( -1.0, -1.0 );
604 glRotatef( 0.5 * p_sys->f_speed , 0.3, 0.5, 0.7 );
606 glEnable( VLCGL_TARGET );
610 glTexCoord2f( 0.5, 0.5 ); glVertex3f( - 1.0, 1.0, 1.0 );
611 glTexCoord2f( 0.5, f_height - 0.5 ); glVertex3f( - 1.0, - 1.0, 1.0 );
612 glTexCoord2f( f_width - 0.5, f_height - 0.5 ); glVertex3f( 1.0, - 1.0, 1.0 );
613 glTexCoord2f( f_width - 0.5, 0.5 ); glVertex3f( 1.0, 1.0, 1.0 );
616 glTexCoord2f( 0.5, 0.5 ); glVertex3f( - 1.0, 1.0, - 1.0 );
617 glTexCoord2f( 0.5, f_height - 0.5 ); glVertex3f( - 1.0, - 1.0, - 1.0 );
618 glTexCoord2f( f_width - 0.5, f_height - 0.5 ); glVertex3f( - 1.0, - 1.0, 1.0 );
619 glTexCoord2f( f_width - 0.5, 0.5 ); glVertex3f( - 1.0, 1.0, 1.0 );
622 glTexCoord2f( 0.5, 0.5 ); glVertex3f( 1.0, 1.0, - 1.0 );
623 glTexCoord2f( 0.5, f_height - 0.5 ); glVertex3f( 1.0, - 1.0, - 1.0 );
624 glTexCoord2f( f_width - 0.5, f_height - 0.5 ); glVertex3f( - 1.0, - 1.0, - 1.0 );
625 glTexCoord2f( f_width - 0.5, 0.5 ); glVertex3f( - 1.0, 1.0, - 1.0 );
628 glTexCoord2f( 0.5, 0.5 ); glVertex3f( 1.0, 1.0, 1.0 );
629 glTexCoord2f( 0.5, f_height - 0.5 ); glVertex3f( 1.0, - 1.0, 1.0 );
630 glTexCoord2f( f_width - 0.5, f_height - 0.5 ); glVertex3f( 1.0, - 1.0, - 1.0 );
631 glTexCoord2f( f_width - 0.5, 0.5 ); glVertex3f( 1.0, 1.0, - 1.0 );
634 glTexCoord2f( 0.5, 0.5 ); glVertex3f( - 1.0, 1.0, - 1.0 );
635 glTexCoord2f( 0.5, f_height - 0.5 ); glVertex3f( - 1.0, 1.0, 1.0 );
636 glTexCoord2f( f_width - 0.5, f_height - 0.5 ); glVertex3f( 1.0, 1.0, 1.0 );
637 glTexCoord2f( 0.5, f_height - 0.5 ); glVertex3f( - 1.0, - 1.0, - 1.0 );
638 glTexCoord2f( f_width - 0.5, f_height - 0.5 ); glVertex3f( 1.0, - 1.0, - 1.0 );
639 glTexCoord2f( f_width - 0.5, 0.5 ); glVertex3f( 1.0, - 1.0, 1.0 );
643 glDisable( VLCGL_TARGET );
645 p_sys->p_vout->pf_swap( p_sys->p_vout );
647 if( p_sys->p_vout->pf_unlock )
649 p_sys->p_vout->pf_unlock( p_sys->p_vout );
653 int GetAlignedSize( int i_size )
655 /* Return the nearest power of 2 */
657 while( i_result < i_size )
664 /*****************************************************************************
665 * Control: control facility for the vout
666 *****************************************************************************/
667 static int Control( vout_thread_t *p_vout, int i_query, va_list args )
669 vout_sys_t *p_sys = p_vout->p_sys;
674 return vout_vaControlDefault( p_vout, i_query, args );
677 if( p_sys->p_vout->pf_control )
678 return p_sys->p_vout->pf_control( p_sys->p_vout, i_query, args );
680 return vout_vaControlDefault( p_vout, i_query, args );
684 static int InitTextures( vout_thread_t *p_vout )
686 vout_sys_t *p_sys = p_vout->p_sys;
689 glDeleteTextures( 2, p_sys->p_textures );
690 glGenTextures( 2, p_sys->p_textures );
692 for( i_index = 0; i_index < 2; i_index++ )
694 glBindTexture( VLCGL_TARGET, p_sys->p_textures[i_index] );
696 /* Set the texture parameters */
697 glTexParameterf( VLCGL_TARGET, GL_TEXTURE_PRIORITY, 1.0 );
699 glTexParameteri( VLCGL_TARGET, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
700 glTexParameteri( VLCGL_TARGET, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
702 glTexParameteri( VLCGL_TARGET, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
703 glTexParameteri( VLCGL_TARGET, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
705 glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
708 /* Tell the driver not to make a copy of the texture but to use
710 glEnable( GL_UNPACK_CLIENT_STORAGE_APPLE );
711 glPixelStorei( GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE );
714 /* Use VRAM texturing */
715 glTexParameteri( VLCGL_TARGET, GL_TEXTURE_STORAGE_HINT_APPLE,
716 GL_STORAGE_CACHED_APPLE );
718 /* Use AGP texturing */
719 glTexParameteri( VLCGL_TARGET, GL_TEXTURE_STORAGE_HINT_APPLE,
720 GL_STORAGE_SHARED_APPLE );
724 /* Call glTexImage2D only once, and use glTexSubImage2D later */
725 glTexImage2D( VLCGL_TARGET, 0, 3, p_sys->i_tex_width,
726 p_sys->i_tex_height, 0, VLCGL_FORMAT, VLCGL_TYPE,
727 p_sys->pp_buffer[i_index] );
733 /*****************************************************************************
734 * SendEvents: forward mouse and keyboard events to the parent p_vout
735 *****************************************************************************/
736 static int SendEvents( vlc_object_t *p_this, char const *psz_var,
737 vlc_value_t oldval, vlc_value_t newval, void *_p_vout )
739 return var_Set( (vlc_object_t *)_p_vout, psz_var, newval );