townengine/src/context.h

71 lines
1.7 KiB
C
Raw Normal View History

2024-07-08 00:44:20 +00:00
#ifndef CONTEXT_H
#define CONTEXT_H
#include "textures.h"
#include "input.h"
#include <SDL2/SDL.h>
#include <stdbool.h>
#include <stdint.h>
typedef struct context {
/* the program's actual argc and argv */
int argc;
char **argv;
struct texture_cache texture_cache;
struct input_state input;
struct primitive_2d *render_queue_2d;
struct mesh_batch_item *uncolored_mesh_batches;
struct audio_channel_item *audio_channels;
2024-07-08 06:46:12 +00:00
SDL_AudioDeviceID audio_device;
int audio_stream_frequency;
SDL_AudioFormat audio_stream_format;
uint8_t audio_stream_channel_count;
2024-07-08 00:44:20 +00:00
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;
2024-07-08 00:44:20 +00:00
int64_t time_averager[4];
int64_t delta_time; /* preserves real time frame delta with no manipilation */
2024-07-08 00:44:20 +00:00
uint64_t tick_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_GLContext *gl_context;
2024-07-08 00:44:20 +00:00
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;
bool window_size_has_changed;
2024-07-08 00:44:20 +00:00
} t_ctx;
extern t_ctx ctx;
#endif