From daf6262c029892212f6b9b4014887c2c37e9ef75 Mon Sep 17 00:00:00 2001
From: 3gg <3gg@shellblade.net>
Date: Sat, 31 Aug 2024 18:58:39 -0700
Subject: Handle resizing.

---
 gfx-iso/include/isogfx/app.h     | 24 ------------------------
 gfx-iso/include/isogfx/backend.h | 28 ++++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 24 deletions(-)
 delete mode 100644 gfx-iso/include/isogfx/app.h
 create mode 100644 gfx-iso/include/isogfx/backend.h

(limited to 'gfx-iso/include/isogfx')

diff --git a/gfx-iso/include/isogfx/app.h b/gfx-iso/include/isogfx/app.h
deleted file mode 100644
index fe60d04..0000000
--- a/gfx-iso/include/isogfx/app.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#pragma once
-
-#include <gfx/app.h>
-
-#include <stdbool.h>
-
-// TODO: Define an isogfx-gl backend library. Remove all these callbacks.
-
-typedef struct IsoGfx    IsoGfx;
-typedef struct IsoGfxApp IsoGfxApp;
-
-typedef struct IsoGfxAppState IsoGfxAppState;
-
-typedef struct IsoGfxApp {
-  int             pixel_scale; // Use 0 or 1 for 1:1 scaling.
-  IsoGfxAppState* state;
-
-  bool (*init)(IsoGfxAppState*, IsoGfx*, int argc, const char** argv);
-  void (*shutdown)(IsoGfxAppState*, IsoGfx*);
-  void (*update)(IsoGfxAppState*, IsoGfx*, double t, double dt);
-  void (*render)(IsoGfxAppState*, IsoGfx*);
-} IsoGfxApp;
-
-void iso_run(int argc, const char** argv, IsoGfxApp*);
diff --git a/gfx-iso/include/isogfx/backend.h b/gfx-iso/include/isogfx/backend.h
new file mode 100644
index 0000000..172991d
--- /dev/null
+++ b/gfx-iso/include/isogfx/backend.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#include <stdbool.h>
+
+typedef struct Gfx    Gfx;
+typedef struct IsoGfx IsoGfx;
+
+typedef struct IsoBackend IsoBackend;
+
+/// Initialize the backend.
+IsoBackend* IsoBackendInit(const IsoGfx*);
+
+/// Shut down the backend.
+void IsoBackendShutdown(IsoBackend**);
+
+/// Notify the backend of a window resize event.
+/// This allows the backend to determine how to position and scale the iso
+/// screen buffer on the graphics window.
+void IsoBackendResizeWindow(IsoBackend*, const IsoGfx*, int width, int height);
+
+/// Render the iso screen to the graphics window.
+void IsoBackendRender(const IsoBackend*, const IsoGfx*);
+
+/// Map window coordinates to iso space coordinates.
+/// This takes into account any possible resizing done by the backend in
+/// response to calls to IsoBackendResizeWindow().
+bool IsoBackendGetMousePosition(
+    const IsoBackend*, double window_x, double window_y, double* x, double* y);
-- 
cgit v1.2.3