X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=vg%2Fvg.h;h=ba392bb99adba028461ce7278a6775880a1c9632;hb=a46972aa1ee718339c2512cae986f2943bed0e04;hp=74a8775cf8c10e11e8d3ca57fe7ba202b92184f4;hpb=95036f2af35f1b5af66bfcd90811f7c3c4bebf78;p=fishladder.git diff --git a/vg/vg.h b/vg/vg.h index 74a8775..ba392bb 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" @@ -30,8 +35,8 @@ m3x3f vg_pv; // Engine globals GLFWwindow* vg_window; -int vg_window_x = 1280; -int vg_window_y = 720; +int vg_window_x = 1366; +int vg_window_y = 768; v2f vg_mouse; v3f vg_mouse_ws; @@ -47,9 +52,10 @@ 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" +#include "vg/vg_steamworks.h" // Engine main // =========================================================================================================== @@ -133,14 +139,8 @@ static void vg_init( int argc, char *argv[], const char *window_name ) { #ifdef VG_STEAM // Initialize steamworks - if( !sw_init( 1218140U ) ) - { - vg_exiterr( "Steamworks failed to initialize" ); - } - else - { - vg_register_exit( &sw_SteamAPI_Shutdown, "SteamAPI" ); - } + if( !sw_init() ) + return; #endif // Context creation @@ -150,6 +150,7 @@ static void vg_init( int argc, char *argv[], const char *window_name ) glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 3 ); glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE ); glfwWindowHint( GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE ); + glfwWindowHint( GLFW_RESIZABLE, GLFW_FALSE ); glfwWindowHint( GLFW_SAMPLES, 4 ); @@ -179,8 +180,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) ) @@ -191,6 +192,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 ++ ) @@ -211,7 +215,7 @@ static void vg_init( int argc, char *argv[], const char *window_name ) 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" ); @@ -221,14 +225,16 @@ 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_debugtools_setup(); + // Main gameloop while( !glfwWindowShouldClose( vg_window ) ) { glfwPollEvents(); #ifdef VG_STEAM - sw_RunSteamEventLoop(); + sw_event_loop(); #endif vg_time_last = vg_time; @@ -241,7 +247,17 @@ 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 ); + ui_set_mouse( &ui_global_ctx, vg_mouse[0], vg_mouse[1], vg_get_button_state( "primary" ) ); + + vg_ui(); + vg_console_draw(); + vg_debugtools_draw(); + + ui_resolve( &ui_global_ctx ); + ui_draw( &ui_global_ctx, NULL ); + } glfwSwapBuffers( vg_window );