projects
/
fishladder.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cross compile build script
[fishladder.git]
/
vg
/
vg.h
diff --git
a/vg/vg.h
b/vg/vg.h
index 84991dbb1135754ab8519e4462df7f0465a3157d..575bf036eeabf667aa322983555a3a2dee818830 100644
(file)
--- a/
vg/vg.h
+++ b/
vg/vg.h
@@
-7,14
+7,18
@@
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
#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
#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_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"
#include "vg/vg_platform.h"
@@
-31,10
+35,20
@@
m3x3f vg_pv;
// Engine globals
GLFWwindow* vg_window;
// Engine globals
GLFWwindow* vg_window;
-int vg_window_x = 1280;
-int vg_window_y = 720;
+
+// 1366, 768
+// 1920, 1080
+
+#ifdef VG_CAPTURE_MODE
+int vg_window_x = 1920;
+int vg_window_y = 1080;
+#else
+int vg_window_x = 1366;
+int vg_window_y = 768;
+#endif
v2f vg_mouse;
v2f vg_mouse;
+v2f vg_mouse_wheel;
v3f vg_mouse_ws;
float vg_time;
v3f vg_mouse_ws;
float vg_time;
@@
-48,10
+62,12
@@
float vg_time_delta;
#include "vg/vg_tex.h"
#include "vg/vg_input.h"
#include "vg/vg_ui.h"
#include "vg/vg_tex.h"
#include "vg/vg_input.h"
#include "vg/vg_ui.h"
-#include "vg/vg_debug.h"
#include "vg/vg_console.h"
#include "vg/vg_console.h"
+#include "vg/vg_debug.h"
-#include "steam/steamworks_thin.h"
+#ifdef VG_STEAM
+#include "vg/vg_steamworks.h"
+#endif
// Engine main
// ===========================================================================================================
// Engine main
// ===========================================================================================================
@@
-115,7
+131,8
@@
void vg_mouse_callback( GLFWwindow* ptrW, double xpos, double ypos )
void vg_scroll_callback( GLFWwindow* ptrW, double xoffset, double yoffset )
{
void vg_scroll_callback( GLFWwindow* ptrW, double xoffset, double yoffset )
{
-
+ vg_mouse_wheel[0] += xoffset;
+ vg_mouse_wheel[1] += yoffset;
}
void vg_framebuffer_resize_callback( GLFWwindow *ptrW, int w, int h )
}
void vg_framebuffer_resize_callback( GLFWwindow *ptrW, int w, int h )
@@
-135,14
+152,8
@@
static void vg_init( int argc, char *argv[], const char *window_name )
{
#ifdef VG_STEAM
// Initialize steamworks
{
#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
#endif
// Context creation
@@
-153,6
+164,12
@@
static void vg_init( int argc, char *argv[], const char *window_name )
glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );
glfwWindowHint( GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE );
glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );
glfwWindowHint( GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE );
+#ifdef VG_CAPTURE_MODE
+ glfwWindowHint( GLFW_RESIZABLE, GLFW_FALSE );
+#else
+ glfwWindowHint( GLFW_RESIZABLE, GLFW_TRUE );
+#endif
+
glfwWindowHint( GLFW_SAMPLES, 4 );
GLFWmonitor *monitor_primary = glfwGetPrimaryMonitor();
glfwWindowHint( GLFW_SAMPLES, 4 );
GLFWmonitor *monitor_primary = glfwGetPrimaryMonitor();
@@
-193,9
+210,6
@@
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 );
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 ++ )
vg_run_gfx_diagnostics();
for( int id = 0; id <= GLFW_JOYSTICK_LAST; id ++ )
@@
-224,16
+238,23
@@
static void vg_init( int argc, char *argv[], const char *window_name )
{
vg_start();
{
vg_start();
+ vg_console_init();
+ vg_register_exit( &vg_console_free, "Console" );
+
vg_audio_init();
vg_register_exit( &vg_audio_free, "vg_audio_free" );
vg_audio_init();
vg_register_exit( &vg_audio_free, "vg_audio_free" );
-
+
+ vg_debugtools_setup();
+
// Main gameloop
while( !glfwWindowShouldClose( vg_window ) )
{
// Main gameloop
while( !glfwWindowShouldClose( vg_window ) )
{
+ v2_copy( (v2f){ 0.0f, 0.0f }, vg_mouse_wheel );
+
glfwPollEvents();
#ifdef VG_STEAM
glfwPollEvents();
#ifdef VG_STEAM
- sw_
RunSteamEventL
oop();
+ sw_
event_l
oop();
#endif
vg_time_last = vg_time;
#endif
vg_time_last = vg_time;
@@
-248,23
+269,14
@@
static void vg_init( int argc, char *argv[], const char *window_name )
{
ui_begin( &ui_global_ctx, vg_window_x, vg_window_y );
{
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_ui();
vg_console_draw();
+ vg_debugtools_draw();
ui_resolve( &ui_global_ctx );
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 );
}
glfwSwapBuffers( vg_window );