townengine/src/twn_engine_context_c.h

54 lines
1.2 KiB
C
Raw Normal View History

#ifndef TWN_ENGINE_CONTEXT_C_H
#define TWN_ENGINE_CONTEXT_C_H
2024-07-08 00:44:20 +00:00
#include "twn_context.h"
#include "twn_textures_c.h"
2024-09-18 17:36:00 +00:00
#include "twn_engine_api.h"
#include "twn_input.h"
#include "rendering/twn_rendering_c.h"
2024-07-08 00:44:20 +00:00
#include <SDL2/SDL.h>
#include <stdbool.h>
#include <stdint.h>
typedef struct engine_context {
/* user code facing context */
t_ctx game;
2024-07-08 00:44:20 +00:00
/* the program's actual argc and argv */
int argc;
char **argv;
struct primitive_2d *render_queue_2d;
struct mesh_batch_item *uncolored_mesh_batches;
2024-08-23 02:41:52 +00:00
struct text_cache text_cache;
struct texture_cache texture_cache;
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
/* 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];
SDL_GLContext *gl_context;
2024-07-08 00:44:20 +00:00
SDL_Window *window;
uint32_t window_id;
2024-07-30 15:19:04 +00:00
2024-07-08 00:44:20 +00:00
bool resync_flag;
2024-07-30 15:19:04 +00:00
bool was_successful;
} t_engine_ctx;
2024-07-08 00:44:20 +00:00
2024-09-18 17:36:00 +00:00
TWN_API extern t_engine_ctx ctx;
2024-07-08 00:44:20 +00:00
#endif