summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authornavewindre <boneyaard@gmail.com>2025-09-03 20:10:09 +0200
committernavewindre <boneyaard@gmail.com>2025-09-03 20:10:09 +0200
commitf8b92ce3aa08b1445c9f956d8166830946562d12 (patch)
tree94e63a5aec9f8f52b577f56799e0c9201fd976a5 /src/main.cpp
a
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..28886fa
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,49 @@
+#include "game.h"
+#include "game/assets.h"
+
+// disable new_delete_type_mismatch asan warning
+#ifndef __has_feature
+ #define __has_feature(feature) 0
+#endif
+#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
+ #ifdef __cplusplus
+ extern "C"
+ #endif
+ const char *__asan_default_options() { return "new_delete_type_mismatch=0"; }
+#endif
+
+I32* canvas;
+GAME_DATA* game;
+GL_DATA* gl;
+
+void loop() {
+ static U8 init = 0;
+
+ if( !init || !gl ) {
+ gl = gl_create( canvas );
+ memcpy( gl->canvas_size, canvas, sizeof(I32) * 2 );
+
+ gl_gen_buffers( gl );
+ game = game_init( gl );
+
+ init = 1;
+ return;
+ }
+
+ game_main_loop( game );
+}
+
+int main() {
+ if( !canvas )
+ canvas = (I32*)malloc( sizeof(I32) * 2 );
+
+ canvas[0] = 800;
+ canvas[1] = 600;
+
+ while( true ) {
+ loop();
+ }
+
+ game_destroy( game );
+ return 0;
+}