Hi guys, I was trying to run the following tutorial in Xcode 8.0
but there is an error: no matching function for call to 'SDL_AddTimer’
How can I please fix that?
Many thanks!
http://lazyfoo.net/tutorials/SDL/45_timer_callbacks/index.php
Uint32 callback( Uint32 interval, void* param )
{
//Print callback message
cout << "Callback called back with message: \n" << (char*)param;
return 0;
}
int main( int argc, char* args[] )
{
//Start up SDL and create window
if( !init() )
{
printf( "Failed to initialize!\n" );
}
else
{
//Load media
if( !loadMedia() )
{
printf( "Failed to load media!\n" );
}
else
{
//Main loop flag
bool quit = false;
//Event handler
SDL_Event e;
//Set callback
SDL_TimerID timerID = SDL_AddTimer( 3 * 1000, callback, "3 seconds waited!" ); /*this line does not compile! */
//While application is running
while( !quit )
{
//Handle events on queue
while( SDL_PollEvent( &e ) != 0 )
{
//User requests quit
if( e.type == SDL_QUIT )
{
quit = true;
}
}
//Clear screen
SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
SDL_RenderClear( gRenderer );
//Render splash
gSplashTexture.render( 0, 0 );
//Update screen
SDL_RenderPresent( gRenderer );
}
//Remove timer in case the call back was not called
SDL_RemoveTimer( timerID );
}
}
//Free resources and close SDL
close();
return 0;
}