summaryrefslogtreecommitdiff
path: root/ctx.h
diff options
context:
space:
mode:
Diffstat (limited to 'ctx.h')
-rw-r--r--ctx.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/ctx.h b/ctx.h
new file mode 100644
index 0000000..3bc93f9
--- /dev/null
+++ b/ctx.h
@@ -0,0 +1,39 @@
+prge_context_t init_prge(void)
+{
+ prge_context_t ctx = {0};
+ ctx.arena = alloc_arena(ARENA_SIZE);
+ ctx.frame_arena = alloc_arena(FRAME_ARENA_SIZE);
+ ctx.input = init_input();
+ ctx.dir = sys_getbindir(&ctx.arena);
+ assert(ctx.dir);
+ printf("[INFO]\tBinary dir\t\"%s\"\n", ctx.dir);
+ return ctx;
+}
+
+texture_t prge_load_texture(prge_context_t *ctx, const char *filename, i32 gamma)
+{
+ char full_path[MAX_PATH];
+ snprintf(full_path, sizeof(full_path), "%s/%s", ctx->dir, filename);
+ texture_t texture = load_texture(&ctx->arena, full_path, gamma);
+ return texture;
+}
+
+model_t prge_load_model(prge_context_t *ctx, transform_t transform, const char *filename)
+{
+ char full_path[MAX_PATH];
+ snprintf(full_path, sizeof(full_path), "%s/%s", ctx->dir, filename);
+ model_t model = load_model_obj(&ctx->arena, transform, full_path);
+ return model;
+}
+
+i32 prge_load_sound_vorbis(prge_context_t *ctx, const char *filename)
+{
+ char full_path[MAX_PATH];
+ snprintf(full_path, sizeof(full_path), "%s/%s", ctx->dir, filename);
+ return load_vorbis(&ctx->arena, ctx->sounds, full_path);
+}
+
+void prge_play_sound(prge_context_t *ctx, i32 id)
+{
+ play_sound(ctx->sounds, &ctx->sound_queue, ctx->sound_queue_nodes, id);
+}