From adb89aaca8c82149b23cc8bde63dc2c5f703c4e4 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Fri, 22 Aug 2025 07:59:12 -0700 Subject: Fix issue with global GfxApp instance across plugins --- app/include/gfx/app.h | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'app/include') diff --git a/app/include/gfx/app.h b/app/include/gfx/app.h index 77b6ad2..639fa2d 100644 --- a/app/include/gfx/app.h +++ b/app/include/gfx/app.h @@ -1,7 +1,6 @@ #pragma once -#include - +typedef struct GfxApp GfxApp; typedef struct GfxAppState GfxAppState; /// Application settings. @@ -16,11 +15,11 @@ typedef struct GfxAppDesc { GfxAppState* app_state; } GfxAppDesc; -typedef bool (*GfxAppInit)(GfxAppState*, int argc, const char** argv); -typedef void (*GfxAppShutdown)(GfxAppState*); -typedef void (*GfxAppUpdate)(GfxAppState*, double t, double dt); -typedef void (*GfxAppRender)(GfxAppState*); -typedef void (*GfxAppResize)(GfxAppState*, int width, int height); +typedef bool (*GfxAppInit)(GfxApp*, GfxAppState*, int argc, const char** argv); +typedef void (*GfxAppShutdown)(GfxApp*, GfxAppState*); +typedef void (*GfxAppUpdate)(GfxApp*, GfxAppState*, double t, double dt); +typedef void (*GfxAppRender)(const GfxApp*, GfxAppState*); +typedef void (*GfxAppResize)(GfxApp*, GfxAppState*, int width, int height); /// Application callback functions. typedef struct GfxAppCallbacks { @@ -74,13 +73,13 @@ extern "C" { bool gfx_app_run(const GfxAppDesc*, const GfxAppCallbacks*); /// Get the mouse coordinates relative to the app's window. -void gfx_app_get_mouse_position(double* x, double* y); +void gfx_app_get_mouse_position(GfxApp*, double* x, double* y); /// Return if the given mouse button is pressed. -bool gfx_app_is_mouse_button_pressed(MouseButton); +bool gfx_app_is_mouse_button_pressed(GfxApp*, MouseButton); /// Return true if the given key is pressed. -bool gfx_app_is_key_pressed(Key); +bool gfx_app_is_key_pressed(GfxApp*, Key); #ifdef __cplusplus } // extern "C" @@ -102,11 +101,10 @@ bool gfx_app_is_key_pressed(Key); .title = TITLE, \ .app_state = &app_state, \ }, \ - &(GfxAppCallbacks){ \ - .init = (GfxAppInit)Init, \ - .shutdown = (GfxAppShutdown)Shutdown, \ - .update = (GfxAppUpdate)Update, \ - .render = (GfxAppRender)Render, \ - .resize = (GfxAppResize)Resize}); \ + &(GfxAppCallbacks){.init = Init, \ + .shutdown = Shutdown, \ + .update = Update, \ + .render = Render, \ + .resize = Resize}); \ return 0; \ } -- cgit v1.2.3