- vg_profile_drawn(
- (struct vg_profile *[]){&vg_prof_update,&vg_prof_render}, 2,
- (1.0f/(float)vg.refresh_rate)*1000.0f,
- (ui_rect){ 4, 4, 250, 0 }, 0
- );
-
- if( vg_profiler )
- {
-
- char perf[128];
-
- snprintf( perf, 127,
- "x: %d y: %d\n"
- "refresh: %.1f (%.1fms)\n"
- "samples: %d\n"
- "iterations: %d (acc: %.3fms%%)\n",
- vg.window_x, vg.window_y,
- vg.refresh_rate, (1.0f/vg.refresh_rate)*1000.0f,
- vg.samples,
- vg.fixed_iterations,
- (vg.accumulator/VG_TIMESTEP_FIXED)*100.0f );
-
- ui_text( (ui_rect){258, 4+24+12,0,0},perf, 1,0);
+ snprintf( perf, 255,
+ "x: %d y: %d\n"
+ "refresh: %d (%.1fms)\n"
+ "samples: %d\n"
+ "iterations: %d (acc: %.3fms%%)\n"
+ "time: real(%.2f) delta(%.2f) rate(%.2f)\n"
+ " extrap(%.2f) frame(%.2f) spin( "PRINTF_U64" )\n",
+ vg.window_x, vg.window_y,
+ frame_target, (1.0f/(float)frame_target)*1000.0f,
+ vg.samples,
+ vg.fixed_iterations,
+ (vg.time_fixed_accumulator/VG_TIMESTEP_FIXED)*100.0f,
+ vg.time_real, vg.time_delta, vg.time_rate,
+ vg.time_fixed_extrapolate, vg.time_frame_delta,
+ vg.time_spinning );
+
+ ui_text( (ui_rect){258, 4+24+12+12,900,900},perf,1,0,k_ui_align_left);
+ }
+ ui_postrender();
+ }
+
+ vg_profile_end( &vg_prof_render );
+}
+
+static void vg_changevsync(void){
+ if( vg.vsync && (vg.vsync_feature != k_vsync_feature_error) ){
+ /* turn on vsync if not enabled */
+
+ enum vsync_feature requested = k_vsync_feature_enabled;
+ if( vg.vsync < 0 ) requested = k_vsync_feature_enabled_adaptive;
+
+ if( vg.vsync_feature != requested ){
+ vg_info( "Setting swap interval\n" );
+
+ int swap_interval = 1;
+ if( requested == k_vsync_feature_enabled_adaptive )
+ swap_interval = -1;
+
+ if( SDL_GL_SetSwapInterval( swap_interval ) == -1 ){
+ if( requested == k_vsync_feature_enabled ){
+ vg_error( "Vsync is not supported by your system\n" );
+ vg_warn( "You may be overriding it in your"
+ " graphics control panel.\n" );
+ }
+ else{
+ vg_error( "Adaptive Vsync is not supported by your system\n" );
+ }
+
+ vg.vsync_feature = k_vsync_feature_error;
+ vg.vsync = 0;
+ /* TODO: Make popup to notify user that this happened */
+ }
+ else{
+ vg_success( "Vsync enabled (%d)\n", requested );
+ vg.vsync_feature = requested;