VG_STATIC void _vg_init_window( const char *window_name )
{
- if( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_GAMECONTROLLER) != 0 )
+ vg_info( "SDL_INIT\n" );
+
+ if( SDL_Init( SDL_INIT_VIDEO ) != 0 )
{
vg_error( "SDL_Init failed: %s\n", SDL_GetError() );
exit(0);
}
- SDL_GL_SetSwapInterval( 1 );
+ SDL_InitSubSystem( SDL_INIT_AUDIO );
+ SDL_InitSubSystem( SDL_INIT_GAMECONTROLLER );
+
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 3 );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 3 );
/*
* Get monitor information
*/
+ vg_info( "Getting display count\n" );
int display_count = 0, display_index = 0, mode_index = 0;
if( (display_count = SDL_GetNumVideoDisplays()) < 1 )
{
}
/* TODO: Allow chosing the modes at startup */
+ vg_info( "Getting display mode\n" );
SDL_DisplayMode mode = { SDL_PIXELFORMAT_UNKNOWN, 0, 0, 0, 0 };
if( SDL_GetDisplayMode( display_index, mode_index, &mode ) != 0 )
{
vg.refresh_rate = mode.refresh_rate;
+ vg_info( "CreateWindow\n" );
+
/* TODO: Allow selecting closest video mode from launch opts */
if((vg.window = SDL_CreateWindow( window_name,
SDL_WINDOWPOS_UNDEFINED,
exit(0);
}
+ vg_info( "CreateContext\n" );
+
/*
* OpenGL loading
*/
const unsigned char* glver = glGetString( GL_VERSION );
vg_success( "Load setup complete, OpenGL version: %s\n", glver );
+
+ vg_info( "Setting swap interval\n" );
+
+ if( SDL_GL_SetSwapInterval( -1 ) == -1 )
+ {
+ vg_warn( "Adaptive Vsync not supported\n" );
+
+ if( SDL_GL_SetSwapInterval( 1 ) == -1 )
+ {
+ vg_fatal_exit_loop( "Cannot enable Vsync! You might be overriding it"
+ " in your graphics control panel.\n" );
+ }
+ else
+ vg_success( "Using vsync\n" );
+ }
+ else
+ vg_success( "Using adaptive Vsync\n" );
}
VG_STATIC void vg_enter( int argc, char *argv[], const char *window_name )