samples;
float refresh_rate;
- v2f mouse,
+ double mouse_pos[2];
+ v2f
+ mouse_delta,
mouse_wheel;
/* Runtime */
/* graphics */
m4x4f pv;
+ enum quality_profile
+ {
+ k_quality_profile_high = 0,
+ k_quality_profile_low = 1,
+ }
+ quality_profile;
/* Gamepad */
GLFWgamepadstate gamepad;
int gamepad_ready;
const char *gamepad_name;
int gamepad_id;
+ int gamepad_use_trackpad_look;
}
VG_STATIC vg = { .time_rate = 1.0 };
#endif
VG_STATIC void vg_fatal_exit_loop( const char *error );
+VG_STATIC void vg_required( void *ptr, const char *path )
+{
+ if( !ptr )
+ {
+ vg_fatal_exit_loop( path );
+ }
+}
+
VG_STATIC void vg_ensure_engine_running(void)
{
void vg_mouse_callback( GLFWwindow* ptrW, double xpos, double ypos )
{
- vg.mouse[0] = xpos;
- vg.mouse[1] = ypos;
+ vg.mouse_delta[0] += xpos - vg.mouse_pos[0];
+ vg.mouse_delta[1] += ypos - vg.mouse_pos[1];
+
+ vg.mouse_pos[0] = xpos;
+ vg.mouse_pos[1] = ypos;
}
void vg_scroll_callback( GLFWwindow* ptrW, double xoffset, double yoffset )
vg.samples = VG_MAX( 0, VG_MIN( 8, atoi( arg ) ) );
}
- if( (arg = vg_long_opt_arg( "use-libc-malloc" )) )
+ if( vg_long_opt( "use-libc-malloc" ) )
{
vg_mem.use_libc_malloc = atoi( arg );
}
+
+ if( vg_long_opt( "high-performance" ) )
+ {
+ vg.quality_profile = k_quality_profile_low;
+ }
}
vg_alloc_quota();
glfwSetCharCallback( vg.window, console_proc_wchar );
glfwSetKeyCallback( vg.window, console_proc_key );
- glfwSetInputMode( vg.window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN );
+ glfwSetInputMode( vg.window, GLFW_CURSOR, GLFW_CURSOR_DISABLED );
+
+ if( glfwRawMouseMotionSupported() )
+ glfwSetInputMode( vg.window, GLFW_RAW_MOUSE_MOTION, GLFW_TRUE );
if( !gladLoadGLLoader((GLADloadproc)glfwGetProcAddress) )
{
if( glfwWindowShouldClose( vg.window ) )
break;
- v2_copy( (v2f){ 0.0f, 0.0f }, vg.mouse_wheel );
+ v2_zero( vg.mouse_wheel );
+ v2_zero( vg.mouse_delta );
+
glfwPollEvents();
vg.time_real_last = vg.time_real;
vg.accumulator += vg.time_delta;
vg.fixed_iterations = 0;
+ vg_lines.allow_input = 1;
while( vg.accumulator >= (VG_TIMESTEP_FIXED-0.00125) )
{
vg_update_fixed( loaded );
+ vg_lines.allow_input = 0;
vg.accumulator -= VG_TIMESTEP_FIXED;
vg.accumulator = VG_MAX( 0.0, vg.accumulator );
break;
}
}
+ vg_lines.allow_input = 1;
/*
* Rendering
vg.engine_stage = k_engine_stage_ui;
{
ui_begin( vg.window_x, vg.window_y );
- ui_set_mouse( vg.mouse[0], vg.mouse[1],
- vg_get_button_state( "primary" ) );
+
+ /* TODO */
+ ui_set_mouse( vg.mouse_pos[0], vg.mouse_pos[1], 0 );
vg_profile_drawn(
(struct vg_profile *[]){&vg_prof_update,&vg_prof_render}, 2,