From cfe2db8135b5332c71a9b844cb5136c4bfd120e3 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Tue, 8 Dec 2020 13:47:38 -0500 Subject: got windows build to work --- .gitignore | 2 ++ main.cpp | 2 +- make.bat | 10 +++++----- sim.cpp | 9 +++++---- sim.hpp | 4 ++++ 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 87650be..6001cd5 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,7 @@ TAGS *.exe *.dll *.xcf +*.lib SDL2 +box2d .vs* diff --git a/main.cpp b/main.cpp index 9365a48..ad5daaf 100644 --- a/main.cpp +++ b/main.cpp @@ -4,10 +4,10 @@ #include "gui.hpp" #if DEBUG typedef void (*SimFrameFn)(Frame *); +#include "time.cpp" #else #include "sim.cpp" #endif -#include "time.cpp" #ifdef _WIN32 #include diff --git a/make.bat b/make.bat index a85f7d6..4fdc115 100644 --- a/make.bat +++ b/make.bat @@ -5,11 +5,11 @@ if _%VCVARS% == _ ( ) if not exist obj mkdir obj -SET CFLAGS=/nologo /W3 /D_CRT_SECURE_NO_WARNINGS /I SDL2/include SDL2/lib/x64/SDL2main.lib SDL2/lib/x64/SDL2.lib opengl32.lib +SET CFLAGS=/nologo /W3 /D_CRT_SECURE_NO_WARNINGS /I SDL2/include /I box2d SDL2/lib/x64/SDL2main.lib SDL2/lib/x64/SDL2.lib opengl32.lib box2d.lib /MD if _%1 == _ ( - cl main.c /DDEBUG /DEBUG /Zi %CFLAGS% /Fo:obj/urbs /Fe:physics - cl sim.c /DDEBUG /DEBUG /LD %CFLAGS% /Fo:obj/sim /Fe:obj/sim + cl main.cpp /DDEBUG /DEBUG /Zi %CFLAGS% /Fo:obj/urbs /Fe:physics + cl sim.cpp /DDEBUG /DEBUG /LD %CFLAGS% /Fo:obj/sim /Fe:obj/sim echo > obj\sim.dll_changed ) -if _%1 == _release cl main.c /O2 %CFLAGS% /Fe:physics -if _%1 == _profile cl main.c /O2 /DPROFILE %CFLAGS% /Fe:physics +if _%1 == _release cl main.cpp /O2 %CFLAGS% /Fe:physics +if _%1 == _profile cl main.cpp /O2 /DPROFILE %CFLAGS% /Fe:physics diff --git a/sim.cpp b/sim.cpp index a2bdaf1..906ece9 100644 --- a/sim.cpp +++ b/sim.cpp @@ -258,12 +258,12 @@ static b2Body *platform_to_body(State *state, Platform *platform) { return body; } -#ifdef _WIN32 -__declspec(dllexport) -#endif #ifdef __cplusplus extern "C" #endif +#ifdef _WIN32 +__declspec(dllexport) +#endif void sim_frame(Frame *frame) { if (frame->memory_size < sizeof(State)) { printf("Not enough memory (got %lu, require %lu).\n", (ulong)frame->memory_size, (ulong)sizeof(State)); @@ -295,10 +295,11 @@ void sim_frame(Frame *frame) { glClearColor(0, 0, 0, 1); glClear(GL_COLOR_BUFFER_BIT); +#if DEBUG if (state->magic_number != MAGIC_NUMBER || keys_pressed[KEY_F5]) { memset(state, 0, sizeof *state); } - +#endif if (!state->initialized) { logln("Initializing..."); diff --git a/sim.hpp b/sim.hpp index 176e879..3fdd509 100644 --- a/sim.hpp +++ b/sim.hpp @@ -1,4 +1,8 @@ +#if _WIN32 +#include +#else #include +#endif // enums with a specified width are a clang C extension & available in C++11 #if defined __clang__ || __cplusplus >= 201103L #define ENUM_U8 typedef enum : u8 -- cgit v1.2.3