+ @synchronized( p_sys->o_layer ) /* Make sure the p_sys->glContext isn't edited */
+ {
+ if( p_sys->glContext )
+ {
+ CGLLockContext(p_sys->glContext);
+ CGLSetCurrentContext(p_sys->glContext);
+ int i_new_index;
+ i_new_index = ( p_sys->i_index + 1 ) & 1;
+
+
+ /* Update the texture */
+ glBindTexture( VLCGL_TARGET, p_sys->p_textures[i_new_index] );
+ glTexSubImage2D( VLCGL_TARGET, 0, 0, 0,
+ p_vout->fmt_out.i_width,
+ p_vout->fmt_out.i_height,
+ VLCGL_FORMAT, VLCGL_TYPE, p_sys->pp_buffer[i_new_index] );
+
+ /* Bind to the previous texture for drawing */
+ glBindTexture( VLCGL_TARGET, p_sys->p_textures[p_sys->i_index] );
+
+ /* Switch buffers */
+ p_sys->i_index = i_new_index;
+ p_pic->p->p_pixels = p_sys->pp_buffer[p_sys->i_index];
+ CGLUnlockContext(p_sys->glContext);
+ }
+ }