From dca1cffb6975ab6104a542861b9ac79777e4de98 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Tue, 24 Aug 2021 20:29:40 +0900 Subject: [PATCH 1/5] Support for windows build via mingw-w64 --- example02_threaded_raytracing/buildWin/Makefile | 13 +++++++++++++ example02_threaded_raytracing/src/rayTracer.cpp | 12 +++++++++--- example02_threaded_raytracing/src/rayTracer.hpp | 12 +++++++++--- 3 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 example02_threaded_raytracing/buildWin/Makefile diff --git a/example02_threaded_raytracing/buildWin/Makefile b/example02_threaded_raytracing/buildWin/Makefile new file mode 100644 index 0000000..75ad497 --- /dev/null +++ b/example02_threaded_raytracing/buildWin/Makefile @@ -0,0 +1,13 @@ +CXX=x86_64-w64-mingw32-g++ +CXXFLAGS=-O3 -DNDEBUG + +all: Example02.exe + +Example02.exe: ../src/main.o ../src/rayTracer.o ../src/argParse.o + $(CXX) -o Example02.exe -lpthread $^ + +.PHONY: + +clean: + rm -f Example02.exe + rm -f ../src/*.o diff --git a/example02_threaded_raytracing/src/rayTracer.cpp b/example02_threaded_raytracing/src/rayTracer.cpp index 50036d0..1da58c6 100644 --- a/example02_threaded_raytracing/src/rayTracer.cpp +++ b/example02_threaded_raytracing/src/rayTracer.cpp @@ -5,9 +5,15 @@ #include #include -#include -#include -#include +#ifdef __MINGW32__ +# include "/usr/include/glm/ext/matrix_transform.hpp" +# include "/usr/include/glm/gtc/matrix_transform.hpp" +# include "/usr/include/glm/matrix.hpp" +#else +# include +# include +# include +#endif const float PI = std::acos(-1.0F); diff --git a/example02_threaded_raytracing/src/rayTracer.hpp b/example02_threaded_raytracing/src/rayTracer.hpp index 2f5307d..59018fa 100644 --- a/example02_threaded_raytracing/src/rayTracer.hpp +++ b/example02_threaded_raytracing/src/rayTracer.hpp @@ -12,9 +12,15 @@ constexpr float EX02_RAY_TRACER_GRAY_SPHERE_RADIUS = 1.5F; #include #include -#include -#include -#include +#ifdef __MINGW32__ +# include "/usr/include/glm/mat4x4.hpp" +# include "/usr/include/glm/matrix.hpp" +# include "/usr/include/glm/vec3.hpp" +#else +# include +# include +# include +#endif namespace Ex02::RT { From a34cec881d0cea559d1f2ed8147f5ad14afe4b81 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Tue, 24 Aug 2021 20:31:05 +0900 Subject: [PATCH 2/5] Update .gitignore Windows build leaves built objs in src directory. --- example02_threaded_raytracing/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/example02_threaded_raytracing/.gitignore b/example02_threaded_raytracing/.gitignore index eb32573..1a1bdad 100644 --- a/example02_threaded_raytracing/.gitignore +++ b/example02_threaded_raytracing/.gitignore @@ -1,3 +1,4 @@ build*/ compile_commands.json .cache/ +src/*.o From d4ff58db533d2a7e0216ab96f6c12f88a2116b29 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Tue, 24 Aug 2021 20:33:16 +0900 Subject: [PATCH 3/5] Fix buildWin/Makefile --- example02_threaded_raytracing/buildWin/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example02_threaded_raytracing/buildWin/Makefile b/example02_threaded_raytracing/buildWin/Makefile index 75ad497..0809acc 100644 --- a/example02_threaded_raytracing/buildWin/Makefile +++ b/example02_threaded_raytracing/buildWin/Makefile @@ -4,7 +4,7 @@ CXXFLAGS=-O3 -DNDEBUG all: Example02.exe Example02.exe: ../src/main.o ../src/rayTracer.o ../src/argParse.o - $(CXX) -o Example02.exe -lpthread $^ + $(CXX) -o Example02.exe -lpthread -Wl,-subsystem,windows $^ .PHONY: From 9cff49e09d2febb42346ad98106f0decd715a5f1 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Tue, 24 Aug 2021 20:36:57 +0900 Subject: [PATCH 4/5] Revert "Fix buildWin/Makefile" This reverts commit d4ff58db533d2a7e0216ab96f6c12f88a2116b29. A console window will probably be handy for the outputs that are text-only. --- example02_threaded_raytracing/buildWin/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example02_threaded_raytracing/buildWin/Makefile b/example02_threaded_raytracing/buildWin/Makefile index 0809acc..75ad497 100644 --- a/example02_threaded_raytracing/buildWin/Makefile +++ b/example02_threaded_raytracing/buildWin/Makefile @@ -4,7 +4,7 @@ CXXFLAGS=-O3 -DNDEBUG all: Example02.exe Example02.exe: ../src/main.o ../src/rayTracer.o ../src/argParse.o - $(CXX) -o Example02.exe -lpthread -Wl,-subsystem,windows $^ + $(CXX) -o Example02.exe -lpthread $^ .PHONY: From c2e865df7d12c4c548076a92ae8c75bca0530c3a Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Tue, 24 Aug 2021 20:39:04 +0900 Subject: [PATCH 5/5] Move commented code to area that makes more sense --- example02_threaded_raytracing/src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example02_threaded_raytracing/src/main.cpp b/example02_threaded_raytracing/src/main.cpp index acc7aa1..25a2720 100644 --- a/example02_threaded_raytracing/src/main.cpp +++ b/example02_threaded_raytracing/src/main.cpp @@ -125,11 +125,11 @@ int main(int argc, char **argv) { } } - // auto pixels = Ex02::RT::renderGraySphere( - // outputWidth, outputHeight, threadCount); std::cout << "Rendering image of width " << outputWidth << " and height " << outputHeight << " with " << threadCount << " thread(s)..." << std::endl; + // auto pixels = Ex02::RT::renderGraySphere( + // outputWidth, outputHeight, threadCount); auto pixels = Ex02::RT::renderColorsWithSpheres(outputWidth, outputHeight, threadCount);