1 /*****************************************************************************
2 * opengl.c: OpenGL video output
3 *****************************************************************************
4 * Copyright (C) 2004 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@videolan.org>
8 * Gildas Bazin <gbazin@videolan.org>
9 * Eric Petit <titer@m0k.org>
10 * Cedric Cocquebert <cedric.cocquebert@supelec.fr>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
27 /*****************************************************************************
29 *****************************************************************************/
35 #include <errno.h> /* ENOMEM */
37 #include <vlc_common.h>
38 #include <vlc_plugin.h>
42 #include <OpenGL/gl.h>
43 #include <OpenGL/glext.h>
45 /* On OS X, use GL_TEXTURE_RECTANGLE_EXT instead of GL_TEXTURE_2D.
46 This allows sizes which are not powers of 2 */
47 #define VLCGL_TARGET GL_TEXTURE_RECTANGLE_EXT
49 /* OS X OpenGL supports YUV. Hehe. */
50 #define VLCGL_FORMAT GL_YCBCR_422_APPLE
51 #define VLCGL_TYPE GL_UNSIGNED_SHORT_8_8_APPLE
55 #define VLCGL_TARGET GL_TEXTURE_2D
58 #ifndef GL_UNSIGNED_SHORT_5_6_5
59 #define GL_UNSIGNED_SHORT_5_6_5 0x8363
61 //#define VLCGL_RGB_FORMAT GL_RGB
62 //#define VLCGL_RGB_TYPE GL_UNSIGNED_SHORT_5_6_5
65 //#define VLCGL_RGB_FORMAT GL_RGB
66 //#define VLCGL_RGB_TYPE GL_UNSIGNED_BYTE
69 #define VLCGL_RGB_FORMAT GL_RGBA
70 #define VLCGL_RGB_TYPE GL_UNSIGNED_BYTE
74 #define YCBCR_MESA 0x8757
76 #ifndef UNSIGNED_SHORT_8_8_MESA
77 #define UNSIGNED_SHORT_8_8_MESA 0x85BA
79 #define VLCGL_YUV_FORMAT YCBCR_MESA
80 #define VLCGL_YUV_TYPE UNSIGNED_SHORT_8_8_MESA
82 /* Use RGB on Win32/GLX */
83 #define VLCGL_FORMAT VLCGL_RGB_FORMAT
84 #define VLCGL_TYPE VLCGL_RGB_TYPE
85 //#define VLCGL_FORMAT VLCGL_YUV_FORMAT
86 //#define VLCGL_TYPE VLCGL_YUV_TYPE
89 #ifndef GL_CLAMP_TO_EDGE
90 # define GL_CLAMP_TO_EDGE 0x812F
93 /*****************************************************************************
95 *****************************************************************************/
96 static int CreateVout ( vlc_object_t * );
97 static void DestroyVout ( vlc_object_t * );
98 static int Init ( vout_thread_t * );
99 static void End ( vout_thread_t * );
100 static int Manage ( vout_thread_t * );
101 static void Render ( vout_thread_t *, picture_t * );
102 static void DisplayVideo ( vout_thread_t *, picture_t * );
103 static int Control ( vout_thread_t *, int, va_list );
105 static inline int GetAlignedSize( int );
107 static int InitTextures ( vout_thread_t * );
108 static int SendEvents ( vlc_object_t *, char const *,
109 vlc_value_t, vlc_value_t, void * );
111 #define PROVIDER_TEXT N_("OpenGL Provider")
112 #define PROVIDER_LONGTEXT N_("Allows you to modify what OpenGL provider should be used")
115 set_shortname( "OpenGL" )
116 set_category( CAT_VIDEO )
117 set_subcategory( SUBCAT_VIDEO_VOUT )
118 set_description( N_("OpenGL video output") )
120 set_capability( "video output", 200 )
122 set_capability( "video output", 20 )
124 add_shortcut( "opengl" )
125 /* Allow opengl provider plugin selection */
126 add_module( "opengl-provider", "opengl provider", NULL, NULL,
127 PROVIDER_TEXT, PROVIDER_LONGTEXT, true )
128 set_callbacks( CreateVout, DestroyVout )
131 /*****************************************************************************
132 * vout_sys_t: video output method descriptor
133 *****************************************************************************
134 * This structure is part of the video output thread descriptor.
135 * It describes the OpenGL specific properties of the output thread.
136 *****************************************************************************/
139 vout_thread_t *p_vout;
141 uint8_t *pp_buffer[2];
145 GLuint p_textures[2];
148 /*****************************************************************************
149 * CreateVout: This function allocates and initializes the OpenGL vout method.
150 *****************************************************************************/
151 static int CreateVout( vlc_object_t *p_this )
153 vout_thread_t *p_vout = (vout_thread_t *)p_this;
157 /* Allocate structure */
158 p_vout->p_sys = p_sys = malloc( sizeof( vout_sys_t ) );
164 p_sys->i_tex_width = p_vout->fmt_in.i_width;
165 p_sys->i_tex_height = p_vout->fmt_in.i_height;
167 /* A texture must have a size aligned on a power of 2 */
168 p_sys->i_tex_width = GetAlignedSize( p_vout->fmt_in.i_width );
169 p_sys->i_tex_height = GetAlignedSize( p_vout->fmt_in.i_height );
172 msg_Dbg( p_vout, "Texture size: %dx%d", p_sys->i_tex_width,
173 p_sys->i_tex_height );
177 (vout_thread_t *)vlc_object_create( p_this, sizeof( vout_thread_t ) );
178 if( p_sys->p_vout == NULL )
183 vlc_object_attach( p_sys->p_vout, p_this );
185 p_sys->p_vout->i_window_width = p_vout->i_window_width;
186 p_sys->p_vout->i_window_height = p_vout->i_window_height;
187 p_sys->p_vout->b_fullscreen = p_vout->b_fullscreen;
188 p_sys->p_vout->render.i_width = p_vout->render.i_width;
189 p_sys->p_vout->render.i_height = p_vout->render.i_height;
190 p_sys->p_vout->render.i_aspect = p_vout->render.i_aspect;
191 p_sys->p_vout->fmt_render = p_vout->fmt_render;
192 p_sys->p_vout->fmt_in = p_vout->fmt_in;
193 p_sys->p_vout->b_autoscale = p_vout->b_autoscale;
194 p_sys->p_vout->i_zoom = p_vout->i_zoom;
195 p_sys->p_vout->i_alignment = p_vout->i_alignment;
196 var_Create( p_sys->p_vout, "video-deco",
197 VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
199 /* Forward events from the opengl provider */
200 var_Create( p_sys->p_vout, "mouse-x", VLC_VAR_INTEGER );
201 var_Create( p_sys->p_vout, "mouse-y", VLC_VAR_INTEGER );
202 var_Create( p_sys->p_vout, "mouse-moved", VLC_VAR_BOOL );
203 var_Create( p_sys->p_vout, "mouse-clicked", VLC_VAR_BOOL );
204 var_Create( p_sys->p_vout, "mouse-button-down", VLC_VAR_INTEGER );
205 var_Create( p_sys->p_vout, "video-on-top",
206 VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
207 var_Create( p_sys->p_vout, "autoscale",
208 VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
209 var_Create( p_sys->p_vout, "scale",
210 VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
212 var_AddCallback( p_sys->p_vout, "mouse-x", SendEvents, p_vout );
213 var_AddCallback( p_sys->p_vout, "mouse-y", SendEvents, p_vout );
214 var_AddCallback( p_sys->p_vout, "mouse-moved", SendEvents, p_vout );
215 var_AddCallback( p_sys->p_vout, "mouse-clicked", SendEvents, p_vout );
216 var_AddCallback( p_sys->p_vout, "mouse-button-down", SendEvents, p_vout );
217 var_AddCallback( p_sys->p_vout, "video-on-top", SendEvents, p_vout );
218 var_AddCallback( p_vout, "autoscale", SendEvents, p_sys->p_vout );
219 var_AddCallback( p_vout, "scale", SendEvents, p_sys->p_vout );
221 psz = var_CreateGetString( p_vout, "opengl-provider" );
222 p_sys->p_vout->p_module =
223 module_need( p_sys->p_vout, "opengl provider", psz, false );
225 if( p_sys->p_vout->p_module == NULL )
227 msg_Warn( p_vout, "No OpenGL provider found" );
228 vlc_object_detach( p_sys->p_vout );
229 /* no need for var_DelCallback here :-) */
230 vlc_object_release( p_sys->p_vout );
235 p_vout->pf_init = Init;
236 p_vout->pf_end = End;
237 p_vout->pf_manage = Manage;
238 p_vout->pf_render = Render;
239 p_vout->pf_display = DisplayVideo;
240 p_vout->pf_control = Control;
245 /*****************************************************************************
246 * Init: initialize the OpenGL video thread output method
247 *****************************************************************************/
248 static int Init( vout_thread_t *p_vout )
250 vout_sys_t *p_sys = p_vout->p_sys;
253 p_sys->p_vout->pf_init( p_sys->p_vout );
255 /* TODO: We use YCbCr on Mac which is Y422, but on OSX it seems to == YUY2. Verify */
256 #if ( defined( WORDS_BIGENDIAN ) && VLCGL_FORMAT == GL_YCBCR_422_APPLE ) || (VLCGL_FORMAT == YCBCR_MESA)
257 p_vout->output.i_chroma = VLC_CODEC_YUYV;
260 #elif (VLCGL_FORMAT == GL_YCBCR_422_APPLE)
261 p_vout->output.i_chroma = VLC_CODEC_UYVY;
264 #elif VLCGL_FORMAT == GL_RGB
265 # if VLCGL_TYPE == GL_UNSIGNED_BYTE
266 p_vout->output.i_chroma = VLC_CODEC_RGB24;
267 # if defined( WORDS_BIGENDIAN )
268 p_vout->output.i_rmask = 0x00ff0000;
269 p_vout->output.i_gmask = 0x0000ff00;
270 p_vout->output.i_bmask = 0x000000ff;
272 p_vout->output.i_rmask = 0x000000ff;
273 p_vout->output.i_gmask = 0x0000ff00;
274 p_vout->output.i_bmask = 0x00ff0000;
278 p_vout->output.i_chroma = VLC_CODEC_RGB16;
279 # if defined( WORDS_BIGENDIAN )
280 p_vout->output.i_rmask = 0x001f;
281 p_vout->output.i_gmask = 0x07e0;
282 p_vout->output.i_bmask = 0xf800;
284 p_vout->output.i_rmask = 0xf800;
285 p_vout->output.i_gmask = 0x07e0;
286 p_vout->output.i_bmask = 0x001f;
291 p_vout->output.i_chroma = VLC_CODEC_RGB32;
292 # if defined( WORDS_BIGENDIAN )
293 p_vout->output.i_rmask = 0xff000000;
294 p_vout->output.i_gmask = 0x00ff0000;
295 p_vout->output.i_bmask = 0x0000ff00;
297 p_vout->output.i_rmask = 0x000000ff;
298 p_vout->output.i_gmask = 0x0000ff00;
299 p_vout->output.i_bmask = 0x00ff0000;
304 /* Since OpenGL can do rescaling for us, stick to the default
305 * coordinates and aspect. */
306 p_vout->output.i_width = p_vout->render.i_width;
307 p_vout->output.i_height = p_vout->render.i_height;
308 p_vout->output.i_aspect = p_vout->render.i_aspect;
310 p_vout->fmt_out = p_vout->fmt_in;
311 p_vout->fmt_out.i_chroma = p_vout->output.i_chroma;
313 /* We know the chroma, allocate one buffer which will be used
314 * directly by the decoder */
315 p_sys->pp_buffer[0] =
316 malloc( p_sys->i_tex_width * p_sys->i_tex_height * i_pixel_pitch );
317 if( !p_sys->pp_buffer[0] )
319 p_sys->pp_buffer[1] =
320 malloc( p_sys->i_tex_width * p_sys->i_tex_height * i_pixel_pitch );
321 if( !p_sys->pp_buffer[1] )
324 p_vout->p_picture[0].i_planes = 1;
325 p_vout->p_picture[0].p->p_pixels = p_sys->pp_buffer[0];
326 p_vout->p_picture[0].p->i_lines = p_vout->output.i_height;
327 p_vout->p_picture[0].p->i_visible_lines = p_vout->output.i_height;
328 p_vout->p_picture[0].p->i_pixel_pitch = i_pixel_pitch;
329 p_vout->p_picture[0].p->i_pitch = p_vout->output.i_width *
330 p_vout->p_picture[0].p->i_pixel_pitch;
331 p_vout->p_picture[0].p->i_visible_pitch = p_vout->output.i_width *
332 p_vout->p_picture[0].p->i_pixel_pitch;
334 p_vout->p_picture[0].i_status = DESTROYED_PICTURE;
335 p_vout->p_picture[0].i_type = DIRECT_PICTURE;
337 PP_OUTPUTPICTURE[ 0 ] = &p_vout->p_picture[0];
339 I_OUTPUTPICTURES = 1;
341 if( p_sys->p_vout->pf_lock &&
342 p_sys->p_vout->pf_lock( p_sys->p_vout ) )
344 msg_Warn( p_vout, "could not lock OpenGL provider" );
348 InitTextures( p_vout );
351 glDisable(GL_DEPTH_TEST);
352 glDepthMask(GL_FALSE);
353 glDisable(GL_CULL_FACE);
354 glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
355 glClear( GL_COLOR_BUFFER_BIT );
357 if( p_sys->p_vout->pf_unlock )
359 p_sys->p_vout->pf_unlock( p_sys->p_vout );
365 /*****************************************************************************
366 * End: terminate GLX video thread output method
367 *****************************************************************************/
368 static void End( vout_thread_t *p_vout )
370 vout_sys_t *p_sys = p_vout->p_sys;
372 if( p_sys->p_vout->pf_lock &&
373 p_sys->p_vout->pf_lock( p_sys->p_vout ) )
375 msg_Warn( p_vout, "could not lock OpenGL provider" );
382 /* Free the texture buffer*/
383 glDeleteTextures( 2, p_sys->p_textures );
384 free( p_sys->pp_buffer[0] );
385 free( p_sys->pp_buffer[1] );
387 if( p_sys->p_vout->pf_unlock )
389 p_sys->p_vout->pf_unlock( p_sys->p_vout );
393 /*****************************************************************************
394 * Destroy: destroy GLX video thread output method
395 *****************************************************************************
396 * Terminate an output method created by CreateVout
397 *****************************************************************************/
398 static void DestroyVout( vlc_object_t *p_this )
400 vout_thread_t *p_vout = (vout_thread_t *)p_this;
401 vout_sys_t *p_sys = p_vout->p_sys;
403 module_unneed( p_sys->p_vout, p_sys->p_vout->p_module );
404 vlc_object_release( p_sys->p_vout );
409 /*****************************************************************************
410 * Manage: handle Sys events
411 *****************************************************************************
412 * This function should be called regularly by video output thread. It returns
413 * a non null value if an error occurred.
414 *****************************************************************************/
415 static int Manage( vout_thread_t *p_vout )
417 vout_sys_t *p_sys = p_vout->p_sys;
418 int i_ret, i_fullscreen_change;
420 i_fullscreen_change = ( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE );
422 p_vout->fmt_out.i_x_offset = p_sys->p_vout->fmt_in.i_x_offset =
423 p_vout->fmt_in.i_x_offset;
424 p_vout->fmt_out.i_y_offset = p_sys->p_vout->fmt_in.i_y_offset =
425 p_vout->fmt_in.i_y_offset;
426 p_vout->fmt_out.i_visible_width = p_sys->p_vout->fmt_in.i_visible_width =
427 p_vout->fmt_in.i_visible_width;
428 p_vout->fmt_out.i_visible_height = p_sys->p_vout->fmt_in.i_visible_height =
429 p_vout->fmt_in.i_visible_height;
430 p_vout->fmt_out.i_aspect = p_sys->p_vout->fmt_in.i_aspect =
431 p_vout->fmt_in.i_aspect;
432 p_vout->fmt_out.i_sar_num = p_sys->p_vout->fmt_in.i_sar_num =
433 p_vout->fmt_in.i_sar_num;
434 p_vout->fmt_out.i_sar_den = p_sys->p_vout->fmt_in.i_sar_den =
435 p_vout->fmt_in.i_sar_den;
436 p_vout->output.i_aspect = p_vout->fmt_in.i_aspect;
438 p_sys->p_vout->i_changes = p_vout->i_changes;
439 i_ret = p_sys->p_vout->pf_manage( p_sys->p_vout );
440 p_vout->i_changes = p_sys->p_vout->i_changes;
443 if( p_sys->p_vout->pf_lock &&
444 p_sys->p_vout->pf_lock( p_sys->p_vout ) )
446 msg_Warn( p_vout, "could not lock OpenGL provider" );
450 /* On OS X, we create the window and the GL view when entering
451 fullscreen - the textures have to be inited again */
452 if( i_fullscreen_change )
454 InitTextures( p_vout );
457 if( p_sys->p_vout->pf_unlock )
459 p_sys->p_vout->pf_unlock( p_sys->p_vout );
462 // to align in real time in OPENGL
463 if (p_sys->p_vout->i_alignment != p_vout->i_alignment)
465 p_vout->i_changes |= VOUT_CROP_CHANGE; //to force change
466 p_sys->p_vout->i_alignment = p_vout->i_alignment;
469 /* forward signal that autoscale toggle has changed */
470 if (p_vout->i_changes & VOUT_SCALE_CHANGE )
472 p_vout->i_changes &= ~VOUT_SCALE_CHANGE;
474 p_sys->p_vout->i_changes |= VOUT_SCALE_CHANGE;
477 /* forward signal that scale has changed */
478 if (p_vout->i_changes & VOUT_ZOOM_CHANGE )
480 p_vout->i_changes &= ~VOUT_ZOOM_CHANGE;
482 p_sys->p_vout->i_changes |= VOUT_ZOOM_CHANGE;
489 /*****************************************************************************
490 * Render: render previously calculated output
491 *****************************************************************************/
492 static void Render( vout_thread_t *p_vout, picture_t *p_pic )
495 vout_sys_t *p_sys = p_vout->p_sys;
497 /* On Win32/GLX, we do this the usual way:
498 + Fill the buffer with new content,
499 + Reload the texture,
502 On OS X with VRAM or AGP texturing, the order has to be:
503 + Reload the texture,
504 + Fill the buffer with new content,
507 (Thanks to gcc from the Arstechnica forums for the tip)
509 Therefore, we have to use two buffers and textures. On Win32/GLX,
510 we reload the texture to be displayed and use it right away. On
511 OS X, we first render, then reload the texture to be used next
514 if( p_sys->p_vout->pf_lock &&
515 p_sys->p_vout->pf_lock( p_sys->p_vout ) )
517 msg_Warn( p_vout, "could not lock OpenGL provider" );
523 i_new_index = ( p_sys->i_index + 1 ) & 1;
526 /* Update the texture */
527 glBindTexture( VLCGL_TARGET, p_sys->p_textures[i_new_index] );
528 glTexSubImage2D( VLCGL_TARGET, 0, 0, 0,
529 p_vout->fmt_out.i_width,
530 p_vout->fmt_out.i_height,
531 VLCGL_FORMAT, VLCGL_TYPE, p_sys->pp_buffer[i_new_index] );
533 /* Bind to the previous texture for drawing */
534 glBindTexture( VLCGL_TARGET, p_sys->p_textures[p_sys->i_index] );
537 p_sys->i_index = i_new_index;
538 p_pic->p->p_pixels = p_sys->pp_buffer[p_sys->i_index];
541 /* Update the texture */
542 glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0,
543 p_vout->fmt_out.i_width,
544 p_vout->fmt_out.i_height,
545 VLCGL_FORMAT, VLCGL_TYPE, p_sys->pp_buffer[0] );
548 if( p_sys->p_vout->pf_unlock )
550 p_sys->p_vout->pf_unlock( p_sys->p_vout );
554 /*****************************************************************************
555 * DisplayVideo: displays previously rendered output
556 *****************************************************************************/
557 static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic )
560 vout_sys_t *p_sys = p_vout->p_sys;
561 float f_width, f_height, f_x, f_y;
563 if( p_sys->p_vout->pf_lock &&
564 p_sys->p_vout->pf_lock( p_sys->p_vout ) )
566 msg_Warn( p_vout, "could not lock OpenGL provider" );
570 /* glTexCoord works differently with GL_TEXTURE_2D and
571 GL_TEXTURE_RECTANGLE_EXT */
573 f_x = (float)p_vout->fmt_out.i_x_offset;
574 f_y = (float)p_vout->fmt_out.i_y_offset;
575 f_width = (float)p_vout->fmt_out.i_x_offset +
576 (float)p_vout->fmt_out.i_visible_width;
577 f_height = (float)p_vout->fmt_out.i_y_offset +
578 (float)p_vout->fmt_out.i_visible_height;
580 f_x = (float)p_vout->fmt_out.i_x_offset / p_sys->i_tex_width;
581 f_y = (float)p_vout->fmt_out.i_y_offset / p_sys->i_tex_height;
582 f_width = ( (float)p_vout->fmt_out.i_x_offset +
583 p_vout->fmt_out.i_visible_width ) / p_sys->i_tex_width;
584 f_height = ( (float)p_vout->fmt_out.i_y_offset +
585 p_vout->fmt_out.i_visible_height ) / p_sys->i_tex_height;
588 /* Why drawing here and not in Render()? Because this way, the
589 OpenGL providers can call pf_display to force redraw. Currently,
590 the OS X provider uses it to get a smooth window resizing */
592 glClear( GL_COLOR_BUFFER_BIT );
594 glEnable( VLCGL_TARGET );
595 glBegin( GL_POLYGON );
596 glTexCoord2f( f_x, f_y ); glVertex2f( -1.0, 1.0 );
597 glTexCoord2f( f_width, f_y ); glVertex2f( 1.0, 1.0 );
598 glTexCoord2f( f_width, f_height ); glVertex2f( 1.0, -1.0 );
599 glTexCoord2f( f_x, f_height ); glVertex2f( -1.0, -1.0 );
602 glDisable( VLCGL_TARGET );
604 p_sys->p_vout->pf_swap( p_sys->p_vout );
606 if( p_sys->p_vout->pf_unlock )
608 p_sys->p_vout->pf_unlock( p_sys->p_vout );
612 int GetAlignedSize( int i_size )
614 /* Return the nearest power of 2 */
616 while( i_result < i_size )
623 /*****************************************************************************
624 * Control: control facility for the vout
625 *****************************************************************************/
626 static int Control( vout_thread_t *p_vout, int i_query, va_list args )
628 vout_sys_t *p_sys = p_vout->p_sys;
630 if( p_sys->p_vout->pf_control )
631 return p_sys->p_vout->pf_control( p_sys->p_vout, i_query, args );
635 static int InitTextures( vout_thread_t *p_vout )
637 vout_sys_t *p_sys = p_vout->p_sys;
640 glDeleteTextures( 2, p_sys->p_textures );
641 glGenTextures( 2, p_sys->p_textures );
643 for( i_index = 0; i_index < 2; i_index++ )
645 glBindTexture( VLCGL_TARGET, p_sys->p_textures[i_index] );
647 /* Set the texture parameters */
648 glTexParameterf( VLCGL_TARGET, GL_TEXTURE_PRIORITY, 1.0 );
650 glTexParameteri( VLCGL_TARGET, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
651 glTexParameteri( VLCGL_TARGET, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
653 glTexParameteri( VLCGL_TARGET, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
654 glTexParameteri( VLCGL_TARGET, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
656 glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
659 /* Tell the driver not to make a copy of the texture but to use
661 glEnable( GL_UNPACK_CLIENT_STORAGE_APPLE );
662 glPixelStorei( GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE );
665 /* Use VRAM texturing */
666 glTexParameteri( VLCGL_TARGET, GL_TEXTURE_STORAGE_HINT_APPLE,
667 GL_STORAGE_CACHED_APPLE );
669 /* Use AGP texturing */
670 glTexParameteri( VLCGL_TARGET, GL_TEXTURE_STORAGE_HINT_APPLE,
671 GL_STORAGE_SHARED_APPLE );
675 /* Call glTexImage2D only once, and use glTexSubImage2D later */
676 glTexImage2D( VLCGL_TARGET, 0, 3, p_sys->i_tex_width,
677 p_sys->i_tex_height, 0, VLCGL_FORMAT, VLCGL_TYPE,
678 p_sys->pp_buffer[i_index] );
684 /*****************************************************************************
685 * SendEvents: forward mouse and keyboard events to the parent p_vout
686 *****************************************************************************/
687 static int SendEvents( vlc_object_t *p_this, char const *psz_var,
688 vlc_value_t oldval, vlc_value_t newval, void *_p_vout )
690 VLC_UNUSED(p_this); VLC_UNUSED(oldval);
691 return var_Set( (vlc_object_t *)_p_vout, psz_var, newval );