Nimbin[12]?Games / Entropie / entropie/src/core/platform.h

Entropie git · main

Entropie festival game; first steps

sdl c game entropie cmake · first commit 2026-10-10 · last commit 2026-11-02 (18 hours ago) · synced 10 hours ago

C 88.5% Markdown 9.1% GLSL 2.3%
git clone https://git.christianimmanuel.de/games/Entropie.gitwget https://git.christianimmanuel.de/games/Entropie/archive/Entropie.tar.gz
entropie/src/core/platform.h 1.7 KB · 46 lines raw
#ifndef CORE_PLATFORM_H
#define CORE_PLATFORM_H

/* Window, OpenGL context, frame timing and asset lookup (SDL3). */

#include <stdbool.h>
#include <stddef.h>
#include <SDL3/SDL.h>

typedef struct {
    SDL_Window   *window;
    SDL_GLContext gl_context;
    Uint64        last_ticks_ns;
    Uint64        frame_start_ns; /* (the frame cap: when the last frame was shown) */
    bool          sdl_ready;
} Platform;

bool  Platform_init(Platform *p, const char *title, int width, int height);
void  Platform_shutdown(Platform *p);

/* Seconds elapsed since the previous call (or since init). */
float Platform_frameDelta(Platform *p);

/* Framebuffer size in pixels (HiDPI aware). */
void  Platform_drawableSize(const Platform *p, int *width, int *height);
/* Shows the frame: vsync, and never more than FRAME_CAP frames a second (the GPU gets to rest). */
#define FRAME_CAP 60
void  Platform_swap(Platform *p);
/* Window size in window coordinates (the mouse uses these). */
void  Platform_windowSize(const Platform *p, int *width, int *height);
/* Mouse captured for looking around (hidden), or a free pointer (menus). */
void  Platform_captureMouse(const Platform *p, bool captured);

/*
 * Builds the full path of an asset (e.g. "shaders/basic.vert").
 * Looks next to the executable first ("<exe dir>/assets/"),
 * then in the install location (ASSET_DIR, set by the Makefile).
 */
bool  Platform_assetPath(const char *relative, char *out, size_t out_size);

/* Where the saves go (the user's data folder: e.g. ~/.local/share/entropie/entropie/saves). */
bool  Platform_saveDir(char *out, size_t out_size);
/* Typing text on / off (a save's name): letters come as Input.text, not as keys. */
void  Platform_typing(const Platform *p, bool on);

#endif /* CORE_PLATFORM_H */