diff options
| author | Mel <einebeere@gmail.com> | 2022-10-08 03:18:06 +0200 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2022-10-08 03:18:06 +0200 |
| commit | 56c86cefa3233bdc94aa1c62ec04dada501c1ccf (patch) | |
| tree | 3a24d8905db3f803ecf1a969bd42ce1eee19d65f | |
| parent | fdbfa8e36f85eee051fc562f1a8588970257a20f (diff) | |
| download | meowcraft-56c86cefa3233bdc94aa1c62ec04dada501c1ccf.tar.zst meowcraft-56c86cefa3233bdc94aa1c62ec04dada501c1ccf.zip | |
Store assets nicely
| -rw-r--r-- | CMakeLists.txt | 19 | ||||
| -rw-r--r-- | assets/shaders/fragment.glsl (renamed from src/Shader/fragment.glsl) | 0 | ||||
| -rw-r--r-- | assets/shaders/vertex.glsl (renamed from src/Shader/vertex.glsl) | 0 | ||||
| -rw-r--r-- | src/Assets.cpp | 17 | ||||
| -rw-r--r-- | src/Assets.hpp | 18 | ||||
| -rw-r--r-- | src/Shader/Shader.hpp | 6 | ||||
| -rw-r--r-- | src/Shader/ShaderSources.hpp | 13 |
7 files changed, 52 insertions, 21 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b2f0f90..25abc3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,11 +4,18 @@ project(meowcraft) set(CMAKE_CXX_STANDARD 17) find_package(glfw3 3.3 REQUIRED) -find_package(OpenGL REQUIRED) find_package(GLEW REQUIRED) -add_executable(meowcraft src/main.cpp src/Window.cpp src/Window.hpp src/Mesh.cpp src/Mesh.hpp src/Math/Vector.hpp src/Math/Math.hpp src/Binder.cpp src/Binder.hpp src/Shader/ShaderSources.hpp src/Shader/Shader.cpp src/Shader/Shader.hpp src/Shader/ShaderProgram.cpp src/Shader/ShaderProgram.hpp src/Math/Matrix.hpp src/Math/MVP.cpp src/Math/MVP.hpp src/Camera.cpp src/Camera.hpp src/Math/Rotation.hpp src/Shader/Uniform.cpp src/Shader/Uniform.hpp src/Mouse.cpp src/Mouse.hpp src/Math/Trig.hpp) -target_link_libraries(meowcraft glfw GLEW::GLEW OpenGL) +if (LINUX) + find_package(OpenGL REQUIRED) +endif (LINUX) + +add_executable(meowcraft src/main.cpp src/Window.cpp src/Window.hpp src/Mesh.cpp src/Mesh.hpp src/Math/Vector.hpp src/Math/Math.hpp src/Binder.cpp src/Binder.hpp src/Shader/Shader.cpp src/Shader/Shader.hpp src/Shader/ShaderProgram.cpp src/Shader/ShaderProgram.hpp src/Math/Matrix.hpp src/Math/MVP.cpp src/Math/MVP.hpp src/Camera.cpp src/Camera.hpp src/Math/Rotation.hpp src/Shader/Uniform.cpp src/Shader/Uniform.hpp src/Mouse.cpp src/Mouse.hpp src/Math/Trig.hpp src/Texture.cpp src/Texture.hpp src/Assets.cpp src/Assets.hpp src/Image/RawImage.cpp src/Image/RawImage.hpp src/Image/PPMParser.cpp src/Image/PPMParser.hpp) +target_link_libraries(meowcraft glfw GLEW::GLEW) + +if (LINUX) + target_link_libraries(meowcraft OpenGL) +endif (LINUX) function(make_includable input_file output_file) file(READ ${input_file} content) @@ -17,5 +24,7 @@ function(make_includable input_file output_file) file(WRITE ${output_file} "${content}") endfunction(make_includable) -make_includable(src/Shader/fragment.glsl src/Shader/Generated/fragment.glsl.includable) -make_includable(src/Shader/vertex.glsl src/Shader/Generated/vertex.glsl.includable) \ No newline at end of file +make_includable(assets/shaders/fragment.glsl assets/generated/shaders/fragment.glsl.includable) +make_includable(assets/shaders/vertex.glsl assets/generated/shaders/vertex.glsl.includable) + +make_includable(assets/images/atlas.ppm assets/generated/images/atlas.ppm.includable) \ No newline at end of file diff --git a/src/Shader/fragment.glsl b/assets/shaders/fragment.glsl index ba5ed93..ba5ed93 100644 --- a/src/Shader/fragment.glsl +++ b/assets/shaders/fragment.glsl diff --git a/src/Shader/vertex.glsl b/assets/shaders/vertex.glsl index e7b9e3d..e7b9e3d 100644 --- a/src/Shader/vertex.glsl +++ b/assets/shaders/vertex.glsl diff --git a/src/Assets.cpp b/src/Assets.cpp new file mode 100644 index 0000000..ffd09ec --- /dev/null +++ b/src/Assets.cpp @@ -0,0 +1,17 @@ +#include "Assets.hpp" + +namespace MC::Assets { + +const char* Shaders::fragment = +#include "../assets/generated/shaders/fragment.glsl.includable" +; + +const char* Shaders::vertex = +#include "../assets/generated/shaders/vertex.glsl.includable" +; + +const char* Images::atlas = +#include "../assets/generated/images/atlas.ppm.includable" +; + +} \ No newline at end of file diff --git a/src/Assets.hpp b/src/Assets.hpp new file mode 100644 index 0000000..641125a --- /dev/null +++ b/src/Assets.hpp @@ -0,0 +1,18 @@ +#pragma once + +namespace MC::Assets { + +namespace Shaders { + +extern const char* vertex; +extern const char* fragment; + +} + +namespace Images { + +extern const char* atlas; + +} + +} \ No newline at end of file diff --git a/src/Shader/Shader.hpp b/src/Shader/Shader.hpp index 75c4f14..76a1197 100644 --- a/src/Shader/Shader.hpp +++ b/src/Shader/Shader.hpp @@ -1,7 +1,7 @@ #pragma once #include <cstdint> -#include "ShaderSources.hpp" +#include "../Assets.hpp" namespace MC { @@ -13,11 +13,11 @@ public: } static Shader create_vertex() { - return {GL_VERTEX_SHADER, ShaderSources::vertex_shader}; + return {GL_VERTEX_SHADER, Assets::Shaders::vertex}; } static Shader create_fragment() { - return {GL_FRAGMENT_SHADER, ShaderSources::fragment_shader}; + return {GL_FRAGMENT_SHADER, Assets::Shaders::fragment}; } private: diff --git a/src/Shader/ShaderSources.hpp b/src/Shader/ShaderSources.hpp deleted file mode 100644 index bd413b6..0000000 --- a/src/Shader/ShaderSources.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -namespace MC::ShaderSources { - -constexpr const char* vertex_shader = -#include "Generated/vertex.glsl.includable" -; - -constexpr const char* fragment_shader = -#include "Generated/fragment.glsl.includable" -; - -} \ No newline at end of file |
