SDL_Overlay * p_overlay; /* overlay device */
boolean_t b_fullscreen;
boolean_t b_reopen_display;
+ boolean_t b_toggle_fullscreen;
Uint8 * p_buffer[2];
/* Buffers informations */
} vout_sys_t;
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-static int SDLOpenDisplay ( vout_thread_t *p_vout );
-static void SDLCloseDisplay ( vout_thread_t *p_vout );
+static int SDLOpenDisplay ( vout_thread_t *p_vout );
+static void SDLCloseDisplay ( vout_thread_t *p_vout );
+static void SDLToggleFullScreen ( vout_thread_t *p_vout );
/*****************************************************************************
* vout_SDLCreate: allocate SDL video thread output method
p_vout->p_sys->p_overlay = NULL;
/* Initialize library */
- if( SDL_Init(SDL_INIT_VIDEO) < 0 )
+ if( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTTHREAD) < 0 )
{
intf_ErrMsg( "error: can't initialize SDL library: %s",
SDL_GetError() );
p_vout->p_sys->i_width = VOUT_WIDTH_DEFAULT;
p_vout->p_sys->i_height = VOUT_HEIGHT_DEFAULT;
- p_vout->p_sys->b_reopen_display = 1;
+ if( SDLOpenDisplay(p_vout) )
+ {
+ intf_ErrMsg( "error: can't initialize SDL library: %s",
+ SDL_GetError() );
+ return( 1 );
+ }
+
+ p_vout->p_sys->b_toggle_fullscreen = 0;
return( 0 );
}
*****************************************************************************/
int vout_SDLInit( vout_thread_t *p_vout )
{
- if( SDLOpenDisplay(p_vout) )
- {
- intf_ErrMsg( "error: can't initialize SDL library: %s",
- SDL_GetError() );
- return( 1 );
- }
-
return( 0 );
}
return( 1 );
}
}
+
+ /* if fullscreen has to be toggled we do so */
+ if( p_vout->p_sys->b_toggle_fullscreen )
+ {
+ SDLToggleFullScreen(p_vout);
+ }
+
return( 0 );
}
+/*****************************************************************************
+ * vout_SDLSetPalette: sets an 8 bpp palette
+ *****************************************************************************
+ * This function sets the palette given as an argument. It does not return
+ * anything, but could later send information on which colors it was unable
+ * to set.
+ *****************************************************************************/
+void vout_SDLSetPalette( p_vout_thread_t p_vout, u16 *red, u16 *green, u16 *blue, u16 *transp)
+{
+ /* Create a display surface with a grayscale palette */
+ SDL_Color colors[256];
+ int i;
+
+ /* Fill colors with color information */
+ for( i = 0; i < 256; i++ )
+ {
+ colors[ i ].r = red[ i ] >> 8;
+ colors[ i ].g = green[ i ] >> 8;
+ colors[ i ].b = blue[ i ] >> 8;
+ }
+
+ /* Set palette */
+ if( SDL_SetColors(p_vout->p_sys->p_display, colors, 0, 256) == 0 )
+ {
+ intf_ErrMsg( "vout error: failed setting palette\n" );
+ }
+
+}
+
/*****************************************************************************
* vout_SDLDisplay: displays previously rendered output
*****************************************************************************
void vout_SDLDisplay( vout_thread_t *p_vout )
{
SDL_Rect disp;
- if(p_vout->p_sys->p_display && !p_vout->p_sys->b_reopen_display)
+ if((p_vout->p_sys->p_display != NULL) && !p_vout->p_sys->b_reopen_display)
{
if(p_vout->b_need_render)
{
*/
/* init flags and cursor */
- flags = SDL_ANYFORMAT;
+ flags = SDL_ANYFORMAT | SDL_HWPALETTE;
if( p_vout->p_sys->b_fullscreen )
flags |= SDL_FULLSCREEN;
{
if( p_vout->p_sys->p_display != NULL )
{
- SDL_UnlockSurface ( p_vout->p_sys->p_display );
if( p_vout->p_sys->p_overlay != NULL )
{
SDL_FreeYUVOverlay(p_vout->p_sys->p_overlay);
p_vout->p_sys->p_overlay = NULL;
}
+ SDL_UnlockSurface ( p_vout->p_sys->p_display );
SDL_FreeSurface( p_vout->p_sys->p_display );
p_vout->p_sys->p_display = NULL;
}
}
+/*****************************************************************************
+ * SDLToggleFullScreen: toggle fullscreen
+ *****************************************************************************
+ * This function toggles the fullscreen state of the surface.
+ *****************************************************************************/
+static void SDLToggleFullScreen( vout_thread_t *p_vout )
+{
+ SDL_WM_ToggleFullScreen(p_vout->p_sys->p_display);
+
+ if( p_vout->p_sys->b_fullscreen )
+ SDL_ShowCursor( 0 );
+ else
+ SDL_ShowCursor( 1 );
+
+ p_vout->p_sys->b_toggle_fullscreen = 0;
+}
+