I want to refresh my screen every 200ms without having to add some code in a loop.
So, I would like to create a Timer with a callback in Vala using SDL.
I read the documentation but I don't understand what is excpected as a second parameter : http://www.valadoc.org/sdl/SDL.Timer.html
The following code compile without any error :
this.timer = new SDL.Timer( 200, () => { this.refresh(); return 0; } );
EDIT : here is the full code with SDL :
public View( int width, int height, bool fullscreen, string window_name = "AKITA application" )
{
SDL.init( InitFlag.VIDEO | InitFlag.TIMER );
this.last_tick = 0;
this.fps = 25; // Set default value for FPS
uint32 video_flags = SurfaceFlag.DOUBLEBUF | SurfaceFlag.HWACCEL | SurfaceFlag.HWSURFACE;
this.screen = Screen.set_video_mode( width, height, 32, video_flags);
if ( this.screen == null )
{
stderr.printf ("Could not set video mode.\n");
}
WindowManager.set_caption (window_name, "");
this.timer = new SDL.Timer( 200, () => { this.refresh(); return 0; } );
}
public void refresh()
{
stdout.printf( "refresh...\n" );
}
But nothing appears (refresh()
should write something on stdout).
Could someone help me with this (or have a better way to do what I want) ?
Thanks,
Damien