#ifndef CONTEXT_H #define CONTEXT_H #include "private/rendering.h" #include "textures.h" #include "input.h" #include #include #include typedef struct context { /* the program's actual argc and argv */ int argc; char **argv; struct texture_cache texture_cache; struct input_state input; struct sprite_primitive *render_queue_sprites; struct rect_primitive *render_queue_rectangles; struct circle_primitive *render_queue_circles; struct audio_channel_pair *audio_channels; SDL_AudioDeviceID audio_device; int audio_stream_frequency; SDL_AudioFormat audio_stream_format; uint8_t audio_stream_channel_count; struct circle_radius_cache_item *circle_radius_hash; /* main loop machinery */ int64_t clocks_per_second; int64_t prev_frame_time; int64_t desired_frametime; /* how long one tick should be */ int64_t frame_accumulator; int64_t delta_averager_residual; int64_t time_averager[4]; uint64_t tick_count; uint64_t step_count; /* set just once on startup */ uint64_t random_seed; /* this should be a multiple of 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 */ unsigned int update_multiplicity; SDL_Renderer *renderer; SDL_Window *window; uint32_t window_id; int window_w; int window_h; bool was_successful; /* you may read from and write to these from game code */ void *udata; bool debug; bool is_running; bool resync_flag; } t_ctx; extern t_ctx ctx; #endif