summaryrefslogtreecommitdiff
path: root/3de.c
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-06-30 18:24:01 +1000
committerquou <quou@disroot.org>2024-06-30 18:27:11 +1000
commit39100e7292d3ee12d387fddfa0f0d7b712e31e1c (patch)
tree28f26b19de857868aeb9ecf23a7fecfc170addf9 /3de.c
initial commit.
Diffstat (limited to '3de.c')
-rw-r--r--3de.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/3de.c b/3de.c
new file mode 100644
index 0000000..1b88ae3
--- /dev/null
+++ b/3de.c
@@ -0,0 +1,45 @@
+#include "config.h"
+#include "memory.h"
+#include "plat.h"
+#include "render.h"
+
+#include <stdio.h>
+
+int entrypoint(int argc, const char** argv, Arena* a) {
+ App* app;
+ Renderer r;
+ Heap h;
+ FPS f;
+ char buf[32];
+ Colour blue = make_aliceblue();
+ (void)argc;
+ (void)argv;
+ init_heap(
+ &h,
+ arena_alloc(a, app_memory_size),
+ app_memory_size
+ );
+ app = new_app(&h, 640, 480, "3D Engine");
+ if (!app) return app->err;
+ init_fps(&f, 20);
+ while (app->o) {
+ fps_begin(&f);
+ while (f.now >= f.next) {
+ app_begin(app);
+ ren_begin(&r, app->fb, app->w, app->h);
+ ren_clear(&r);
+ sprintf(buf, "FPS: %d", app->fps);
+ ren_text(&r, blue, 3, 3, buf);
+ sprintf(buf, "CAP: %d", f.fps);
+ ren_text(&r, blue, 3, 13, buf);
+ sprintf(buf, "MOUSE: %d, %d", app->mx, app->my);
+ ren_text(&r, blue, 3, 23, buf);
+ ren_end(&r);
+ app_end(app);
+ fps_update(&f);
+ }
+ fps_end(&f);
+ }
+ deinit_app(app);
+ return 0;
+}