X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=vg%2Fvg.h;h=22cd0a7e3e80bb3fd1a2f41b97c46f97d2bb905c;hb=72e9a469a490e537f2e12464c1b075eb8991a868;hp=658130bfe497992289dfe23977e9a0c98cf7a47c;hpb=27f1751d523e9dee4ab00ec10666bbb3d8db74bc;p=fishladder.git diff --git a/vg/vg.h b/vg/vg.h index 658130b..22cd0a7 100644 --- a/vg/vg.h +++ b/vg/vg.h @@ -6,14 +6,19 @@ #include #include #include +#include +#include #include "gl/glad/glad.h" #include "gl/glfw3.h" #define STB_DS_IMPLEMENTATION -#define STB_IMAGE_IMPLEMENTATION #include "stb/stb_ds.h" -#include "stb/stb_image.h" +//#define STB_IMAGE_IMPLEMENTATION +//#include "stb/stb_image.h" + +#define QOI_IMPLEMENTATION +#include "phoboslab/qoi.h" #include "vg/vg_platform.h" @@ -47,6 +52,8 @@ float vg_time_delta; #include "vg/vg_tex.h" #include "vg/vg_input.h" #include "vg/vg_ui.h" +#include "vg/vg_console.h" +#include "vg/vg_debug.h" #include "steam/steamworks_thin.h" @@ -178,8 +185,8 @@ static void vg_init( int argc, char *argv[], const char *window_name ) glfwSetCursorPosCallback( vg_window, vg_mouse_callback ); glfwSetScrollCallback( vg_window, vg_scroll_callback ); - //glfwSetCharCallback( vg_window, console_proc_wchar ); - //glfwSetKeyCallback( vg_window, console_proc_key ); + glfwSetCharCallback( vg_window, console_proc_wchar ); + glfwSetKeyCallback( vg_window, console_proc_key ); //glfwSetInputMode(vg_window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); if( !gladLoadGLLoader((GLADloadproc)glfwGetProcAddress) ) @@ -190,6 +197,9 @@ static void vg_init( int argc, char *argv[], const char *window_name ) const unsigned char* glver = glGetString( GL_VERSION ); vg_success( "Load setup complete, OpenGL version: %s\n", glver ); + vg_console_init(); + vg_register_exit( &vg_console_free, "Console" ); + vg_run_gfx_diagnostics(); for( int id = 0; id <= GLFW_JOYSTICK_LAST; id ++ ) @@ -206,11 +216,11 @@ static void vg_init( int argc, char *argv[], const char *window_name ) } } - vg_audio_init(); - vg_register_exit( &vg_audio_free, "vg_audio_free" ); vg_lines_init(); vg_register_exit( &vg_lines_free, "vg_lines_free" ); - + ui_default_init(); + vg_register_exit( &ui_default_free, "UI" ); + vg_register(); vg_register_exit( &vg_free, "vg_free" ); @@ -218,6 +228,11 @@ static void vg_init( int argc, char *argv[], const char *window_name ) { vg_start(); + vg_audio_init(); + vg_register_exit( &vg_audio_free, "vg_audio_free" ); + + vg_debugtools_setup(); + // Main gameloop while( !glfwWindowShouldClose( vg_window ) ) { @@ -229,7 +244,7 @@ static void vg_init( int argc, char *argv[], const char *window_name ) vg_time_last = vg_time; vg_time = glfwGetTime(); - vg_time_delta = vg_min( vg_time - vg_time_last, 0.1f ); + vg_time_delta = vg_minf( vg_time - vg_time_last, 0.1f ); vg_update_inputs(); vg_update(); @@ -237,7 +252,27 @@ static void vg_init( int argc, char *argv[], const char *window_name ) vg_lines_drawall((float*)vg_pv); - vg_ui(); + { + ui_begin( &ui_global_ctx, vg_window_x, vg_window_y ); + + // TODO: Find a more elegent form for this + int mouse_state = 0; + if( vg_get_button( "primary" ) ) mouse_state = 2; + if( vg_get_button_down( "primary" ) ) mouse_state = 1; + if( vg_get_button_up( "primary" ) ) mouse_state = 3; + + ui_set_mouse( &ui_global_ctx, vg_mouse[0], vg_mouse[1], mouse_state ); + + vg_ui(); + vg_console_draw(); + vg_debugtools_draw(); + + ui_resolve( &ui_global_ctx ); + m3x3f view = M3X3_IDENTITY; + m3x3_translate( view, (v3f){ -1.0f, 1.0f, 0.0f } ); + m3x3_scale( view, (v3f){ 1.0f/((float)vg_window_x*0.5f), -1.0f/((float)vg_window_y*0.5f), 1.0f } ); + ui_draw( &ui_global_ctx ); + } glfwSwapBuffers( vg_window );