3 /* Copyright (C) 2021-2024 Mt.Zero Software - All Rights Reserved */
7 | | .---------------------------------------------------------.
8 |API| | vg_enter( int argc, char *argv[], const char *window_name |
9 | | '---------------------------------------------------------'
12 |IMP| vg_launch_opt(void) <--.
14 | | |'---------------'
16 | | |'-----------------------------------| 1 |------.
19 | | | |IMP| vg_preload(void)
22 | | | | |IMP| vg_load(void)
24 |IMP| | vg_framebuffer_resize(void) |
26 |IMP| | |.--------------------------------------------'
29 |IMP| | vg_pre_update(void)
32 | | | | | called 0x to 8x
34 |IMP| | '- vg_fixed_update(void)
39 |IMP| | vg_post_update(void)
42 |IMP| | vg_render(void)
48 |IMP| | vg_game_settings_init(void)
49 |IMP| | vg_game_settings_gui( ui_rect panel )
50 | | | | (optional: #define VG_GAME_SETTINGS)
57 /* configuration warnings */
59 #ifndef VG_TIMESTEP_FIXED
60 #warning VG_TIMESTEP_FIXED not defined; setting to 1/60
61 #define VG_TIMESTEP_FIXED (1.0/60.0)
66 #warning VG_3D or VG_2D not defined; defining VG_3D
72 #define SDL_MAIN_HANDLED
74 #include "dep/glad/glad.h"
75 #include "dep/sdl/include/SDL.h"
77 #include "vg_platform.h"
85 void vg_enter( int argc
, char *argv
[], const char *window_name
);
88 void vg_bake_shaders(void);
90 extern void vg_preload(void);
91 extern void vg_load(void);
94 extern void vg_launch_opt(void);
95 extern void vg_framebuffer_resize(int w
, int h
);
96 extern void vg_pre_update(void);
97 extern void vg_fixed_update(void);
98 extern void vg_post_update(void);
100 extern void vg_render(void);
101 extern void vg_gui(void);
103 void vg_settings_open(void);
104 void vg_settings_close(void);
106 enum quality_profile
{
107 k_quality_profile_high
= 0,
108 k_quality_profile_low
= 1,
109 k_quality_profile_min
= 2
112 enum vg_thread_purpose
114 k_thread_purpose_nothing
,
115 k_thread_purpose_main
,
116 k_thread_purpose_loader
122 SDL_GLContext gl_context
;
124 SDL_sem
*sem_loader
; /* allows only one loader at a time */
125 jmp_buf env_loader_exit
;
127 SDL_threadID thread_id_main
,
131 SDL_SpinLock sl_status
;
133 k_engine_status_none
,
134 k_engine_status_load_internal
,
135 k_engine_status_running
,
136 k_engine_status_crashed
140 /* Window information */
145 const char *base_path
;
147 int display_refresh_rate
,
156 k_vsync_feature_disabled
=0,
157 k_vsync_feature_enabled
=1,
158 k_vsync_feature_enabled_adaptive
=2,
159 k_vsync_feature_error
=3
173 time_fixed_accumulator
,
174 time_fixed_extrapolate
,
177 f32 time_fixed_delta
;
179 u64 time_hp
, time_hp_last
, time_spinning
;
181 int fixed_iterations
;
185 k_engine_stage_update
,
186 k_engine_stage_update_fixed
,
187 k_engine_stage_rendering
,
208 struct vg_setting_enum
210 i32 new_value
, *actual_value
;
212 struct ui_enum_opt
*options
;
217 struct vg_setting_ranged_i32
219 i32 new_value
, *actual_value
, min
, max
;
224 void ui_settings_ranged_i32_init( struct vg_setting_ranged_i32
*prop
);
225 void ui_settings_enum_init( struct vg_setting_enum
*prop
);
226 bool vg_settings_enum( struct vg_setting_enum
*prop
, ui_rect rect
);
227 bool vg_settings_enum_diff( struct vg_setting_enum
*prop
);
228 void vg_settings_ui_header( ui_rect inout_panel
, const char *name
);
229 bool vg_settings_apply_button( ui_rect inout_panel
, bool validated
);
231 enum engine_status
_vg_engine_status(void);
232 enum vg_thread_purpose
vg_thread_purpose(void);
234 void vg_checkgl( const char *src_info
);
235 #define VG_STRINGIT( X ) #X
236 #define VG_CHECK_GL_ERR() vg_checkgl( __FILE__ ":L" VG_STRINGIT(__LINE__) )
238 /* the few includes we always want. */
240 #include "vg_shader.h"
241 #include "vg_console.h"