working on windows! not using VS tho
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 18 Nov 2021 03:35:37 +0000 (21:35 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 18 Nov 2021 03:35:37 +0000 (21:35 -0600)
.gitignore
assets/fonts/mononoki-Regular Nerd Font Complete Mono.ttf [new file with mode: 0644]
build.bat
include/heartbreak.h
src/gfx.c
src/heartbreak.c

index b45a8528efba839f634a269347ed47aeb0833504..146bd95fee7b4993f4b556b24c154d231107ca66 100644 (file)
@@ -1,4 +1,11 @@
 *.o
 *.wasm
+*.exe
+*.pdb
+*.ilk
+*.obj
+*.rdbg
 bin/heartbreak
-.vscode/
\ No newline at end of file
+.vscode/
+*.sublime-project
+*.sublime-workspace
\ No newline at end of file
diff --git a/assets/fonts/mononoki-Regular Nerd Font Complete Mono.ttf b/assets/fonts/mononoki-Regular Nerd Font Complete Mono.ttf
new file mode 100644 (file)
index 0000000..e8e72d9
Binary files /dev/null and b/assets/fonts/mononoki-Regular Nerd Font Complete Mono.ttf differ
index 616d965b6103b38e8a061d1efdbed53088d8a232..f9bf23b389de540fe7d42f342d045fc3d6b4ff0e 100644 (file)
--- a/build.bat
+++ b/build.bat
@@ -1,6 +1,6 @@
 @echo off
 
-set FLAGS=/Od /MDT /Z7 /TC /std:c17
+set FLAGS=/O2 /MT /Z7 /TC /std:c17
 set SOURCE=src/gfx.c src/heartbreak.c src/heartbreak_graphics.c src/heartbreak_input.c src/heartbreak_system.c src/heartbreak_window.c src/utils.c
 set LIBS=lib\windows_x86_64\lib\wasmer.lib C:\tools\glfw-3.3.5.bin.WIN64\lib-vc2019\glfw3.lib C:\tools\glfw-3.3.5.bin.WIN64\lib-vc2019\glfw3dll.lib opengl32.lib ws2_32.lib Advapi32.lib userenv.lib bcrypt.lib
 set LINKFLAGS=/incremental:no /opt:ref /subsystem:console
index cf6aa435e816129c7bbb66fbb48e1e4b0900928b..e26d93ad548187525ff7ff53f09fb07d1406b6fa 100644 (file)
@@ -31,18 +31,8 @@ extern ImmediateRenderer renderer;
 // Helper macro to easily define WASM-interface functions
 //
 
-#ifdef _MSC_VER // Microsoft compilers
-#   define GET_ARG_COUNT(...)  INTERNAL_EXPAND_ARGS_PRIVATE(INTERNAL_ARGS_AUGMENTER(__VA_ARGS__))
-#   define INTERNAL_ARGS_AUGMENTER(...) unused, __VA_ARGS__
-#   define INTERNAL_EXPAND(x) x
-#   define INTERNAL_EXPAND_ARGS_PRIVATE(...) INTERNAL_EXPAND(INTERNAL_GET_ARG_COUNT_PRIVATE(__VA_ARGS__, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0))
-#   define INTERNAL_GET_ARG_COUNT_PRIVATE(_1_, _2_, _3_, _4_, _5_, _6_, _7_, _8_, _9_, _10_, _11_, _12_, _13_, _14_, _15_, _16_, _17_, _18_, _19_, _20_, _21_, _22_, _23_, _24_, _25_, _26_, _27_, _28_, _29_, _30_, _31_, _32_, _33_, _34_, _35_, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, count, ...) count
-#else // Non-Microsoft compilers
-#   define GET_ARG_COUNT(...) INTERNAL_GET_ARG_COUNT_PRIVATE(0, ## __VA_ARGS__, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
-#   define INTERNAL_GET_ARG_COUNT_PRIVATE(_0, _1_, _2_, _3_, _4_, _5_, _6_, _7_, _8_, _9_, _10_, _11_, _12_, _13_, _14_, _15_, _16_, _17_, _18_, _19_, _20_, _21_, _22_, _23_, _24_, _25_, _26_, _27_, _28_, _29_, _30_, _31_, _32_, _33_, _34_, _35_, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, count, ...) count
-#endif
-
-#define _VALS(...) { GET_ARG_COUNT(__VA_ARGS__), __VA_ARGS__ }
+#define NUM_VALS(...) (sizeof((wasm_valkind_t []){ 0, __VA_ARGS__ }) / sizeof(wasm_valkind_t))
+#define _VALS(...) { NUM_VALS(__VA_ARGS__) - 1, __VA_ARGS__ }
 
 typedef struct WasmValkindBuffer {
     u32 count;
index a4af0d9ec92c6f9ef1082f63c037bac269623610..8917189256cada6a9cf96db1ce2ce943035cbec8 100644 (file)
--- a/src/gfx.c
+++ b/src/gfx.c
@@ -1,6 +1,8 @@
 #include "gfx.h"
 #include <math.h>
 
+#define DEFAULT_FONT_PATH "assets/fonts/mononoki-Regular Nerd Font Complete Mono.ttf"
+
 static const char* SIMPLE_SHADER_VERTEX = "#version 300 es\n"
 "precision mediump float;\n"
 "layout(location = 0) in vec2 a_vertex;\n"
@@ -260,8 +262,7 @@ void gfx_immediate_renderer_init(ImmediateRenderer *ir, bh_allocator allocator)
     ir->current_color = (ImmediateColor) { 1, 1, 1, 1 };
     ir->world_transform_dirty = 1;
 
-    // @TODO Use a font that is within this project
-    ir->default_font = gfx_font_load(ir, "/usr/share/fonts/nerd-fonts-complete/TTF/mononoki-Regular Nerd Font Complete Mono.ttf", 32.0f);
+    ir->default_font = gfx_font_load(ir, DEFAULT_FONT_PATH, 32.0f);
     ir->active_font  = ir->default_font;
 }
 
index b3eb6bdce0bd0892724924f40e183e69b370e287..181f7f57f9dac453250e898a6b07cfb005a2e6f9 100644 (file)
@@ -160,7 +160,7 @@ void run_wasm_file(bh_buffer wasm_bytes) {
         goto bad_import;
 
     import_found:
-        bh_printf("Found import %b.%b.\n", module_name->data, module_name->size, import_name->data, import_name->size);
+        // bh_printf("Found import %b.%b.\n", module_name->data, module_name->size, import_name->data, import_name->size);
         imports.data[i] = import;
         continue;
 
@@ -205,6 +205,10 @@ void run_wasm_file(bh_buffer wasm_bytes) {
 
 error_handling:
     logprint(ERROR, "An error occured trying to run the WASM module...\n");
+    i32 len = wasmer_last_error_length();
+    char *buf = alloca(len + 1);
+    wasmer_last_error_message(buf, len);
+    bh_printf("%b\n", buf, len);
 
 cleanup:
     if (wasm_instance) wasm_instance_delete(wasm_instance);