1 /*****************************************************************************
2 * glx.c: GLX video output
3 *****************************************************************************
4 * Copyright (C) 2004 VideoLAN
7 * Authors: Cyril Deguet <asmax@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <errno.h> /* ENOMEM */
28 #include <stdlib.h> /* malloc(), free() */
35 /* For the opengl provider interface */
36 #include "vlc_opengl.h"
39 #include <X11/Xutil.h>
43 /* Data common to vout and opengl provider structures */
58 /*****************************************************************************
60 *****************************************************************************/
61 static int CreateVout ( vlc_object_t * );
62 static void DestroyVout ( vlc_object_t * );
63 static int Init ( vout_thread_t * );
64 static void End ( vout_thread_t * );
65 static int Manage ( vout_thread_t * );
66 static void Render ( vout_thread_t *p_vout, picture_t *p_pic );
67 static void DisplayVideo ( vout_thread_t *, picture_t * );
69 /*****************************************************************************
70 * OpenGL providerinterface
71 *****************************************************************************/
72 static int CreateOpenGL ( vlc_object_t * );
73 static void DestroyOpenGL( vlc_object_t * );
74 static int InitOpenGL ( opengl_t *, int, int );
75 static void SwapBuffers ( opengl_t * );
76 static int HandleEvents ( opengl_t * );
78 /*****************************************************************************
80 *****************************************************************************/
81 static int OpenDisplay ( vlc_object_t *, glx_t * );
82 static void CloseDisplay( glx_t * );
83 static int InitGLX12 ( vlc_object_t *, glx_t * );
84 static int InitGLX13 ( vlc_object_t *, glx_t * );
85 static void CreateWindow( vlc_object_t *, glx_t *, XVisualInfo *);
86 static int HandleX11Events( vlc_object_t *, glx_t * );
87 static void SwitchContext( glx_t * );
89 static inline int GetAlignedSize( int i_size );
91 /*****************************************************************************
93 *****************************************************************************/
95 set_description( _("X11 OpenGL (GLX) video output") );
96 set_capability( "video output", 20 );
97 add_shortcut( "glx" );
98 set_callbacks( CreateVout, DestroyVout );
101 set_description( _("X11 OpenGL provider") );
102 set_capability( "opengl provider", 50 );
103 set_callbacks( CreateOpenGL, DestroyOpenGL );
107 /*****************************************************************************
108 * vout_sys_t: GLX video output method descriptor
109 *****************************************************************************
110 * This structure is part of the video output thread descriptor.
111 * It describes the GLX specific properties of an output thread.
112 *****************************************************************************/
131 #define MWM_HINTS_DECORATIONS (1L << 1)
132 #define PROP_MWM_HINTS_ELEMENTS 5
133 typedef struct mwmhints_t
137 uint32_t decorations;
143 /*****************************************************************************
144 * CreateVout: allocates GLX video thread output method
145 *****************************************************************************
146 * This function allocates and initializes a GLX vout method.
147 *****************************************************************************/
148 static int CreateVout( vlc_object_t *p_this )
150 vout_thread_t *p_vout = (vout_thread_t *)p_this;
152 /* Allocate structure */
153 p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
154 if( p_vout->p_sys == NULL )
156 msg_Err( p_vout, "out of memory" );
160 //XXX set to 0 to disable the cube effect
161 p_vout->p_sys->i_effect = 1;
163 /* p_vout->p_sys->glx.i_width = p_vout->i_window_width;
164 p_vout->p_sys->glx.i_height = p_vout->i_window_height; */
165 p_vout->p_sys->glx.i_width = 700;
166 p_vout->p_sys->glx.i_height = 700;
167 p_vout->p_sys->glx.b_fullscreen = 0;
169 /* A texture must have a size aligned on a power of 2 */
170 p_vout->p_sys->i_tex_width = GetAlignedSize( p_vout->render.i_width );
171 p_vout->p_sys->i_tex_height = GetAlignedSize( p_vout->render.i_height );
173 msg_Dbg( p_vout, "Texture size: %dx%d", p_vout->p_sys->i_tex_width,
174 p_vout->p_sys->i_tex_height );
176 /* Open and initialize device */
177 if( OpenDisplay( p_this, &p_vout->p_sys->glx ) )
179 msg_Err( p_vout, "cannot open display" );
180 free( p_vout->p_sys );
184 p_vout->pf_init = Init;
185 p_vout->pf_end = End;
186 p_vout->pf_manage = Manage;
187 p_vout->pf_render = Render;
188 p_vout->pf_display = DisplayVideo;
193 /*****************************************************************************
194 * Init: initialize GLX video thread output method
195 *****************************************************************************/
196 static int Init( vout_thread_t *p_vout )
201 /* No YUV textures :( */
202 p_vout->output.i_chroma = VLC_FOURCC('R','V','3','2');
203 p_vout->output.i_rmask = 0x000000ff;
204 p_vout->output.i_gmask = 0x0000ff00;
205 p_vout->output.i_bmask = 0x00ff0000;
207 p_vout->output.i_width = p_vout->render.i_width;
208 p_vout->output.i_height = p_vout->render.i_height;
209 p_vout->output.i_aspect = p_vout->render.i_aspect;
211 I_OUTPUTPICTURES = 0;
215 /* Find an empty picture slot */
216 for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
218 if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
220 p_pic = p_vout->p_picture + i_index;
230 /* We know the chroma, allocate a buffer which will be used
231 * directly by the decoder */
234 p_vout->p_sys->p_buffer =
235 malloc( p_vout->p_sys->i_tex_width * p_vout->p_sys->i_tex_height * 4 );
236 if( !p_vout->p_sys->p_buffer )
238 msg_Err( p_vout, "Out of memory" );
242 p_pic->p->p_pixels = p_vout->p_sys->p_buffer
243 + 2 * p_vout->p_sys->i_tex_width *
244 (p_vout->p_sys->i_tex_height - p_vout->output.i_height)
245 + 2 * (p_vout->p_sys->i_tex_width - p_vout->output.i_width);
246 p_pic->p->i_lines = p_vout->output.i_height;
247 p_pic->p->i_pitch = p_vout->p_sys->i_tex_width * 4;
248 p_pic->p->i_pixel_pitch = 4;
249 p_pic->p->i_visible_pitch = p_vout->output.i_width * 4;
251 p_pic->i_status = DESTROYED_PICTURE;
252 p_pic->i_type = DIRECT_PICTURE;
254 PP_OUTPUTPICTURE[ 0 ] = p_pic;
256 I_OUTPUTPICTURES = 1;
258 SwitchContext( &p_vout->p_sys->glx );
260 /* Set the texture parameters */
261 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
262 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
264 if( p_vout->p_sys->i_effect )
266 glEnable( GL_CULL_FACE);
267 /* glDisable( GL_DEPTH_TEST );
268 glEnable( GL_BLEND );
269 glBlendFunc( GL_SRC_ALPHA, GL_ONE );*/
271 /* Set the perpective */
272 glMatrixMode( GL_PROJECTION );
274 glFrustum( -1.0, 1.0, -1.0, 1.0, 3.0, 20.0 );
275 glMatrixMode( GL_MODELVIEW );
277 glTranslatef( 0.0, 0.0, - 5.0 );
283 /*****************************************************************************
284 * End: terminate GLX video thread output method
285 *****************************************************************************/
286 static void End( vout_thread_t *p_vout )
291 /*****************************************************************************
292 * Destroy: destroy GLX video thread output method
293 *****************************************************************************
294 * Terminate an output method created by CreateVout
295 *****************************************************************************/
296 static void DestroyVout( vlc_object_t *p_this )
298 vout_thread_t *p_vout = (vout_thread_t *)p_this;
300 CloseDisplay( &p_vout->p_sys->glx );
302 /* Free the texture buffer*/
303 if( p_vout->p_sys->p_buffer )
305 free( p_vout->p_sys->p_buffer );
308 free( p_vout->p_sys );
312 /*****************************************************************************
313 * CreateOpenGL: initialize an OpenGL provider
314 *****************************************************************************/
315 static int CreateOpenGL( vlc_object_t *p_this )
317 opengl_t *p_opengl = (opengl_t*)p_this;
319 /* Allocate the structure */
320 p_opengl->p_sys = malloc(sizeof(opengl_sys_t));
322 /* Set the function pointers */
323 p_opengl->pf_init = InitOpenGL;
324 p_opengl->pf_swap = SwapBuffers;
325 p_opengl->pf_handle_events = HandleEvents;
327 p_opengl->p_sys->glx.wnd = None;
333 /*****************************************************************************
334 * DestroyOpenGL: destroys an OpenGL provider
335 *****************************************************************************/
336 static void DestroyOpenGL( vlc_object_t *p_this )
338 opengl_t *p_opengl = (opengl_t*)p_this;
340 /* Free the structure */
341 free(p_opengl->p_sys);
344 /*****************************************************************************
345 * InitOpenGL: creates the OpenGL window
346 *****************************************************************************/
347 static int InitOpenGL( opengl_t *p_opengl, int i_width, int i_height )
349 p_opengl->p_sys->glx.i_width = i_width;
350 p_opengl->p_sys->glx.i_height = i_height;
351 p_opengl->p_sys->glx.b_fullscreen = 0;
353 if( OpenDisplay( (vlc_object_t*)p_opengl, &p_opengl->p_sys->glx ) )
355 msg_Err( p_opengl, "Cannot create OpenGL window" );
359 /* Set the OpenGL context _for the current thread_ */
360 SwitchContext( &p_opengl->p_sys->glx );
366 /*****************************************************************************
367 * SwapBuffers: swap front/back buffers
368 *****************************************************************************/
369 static void SwapBuffers( opengl_t *p_opengl )
371 if( p_opengl->p_sys->glx.b_glx13 )
373 glXSwapBuffers( p_opengl->p_sys->glx.p_display,
374 p_opengl->p_sys->glx.gwnd );
378 glXSwapBuffers( p_opengl->p_sys->glx.p_display,
379 p_opengl->p_sys->glx.wnd );
384 /*****************************************************************************
385 * HandleEvents: handle window events
386 *****************************************************************************/
387 static int HandleEvents( opengl_t *p_opengl )
390 HandleX11Events( (vlc_object_t*)p_opengl, &p_opengl->p_sys->glx );
393 /* close the window */
394 CloseDisplay( &p_opengl->p_sys->glx );
400 /*****************************************************************************
401 * Manage: handle X11 events
402 *****************************************************************************
403 * This function should be called regularly by video output thread. It manages
404 * console events. It returns a non null value on error.
405 *****************************************************************************/
406 static int Manage( vout_thread_t *p_vout )
408 if( HandleX11Events( (vlc_object_t*)p_vout, &p_vout->p_sys->glx ) )
410 /* the user wants to close the window */
411 playlist_t * p_playlist =
412 (playlist_t *)vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST,
414 if( p_playlist != NULL )
416 playlist_Stop( p_playlist );
417 vlc_object_release( p_playlist );
424 static int HandleX11Events( vlc_object_t *p_thread, glx_t *p_glx )
428 p_display = p_glx->p_display;
430 /* loop on X11 events */
431 while( XPending( p_display ) > 0 )
434 XNextEvent( p_display, &evt );
439 /* Delete notification */
440 if( (evt.xclient.format == 32) &&
441 ((Atom)evt.xclient.data.l[0] ==
454 /*****************************************************************************
455 * Render: render previously calculated output
456 *****************************************************************************/
457 static void Render( vout_thread_t *p_vout, picture_t *p_pic )
459 glClear(GL_COLOR_BUFFER_BIT);
460 /*glTexImage2D (GL_TEXTURE_2D, 0, 3, p_vout->output.i_width,
461 p_vout->output.i_height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
462 p_vout->p_sys->p_buffer);*/
463 glTexImage2D (GL_TEXTURE_2D, 0, 3, p_vout->p_sys->i_tex_width,
464 p_vout->p_sys->i_tex_height , 0, GL_RGBA, GL_UNSIGNED_BYTE,
465 p_vout->p_sys->p_buffer);
467 if( !p_vout->p_sys->i_effect )
469 glEnable( GL_TEXTURE_2D);
470 glBegin( GL_POLYGON);
471 glTexCoord2f(0.0,0.0); glVertex2f(-1.0,1.0);
472 glTexCoord2f(1.0,0.0); glVertex2f(1.0,1.0);
473 glTexCoord2f(1.0,1.0); glVertex2f(1.0,-1.0);
474 glTexCoord2f(0.0,1.0); glVertex2f(-1.0,-1.0);
479 glRotatef( 1.0, 0.3, 0.5, 0.7 );
481 glEnable( GL_TEXTURE_2D);
484 float f_width = p_vout->output.i_width;
485 float f_height = p_vout->output.i_height;
487 /* Correct the aspect ratio */
488 /* float f_aspect = (float)p_vout->output.i_aspect / VOUT_ASPECT_FACTOR;
491 f_height *= f_aspect;
498 float f_offset_x = (1.0 - f_width / p_vout->p_sys->i_tex_width) / 2.0;
499 float f_offset_y = (1.0 - f_height / p_vout->p_sys->i_tex_height) / 2.0;
502 glTexCoord2f( f_offset_x, f_offset_y );
503 glVertex3f( - 1.0, 1.0, 1.0 );
504 glTexCoord2f( f_offset_x, 1.0 - f_offset_y );
505 glVertex3f( - 1.0, - 1.0, 1.0 );
506 glTexCoord2f( 1.0 - f_offset_x, 1.0 - f_offset_y );
507 glVertex3f( 1.0, - 1.0, 1.0 );
508 glTexCoord2f( 1.0 - f_offset_x, f_offset_y );
509 glVertex3f( 1.0, 1.0, 1.0 );
512 glTexCoord2f( f_offset_x, f_offset_y );
513 glVertex3f( - 1.0, 1.0, - 1.0 );
514 glTexCoord2f( f_offset_x, 1.0 - f_offset_y );
515 glVertex3f( - 1.0, - 1.0, - 1.0 );
516 glTexCoord2f( 1.0 - f_offset_x, 1.0 - f_offset_y );
517 glVertex3f( - 1.0, - 1.0, 1.0 );
518 glTexCoord2f( 1.0 - f_offset_x, f_offset_y );
519 glVertex3f( - 1.0, 1.0, 1.0 );
522 glTexCoord2f( f_offset_x, f_offset_y );
523 glVertex3f( 1.0, 1.0, - 1.0 );
524 glTexCoord2f( f_offset_x, 1.0 - f_offset_y );
525 glVertex3f( 1.0, - 1.0, - 1.0 );
526 glTexCoord2f( 1.0 - f_offset_x, 1.0 - f_offset_y );
527 glVertex3f( - 1.0, - 1.0, - 1.0 );
528 glTexCoord2f( 1.0 - f_offset_x, f_offset_y );
529 glVertex3f( - 1.0, 1.0, - 1.0 );
532 glTexCoord2f( f_offset_x, f_offset_y );
533 glVertex3f( 1.0, 1.0, 1.0 );
534 glTexCoord2f( f_offset_x, 1.0 - f_offset_y );
535 glVertex3f( 1.0, - 1.0, 1.0 );
536 glTexCoord2f( 1.0 - f_offset_x, 1.0 - f_offset_y );
537 glVertex3f( 1.0, - 1.0, - 1.0 );
538 glTexCoord2f( 1.0 - f_offset_x, f_offset_y );
539 glVertex3f( 1.0, 1.0, - 1.0 );
542 glTexCoord2f( f_offset_x, f_offset_y );
543 glVertex3f( - 1.0, 1.0, - 1.0 );
544 glTexCoord2f( f_offset_x, 1.0 - f_offset_y );
545 glVertex3f( - 1.0, 1.0, 1.0 );
546 glTexCoord2f( 1.0 - f_offset_x, 1.0 - f_offset_y );
547 glVertex3f( 1.0, 1.0, 1.0 );
548 glTexCoord2f( 1.0 - f_offset_x, f_offset_y );
549 glVertex3f( 1.0, 1.0, - 1.0 );
552 glTexCoord2f( f_offset_x, f_offset_y );
553 glVertex3f( - 1.0, - 1.0, 1.0 );
554 glTexCoord2f( f_offset_x, 1.0 - f_offset_y );
555 glVertex3f( - 1.0, - 1.0, - 1.0 );
556 glTexCoord2f( 1.0 - f_offset_x, 1.0 - f_offset_y );
557 glVertex3f( 1.0, - 1.0, - 1.0 );
558 glTexCoord2f( 1.0 - f_offset_x, f_offset_y );
559 glVertex3f( 1.0, - 1.0, 1.0 );
562 glDisable( GL_TEXTURE_2D);
566 /*****************************************************************************
567 * DisplayVideo: displays previously rendered output
568 *****************************************************************************/
569 static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic )
571 if( p_vout->p_sys->glx.b_glx13 )
573 glXSwapBuffers( p_vout->p_sys->glx.p_display,
574 p_vout->p_sys->glx.gwnd );
578 glXSwapBuffers( p_vout->p_sys->glx.p_display,
579 p_vout->p_sys->glx.wnd );
584 /*****************************************************************************
585 * OpenDisplay: open and initialize OpenGL device
586 *****************************************************************************/
587 static int OpenDisplay( vlc_object_t *p_thread, glx_t *p_glx )
590 int i_opcode, i_evt, i_err;
593 /* Open the display */
594 p_glx->p_display = p_display = XOpenDisplay( NULL );
597 msg_Err( p_thread, "Cannot open display" );
601 /* Check for GLX extension */
602 if( !XQueryExtension( p_display, "GLX", &i_opcode, &i_evt, &i_err ) )
604 msg_Err( p_thread, "GLX extension not supported" );
607 if( !glXQueryExtension( p_display, &i_err, &i_evt ) )
609 msg_Err( p_thread, "glXQueryExtension failed" );
613 /* Check GLX version */
614 if (!glXQueryVersion( p_display, &i_maj, &i_min ) )
616 msg_Err( p_thread, "glXQueryVersion failed" );
619 if( i_maj <= 0 || ((i_maj == 1) && (i_min < 3)) )
622 msg_Dbg( p_thread, "Using GLX 1.2 API" );
623 if( InitGLX12( p_thread, p_glx ) == -1 )
631 msg_Dbg( p_thread, "Using GLX 1.3 API" );
632 if( InitGLX13( p_thread, p_glx ) == -1 )
638 XMapWindow( p_display, p_glx->wnd );
639 if( p_glx->b_fullscreen )
642 XMoveWindow( p_display, p_glx->wnd, 0, 0 );
648 /*****************************************************************************
649 * CloseDisplay: close and reset OpenGL device
650 *****************************************************************************
651 * Returns all resources allocated by OpenDisplay and restore the original
652 * state of the device.
653 *****************************************************************************/
654 static void CloseDisplay( glx_t *p_glx )
658 if (p_glx->wnd == None )
660 // Already closed or not opened...
665 p_display = p_glx->p_display;
666 glXDestroyContext( p_display, p_glx->gwctx );
669 glXDestroyWindow( p_display, p_glx->gwnd );
671 XDestroyWindow( p_display, p_glx->wnd );
676 int InitGLX12( vlc_object_t *p_thread, glx_t *p_glx )
681 int p_attr[] = { GLX_RGBA, GLX_RED_SIZE, 5, GLX_GREEN_SIZE, 5,
682 GLX_BLUE_SIZE, 5, GLX_DOUBLEBUFFER,
685 p_display = p_glx->p_display;
687 p_vi = glXChooseVisual( p_display, DefaultScreen( p_display), p_attr );
690 msg_Err( p_thread, "Cannot get GLX 1.2 visual" );
694 /* Create the window */
695 CreateWindow( p_thread, p_glx, p_vi );
697 /* Create an OpenGL context */
698 p_glx->gwctx = gwctx = glXCreateContext( p_display, p_vi, 0, True );
701 msg_Err( p_thread, "Cannot create OpenGL context");
711 int InitGLX13( vlc_object_t *p_thread, glx_t *p_glx )
715 GLXFBConfig *p_fbconfs, fbconf;
718 int p_attr[] = { GLX_RED_SIZE, 5, GLX_GREEN_SIZE, 5,
719 GLX_BLUE_SIZE, 5, GLX_DOUBLEBUFFER, True,
720 GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, 0 };
722 p_display = p_glx->p_display;
724 /* Get the FB configuration */
725 p_fbconfs = glXChooseFBConfig( p_display, 0, p_attr, &i_nbelem );
726 if( (i_nbelem <= 0) || !p_fbconfs )
728 msg_Err( p_thread, "Cannot get FB configurations");
735 fbconf = p_fbconfs[0];
737 /* Get the X11 visual */
738 p_vi = glXGetVisualFromFBConfig( p_display, fbconf );
741 msg_Err( p_thread, "Cannot get X11 visual" );
746 /* Create the window */
747 CreateWindow( p_thread, p_glx, p_vi );
751 /* Create the GLX window */
752 p_glx->gwnd = glXCreateWindow( p_display, fbconf, p_glx->wnd, NULL );
753 if( p_glx->gwnd == None )
755 msg_Err( p_thread, "Cannot create GLX window" );
759 /* Create an OpenGL context */
760 p_glx->gwctx = gwctx = glXCreateNewContext( p_display, fbconf,
761 GLX_RGBA_TYPE, NULL, True );
764 msg_Err( p_thread, "Cannot create OpenGL context");
774 void CreateWindow( vlc_object_t *p_thread, glx_t *p_glx, XVisualInfo *p_vi )
777 XSetWindowAttributes xattr;
780 XSizeHints* p_size_hints;
784 p_display = p_glx->p_display;
786 /* Create a colormap */
787 cm = XCreateColormap( p_display, RootWindow( p_display, p_vi->screen ),
788 p_vi->visual, AllocNone );
790 /* Create the window */
791 xattr.background_pixel = BlackPixel( p_display, DefaultScreen(p_display) );
792 xattr.border_pixel = 0;
794 p_glx->wnd = wnd = XCreateWindow( p_display, DefaultRootWindow(p_display),
795 0, 0, p_glx->i_width, p_glx->i_height, 0, p_vi->depth,
796 InputOutput, p_vi->visual,
797 CWBackPixel | CWBorderPixel | CWColormap, &xattr);
799 /* Allow the window to be deleted by the window manager */
800 p_glx->wm_delete = XInternAtom( p_display, "WM_DELETE_WINDOW", False );
801 XSetWMProtocols( p_display, wnd, &p_glx->wm_delete, 1 );
803 if( p_glx->b_fullscreen )
805 mwmhints.flags = MWM_HINTS_DECORATIONS;
806 mwmhints.decorations = False;
808 prop = XInternAtom( p_display, "_MOTIF_WM_HINTS", False );
809 XChangeProperty( p_display, wnd, prop, prop, 32, PropModeReplace,
810 (unsigned char *)&mwmhints, PROP_MWM_HINTS_ELEMENTS );
814 /* Prevent the window from being resized */
815 p_size_hints = XAllocSizeHints();
816 p_size_hints->flags = PMinSize | PMaxSize;
817 p_size_hints->min_width = p_glx->i_width;
818 p_size_hints->min_height = p_glx->i_height;
819 p_size_hints->max_width = p_glx->i_width;
820 p_size_hints->max_height = p_glx->i_height;
821 XSetWMNormalHints( p_display, wnd, p_size_hints );
822 XFree( p_size_hints );
824 XSelectInput( p_display, wnd, KeyPressMask );
828 void SwitchContext( glx_t *p_glx )
830 /* Change the current OpenGL context */
833 glXMakeContextCurrent( p_glx->p_display, p_glx->gwnd,
834 p_glx->gwnd, p_glx->gwctx );
838 glXMakeCurrent( p_glx->p_display, p_glx->wnd,
844 int GetAlignedSize( int i_size )
846 /* Return the nearest power of 2 */
848 while( i_result < i_size )