summaryrefslogtreecommitdiff
path: root/chapter32/src/main/c/simple_graphics.h
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-12-04 13:51:35 -0800
committerGitHub <noreply@github.com>2026-12-04 13:51:35 -0800
commit7be87ff4db692a392af1c68abe7752a1da55637f (patch)
treed5e8e68bed74166aeaf4b658f9ce104d1df48c8a /chapter32/src/main/c/simple_graphics.h
parentf0a6c6757a795b8e186de0076836a87acef59fa7 (diff)
parentebdb2c71237506d67cfa8f3bb459b41902840481 (diff)
downloadSimple-7be87ff4db692a392af1c68abe7752a1da55637f.tar.gz
Simple-7be87ff4db692a392af1c68abe7752a1da55637f.zip
Merge pull request #265 from SeaOfNodes/ch32main
Land Chapter 32 compiler performance work and backported fixes
Diffstat (limited to 'chapter32/src/main/c/simple_graphics.h')
-rw-r--r--chapter32/src/main/c/simple_graphics.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/chapter32/src/main/c/simple_graphics.h b/chapter32/src/main/c/simple_graphics.h
new file mode 100644
index 00000000..d19cac46
--- /dev/null
+++ b/chapter32/src/main/c/simple_graphics.h
@@ -0,0 +1,23 @@
+#ifndef SIMPLE_GRAPHICS_H
+#define SIMPLE_GRAPHICS_H
+#include <stdint.h>
+
+// Private, versioned boundary between the tiny runtime loader and MiniFB.
+// All calls run on the main thread. Pixel memory is borrowed for present only.
+struct simple_graphics_api {
+ int32_t version;
+ int32_t (*open)(const char *, uint32_t, uint32_t);
+ int32_t (*present)(const uint32_t *, uint32_t);
+ int32_t (*poll)(int32_t);
+ int32_t (*mouse_x)(void);
+ int32_t (*mouse_y)(void);
+ int32_t (*button)(int32_t);
+ int32_t (*key)(int32_t);
+ void (*close)(void);
+ int32_t (*wait)(int64_t);
+ uint32_t (*width)(void);
+ uint32_t (*height)(void);
+ int32_t (*present_size)(const uint32_t *, uint32_t, uint32_t, uint32_t);
+};
+#define SIMPLE_GRAPHICS_VERSION 3
+#endif