engine_stage;
/* graphics */
-#if 0
m4x4f pv;
-#endif
enum quality_profile
{
k_quality_profile_high = 0,
{
vg_acquire_thread_sync();
-#if 0
vg_function_push( (struct vg_cmd)
{
- .name = "shaders",
+ .name = "reload_shaders",
.function = vg_shaders_live_recompile
});
-#endif
vg_shaders_compile();
vg_release_thread_sync();
}
/* FIXME */
-#if 0
audio_debug_ui( vg.pv );
-#endif
vg_ui();
_vg_console_draw();
_vg_gameloop_update();
_vg_gameloop_render();
- audio_push_console_vol();
SDL_GL_SwapWindow( vg.window );
_vg_run_synced();
{
vg_info( "SDL_INIT\n" );
- if( SDL_Init( SDL_INIT_VIDEO ) != 0 )
- {
+ if( SDL_Init( SDL_INIT_VIDEO ) != 0 ){
vg_error( "SDL_Init failed: %s\n", SDL_GetError() );
exit(0);
}
*/
vg_info( "Getting display count\n" );
int display_count = 0, display_index = 0, mode_index = 0;
- if( (display_count = SDL_GetNumVideoDisplays()) < 1 )
- {
+ if( (display_count = SDL_GetNumVideoDisplays()) < 1 ){
vg_error( "SDL_GetNumVideoDisplays returned: %i\n", display_count );
exit(0);
}
+
+
+
/* 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_info( "Getting default display mode\n" );
+ SDL_DisplayMode vm_ideal = { 0, 0, 0, 0, 0 };
+ if( SDL_GetDisplayMode( display_index, mode_index, &vm_ideal ) != 0 )
{
vg_error( "SDL_GetDisplayMode failed: %s", SDL_GetError() );
exit(0);
}
- vg.refresh_rate = mode.refresh_rate;
+ if( vg.window_x )
+ vm_ideal.w = vg.window_x;
+
+ if( vg.window_y )
+ vm_ideal.h = vg.window_y;
- if( !vg.window_x )
- vg.window_x = mode.w;
- if( !vg.window_y )
- vg.window_y = mode.h;
+ SDL_DisplayMode vm_best;
+ if( !SDL_GetClosestDisplayMode( display_index, &vm_ideal, &vm_best ) )
+ {
+ vg_error( "SDL_GetClosestDisplayMode failed: %s", SDL_GetError() );
+ exit(0);
+ }
+
+ vg.refresh_rate = vm_best.refresh_rate;
+ vg.window_x = vm_best.w;
+ vg.window_y = vm_best.h;
- vg_info( "CreateWindow( %d %d )\n", vg.window_x, vg.window_y );
+ vg_info( "CreateWindow( %d %d @%.2fhz )\n", vg.window_x, vg.window_y,
+ vg.refresh_rate );
/* TODO: Allow selecting closest video mode from launch opts */
if((vg.window = SDL_CreateWindow( window_name,
SDL_WINDOW_OPENGL |
SDL_WINDOW_INPUT_GRABBED )))
{
+ if( SDL_SetWindowDisplayMode( vg.window, &vm_best ) )
+ {
+ vg_error( "SDL_SetWindowDisplayMode failed: %s", SDL_GetError() );
+ SDL_Quit();
+ exit(0);
+ }
}
else
{
SDL_Quit();
}
-/*
- * Immediately transfer away from calling thread into a safe loop, signal for
- * others to shutdown, then free everything once the user closes the window.
- *
- * FIXME(bug): glfwWindowShouldClose() never returns 1 in windows via wine, ONLY
- * when calling the program from outside its normal directory.
- */
-VG_STATIC void vg_fatal_exit_loop( const char *error )
+void vg_print_backtrace(void)
{
- /*
- * https://www.gnu.org/software/libc/manual/html_node/Backtraces.html
- * thanks gnu <3
- *
- * TODO: this on windows?
- */
-
#ifndef _WIN32
void *array[20];
free( strings );
#endif
+}
+
+/*
+ * Immediately transfer away from calling thread into a safe loop, signal for
+ * others to shutdown, then free everything once the user closes the window.
+ *
+ * FIXME(bug): glfwWindowShouldClose() never returns 1 in windows via wine, ONLY
+ * when calling the program from outside its normal directory.
+ */
+VG_STATIC void vg_fatal_exit_loop( const char *error )
+{
+ /*
+ * https://www.gnu.org/software/libc/manual/html_node/Backtraces.html
+ * thanks gnu <3
+ *
+ * TODO: this on windows?
+ */
+ vg_print_backtrace();
vg_error( "Fatal error: %s\n", error );
SDL_AtomicLock( &vg.sl_context );