rework to context: now there's engine and user code copies, renaming of fields, most things that shouldn't be there are hidden
This commit is contained in:
@ -17,6 +17,8 @@
|
||||
|
||||
typedef struct EngineContext {
|
||||
/* user code facing context */
|
||||
Context game_copy;
|
||||
/* engine-side context, copied to `game_copy` before every frame */
|
||||
Context game;
|
||||
|
||||
InputState input;
|
||||
@ -27,6 +29,8 @@ typedef struct EngineContext {
|
||||
/* where the app was run from, used as the root for packs */
|
||||
char *base_dir;
|
||||
|
||||
Vec2i window_dims;
|
||||
|
||||
/* configuration */
|
||||
toml_table_t *config_table;
|
||||
int64_t base_render_width;
|
||||
@ -52,6 +56,7 @@ typedef struct EngineContext {
|
||||
uint8_t audio_stream_channel_count;
|
||||
|
||||
/* main loop machinery */
|
||||
int64_t delta_time; /* preserves real time frame delta with no manipilation */
|
||||
int64_t clocks_per_second;
|
||||
int64_t prev_frame_time;
|
||||
int64_t desired_frametime; /* how long one tick should be */
|
||||
@ -59,10 +64,17 @@ typedef struct EngineContext {
|
||||
int64_t delta_averager_residual;
|
||||
int64_t time_averager[4];
|
||||
|
||||
/* this should be a multiple of the current ticks per second */
|
||||
/* use it to simulate low framerate (e.g. at 60 tps, set to 2 for 30 fps) */
|
||||
/* it can be changed at runtime; any resulting logic anomalies are bugs */
|
||||
uint32_t update_multiplicity;
|
||||
|
||||
SDL_GLContext *gl_context;
|
||||
SDL_Window *window;
|
||||
uint32_t window_id;
|
||||
|
||||
bool is_running;
|
||||
bool window_size_has_changed;
|
||||
bool resync_flag;
|
||||
bool was_successful;
|
||||
} EngineContext;
|
||||
|
Reference in New Issue
Block a user