roleplay/client/include/engine.h

83 lines
1.8 KiB
C

#ifndef ENGINE_H
#define ENGINE_H
#include "GLFW/glfw3.h"
#include "gpu.h"
#include "ui.h"
#include "hex.h"
#include "events.h"
#include "camera.h"
typedef struct ClientContextStruct ClientContext;
typedef void (*app_text_callback)(
ClientContext* context,
unsigned int codepoint);
typedef void (*app_key_callback)(
ClientContext* context,
int key,
int action,
int mods);
typedef void (*app_button_callback)(
ClientContext* context,
float x,
float y,
int button,
int action,
int mods);
typedef void (*app_scroll_callback)(
ClientContext* context,
double x,
double y);
typedef void (*app_cursor_callback)(
ClientContext* context,
float x,
float y);
typedef void (*app_frame_function)(
ClientContext* context,
double delta_time);
typedef void (*app_startup_function)(
ClientContext* context);
struct ClientContextStruct {
GLFWwindow* window;
RenderContext render;
UIContext ui;
HexContext hex;
EventBus events;
Camera camera;
// Nullable, non-owning. Set by the app to render a second camera's scene
// into an offscreen texture each frame (see camera_init_texture_target,
// camera.h) - NULL (the zero-init default) skips that pass entirely, so
// apps that don't opt in see no behavior change.
Camera* offscreen_camera;
void* app_data;
app_frame_function app_frame;
app_text_callback app_text;
app_key_callback app_key;
app_button_callback app_button;
app_scroll_callback app_scroll;
app_cursor_callback app_cursor;
};
int run_app(
void* app_data,
app_startup_function app_startup,
app_frame_function app_frame,
app_text_callback app_text,
app_key_callback app_key,
app_button_callback app_button,
app_scroll_callback app_scroll,
app_cursor_callback app_cursor);
#endif