From: Brendan Hansen Date: Thu, 18 Nov 2021 03:35:37 +0000 (-0600) Subject: working on windows! not using VS tho X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=21db164aba9d34ed7c71a016a467c6cef9345a07;p=heartbreak.git working on windows! not using VS tho --- diff --git a/.gitignore b/.gitignore index b45a852..146bd95 100644 --- a/.gitignore +++ b/.gitignore @@ -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 index 0000000..e8e72d9 Binary files /dev/null and b/assets/fonts/mononoki-Regular Nerd Font Complete Mono.ttf differ diff --git a/build.bat b/build.bat index 616d965..f9bf23b 100644 --- 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 diff --git a/include/heartbreak.h b/include/heartbreak.h index cf6aa43..e26d93a 100644 --- a/include/heartbreak.h +++ b/include/heartbreak.h @@ -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; diff --git a/src/gfx.c b/src/gfx.c index a4af0d9..8917189 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -1,6 +1,8 @@ #include "gfx.h" #include +#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; } diff --git a/src/heartbreak.c b/src/heartbreak.c index b3eb6bd..181f7f5 100644 --- a/src/heartbreak.c +++ b/src/heartbreak.c @@ -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);