--- /dev/null
+#pragma once
+
+/* Copyright (C) 2021-2024 Mt.Zero Software - All Rights Reserved */
+/*
+ .-. VG Event loop
+| 0 |
+| | .---------------------------------------------------------.
+|API| | vg_enter( int argc, char *argv[], const char *window_name |
+| | '---------------------------------------------------------'
+| | |
+| | v
+|IMP| vg_launch_opt(void) <--.
+| | | |
+| | |'---------------'
+| | | .-.
+| | |'-----------------------------------| 1 |------.
+| | | | | |
+| | | | | v
+| | | |IMP| vg_preload(void)
+| | | | | |
+| | .-----+. | | v
+| | | | |IMP| vg_load(void)
+| | | v '___' |
+|IMP| | vg_framebuffer_resize(void) |
+| | | | |
+|IMP| | |.--------------------------------------------'
+| | | |
+| | | v
+|IMP| | vg_pre_update(void)
+| | | |
+| | | .-----+.
+| | | | | called 0x to 8x
+| | | | v
+|IMP| | '- vg_fixed_update(void)
+| | | |
+| | | .-'
+| | | |
+| | | v
+|IMP| | vg_post_update(void)
+| | | |
+| | | v
+|IMP| | vg_render(void)
+| | | |
+| | | v
+|IMP| | vg_gui(void)
+| | | |
+| | | v
+|IMP| | vg_game_settings_init(void)
+|IMP| | vg_game_settings_gui( ui_rect panel )
+| | | | (optional: #define VG_GAME_SETTINGS)
+| | | |
+| | '----'
+'___'
+
+*/
+
+/* configuration warnings */
+
+#ifndef VG_TIMESTEP_FIXED
+ #warning VG_TIMESTEP_FIXED not defined; setting to 1/60
+ #define VG_TIMESTEP_FIXED (1.0/60.0)
+#endif
+
+#ifndef VG_3D
+ #ifndef VG_2D
+ #warning VG_3D or VG_2D not defined; defining VG_3D
+ #define VG_3D
+ #endif
+#endif
+
+#define VG_ENGINE
+#define SDL_MAIN_HANDLED
+
+#include "dep/glad/glad.h"
+#include "dep/sdl/include/SDL.h"
+
+#include "vg_platform.h"
+#include "vg_mem.h"
+#include "vg_m.h"
+#include "vg_imgui.h"
+
+#include <setjmp.h>
+
+/* API */
+void vg_enter( int argc, char *argv[], const char *window_name );
+
+/* Thread 1 */
+void vg_bake_shaders(void);
+
+extern void vg_preload(void);
+extern void vg_load(void);
+
+/* Main thread */
+extern void vg_launch_opt(void);
+extern void vg_framebuffer_resize(int w, int h);
+extern void vg_pre_update(void);
+extern void vg_fixed_update(void);
+extern void vg_post_update(void);
+
+extern void vg_render(void);
+extern void vg_gui(void);
+
+void vg_settings_open(void);
+void vg_settings_close(void);
+
+enum quality_profile{
+ k_quality_profile_high = 0,
+ k_quality_profile_low = 1,
+ k_quality_profile_min = 2
+};
+
+enum vg_thread_purpose
+{
+ k_thread_purpose_nothing,
+ k_thread_purpose_main,
+ k_thread_purpose_loader
+};
+
+struct vg_engine {
+ /* Engine sync */
+ SDL_Window *window;
+ SDL_GLContext gl_context;
+
+ SDL_sem *sem_loader; /* allows only one loader at a time */
+ jmp_buf env_loader_exit;
+
+ SDL_threadID thread_id_main,
+ thread_id_loader;
+ void *thread_data;
+
+ SDL_SpinLock sl_status;
+ enum engine_status{
+ k_engine_status_none,
+ k_engine_status_load_internal,
+ k_engine_status_running,
+ k_engine_status_crashed
+ }
+ engine_status;
+
+ /* Window information */
+ int window_x,
+ window_y,
+ samples,
+ window_should_close;
+ const char *base_path;
+
+ int display_refresh_rate,
+ fps_limit,
+ vsync,
+ screen_mode,
+ display_index;
+
+ int settings_open;
+
+ enum vsync_feature{
+ k_vsync_feature_disabled=0,
+ k_vsync_feature_enabled=1,
+ k_vsync_feature_enabled_adaptive=2,
+ k_vsync_feature_error=3
+ }
+ vsync_feature;
+
+ i32 mouse_pos[2];
+ v2f mouse_delta,
+ mouse_wheel;
+
+ /* Runtime */
+ double time,
+ time_real,
+ time_delta,
+ time_rate,
+
+ time_fixed_accumulator,
+ time_fixed_extrapolate,
+ time_frame_delta;
+
+ f32 time_fixed_delta;
+
+ u64 time_hp, time_hp_last, time_spinning;
+
+ int fixed_iterations;
+
+ enum engine_stage{
+ k_engine_stage_none,
+ k_engine_stage_update,
+ k_engine_stage_update_fixed,
+ k_engine_stage_rendering,
+ k_engine_stage_ui
+ }
+ engine_stage;
+
+ /* graphics */
+#ifdef VG_3D
+ m4x4f pv;
+#else
+ m3x3f pv;
+#endif
+
+ i32 quality_profile;
+
+ float loader_ring;
+ GLuint tex_missing;
+
+ vg_rand rand;
+}
+extern vg;
+
+struct vg_setting_enum
+{
+ i32 new_value, *actual_value;
+
+ struct ui_enum_opt *options;
+ u32 option_count;
+ const char *label;
+};
+
+struct vg_setting_ranged_i32
+{
+ i32 new_value, *actual_value, min, max;
+ char buf[10];
+ const char *label;
+};
+
+void ui_settings_ranged_i32_init( struct vg_setting_ranged_i32 *prop );
+void ui_settings_enum_init( struct vg_setting_enum *prop );
+bool vg_settings_enum( struct vg_setting_enum *prop, ui_rect rect );
+bool vg_settings_enum_diff( struct vg_setting_enum *prop );
+void vg_settings_ui_header( ui_rect inout_panel, const char *name );
+bool vg_settings_apply_button( ui_rect inout_panel, bool validated );
+
+enum engine_status _vg_engine_status(void);
+enum vg_thread_purpose vg_thread_purpose(void);
+
+void vg_checkgl( const char *src_info );
+#define VG_STRINGIT( X ) #X
+#define VG_CHECK_GL_ERR() vg_checkgl( __FILE__ ":L" VG_STRINGIT(__LINE__) )
+
+/* the few includes we always want. */
+#include "vg_log.h"
+#include "vg_shader.h"
+#include "vg_console.h"