X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=src%2Fvg%2Fvg.h;h=77d27e2fb9f80553cacad4469608b79f82a4678d;hb=3dd767bb10e6fee9cbffeb185d1a9685810c17b5;hp=f3456f3199887c8e76c4f0222cefe55732978292;hpb=5071899d6840f99825d0eaab4132a0bf27646938;p=vg.git diff --git a/src/vg/vg.h b/src/vg/vg.h index f3456f3..77d27e2 100644 --- a/src/vg/vg.h +++ b/src/vg/vg.h @@ -84,7 +84,9 @@ struct vg samples; float refresh_rate; - v2f mouse, + double mouse_pos[2]; + v2f + mouse_delta, mouse_wheel; /* Runtime */ @@ -110,12 +112,19 @@ struct vg /* 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 }; @@ -144,6 +153,14 @@ static VG_THREAD_LOCAL struct vg_thread_info vg_thread_info; #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) { @@ -318,8 +335,11 @@ VG_STATIC void vg_checkgl( const char *src_info ) 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 ) @@ -398,10 +418,15 @@ VG_STATIC void vg_enter( int argc, char *argv[], const char *window_name ) 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(); @@ -479,7 +504,10 @@ VG_STATIC void vg_enter( int argc, char *argv[], const char *window_name ) 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) ) { @@ -510,7 +538,9 @@ VG_STATIC void vg_enter( int argc, char *argv[], const char *window_name ) 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; @@ -549,9 +579,11 @@ VG_STATIC void vg_enter( int argc, char *argv[], const char *window_name ) 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 ); @@ -562,6 +594,7 @@ VG_STATIC void vg_enter( int argc, char *argv[], const char *window_name ) break; } } + vg_lines.allow_input = 1; /* * Rendering @@ -583,8 +616,9 @@ VG_STATIC void vg_enter( int argc, char *argv[], const char *window_name ) 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,