level selector
[fishladder.git] / vg / vg.h
diff --git a/vg/vg.h b/vg/vg.h
index bf3a0a0224166961d968560d04e2e1cd41dc8f90..ba392bb99adba028461ce7278a6775880a1c9632 100644 (file)
--- a/vg/vg.h
+++ b/vg/vg.h
@@ -7,14 +7,18 @@
 #include <string.h>
 #include <stdarg.h>
 #include <ctype.h>
+#include <math.h>
 
 #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"
 
@@ -31,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;
@@ -51,7 +55,7 @@ float vg_time_delta;
 #include "vg/vg_console.h"
 #include "vg/vg_debug.h"
 
-#include "steam/steamworks_thin.h"
+#include "vg/vg_steamworks.h"
 
 // Engine main
 // ===========================================================================================================
@@ -135,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
@@ -152,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 );
        
@@ -235,7 +234,7 @@ static void vg_init( int argc, char *argv[], const char *window_name )
                        glfwPollEvents();
                        
                        #ifdef VG_STEAM
-                       sw_RunSteamEventLoop();
+                       sw_event_loop();
                        #endif
                        
                        vg_time_last = vg_time;
@@ -250,24 +249,14 @@ static void vg_init( int argc, char *argv[], const char *window_name )
                        
                        {
                                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 );
+                               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 );
-                               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 );
+                               ui_draw( &ui_global_ctx, NULL );
                        }
                        
                        glfwSwapBuffers( vg_window );