From 3fdeb074c15841bb788eeb2ebf1b295ca1f065db Mon Sep 17 00:00:00 2001 From: Lauchmelder23 Date: Mon, 25 Jan 2021 02:33:21 +0100 Subject: [PATCH] Fixed macos build problems --- .DS_Store | Bin 0 -> 8196 bytes .gitignore | 2 ++ CMakeLists.txt | 6 +++--- examples/.DS_Store | Bin 0 -> 6148 bytes examples/debug/CMakeLists.txt | 20 +++++++++++++++++--- examples/debug/main.cpp | 4 ++-- examples/movement/CMakeLists.txt | 20 +++++++++++++++++--- examples/movement/main.cpp | 4 ++-- include/shader.hpp | 14 ++++++++++---- include/texture.hpp | 8 ++++++-- include/vertexArray.hpp | 11 ++++++++--- src/object.cpp | 5 +++-- src/shader.cpp | 6 +++--- 13 files changed, 73 insertions(+), 27 deletions(-) create mode 100644 .DS_Store create mode 100644 examples/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..2438dcdad8466d77b8d78bbf2da2475e0a9392b4 GIT binary patch literal 8196 zcmeHM(QeZ)6un-%HSGlS0cm~A14ukfQzs}zLP(`+A1VPt1i=HKt!WFbmL^r3t}CS| zFMI@i01}_V7w{o`0Gw-EQ+e{j_ZtwM19)bCn^z*0qD^&r5Sl9V5kn|C?%V7RtZ9rC zDmn>8C!wD#^a(}Cr-NrpcM>&)CN~Ng1y&W{v->8wG^GJ~iSs)zq`OEren^wln5R3N zjPyzWt2^=rldxR=CN?tJ&8?he6|BOg!YijA%$%?tPAB#D_yu1*ZijtWm!AfKcUEq@ z&j!8OVe#rg;D_yj-y2KvpxcAX%jW~X8_ep#)bCDYJC3?xS$QjeSS&3Tm1Y4cb=ZW^FB2&d7230FulrT@Z*dOrq!4_$#!M1<6c{G0?yY4I_Z0Y z>EO#rHBPq6qZ8L+qeJ(#@uatr7;73Mg#z)11{RM2I=ib7!T9 zXq>j&_oA{=U9GK2*^rI(#<_Q`CSK~N*|_JAPN{d~r`G}7$4bSIwjZ2CgULnn!&jB0 zev}MGIynjl7;^S4NZ=1A{RBX) zqFW2vR0}D`VRRXDgE)dBOe&&D75u~yCLR3_$GMETL6Z)GA0L9hEck^Y^w)8IM~8!O z4cgW+U>TTaV8wKsRR0fNe*e!W*`8&/$.lib" glfw ) +if(WIN32) + target_link_libraries(debug PRIVATE + "$/$.lib" + ) +else() + target_link_libraries(debug PRIVATE + $ + ) +endif() + add_custom_command(TARGET debug POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ $ $ COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/shaders $/shaders COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/assets $/assets -) \ No newline at end of file +) + +if(WIN32) + add_custom_command(TARGET debug POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $ $ + ) +endif() \ No newline at end of file diff --git a/examples/debug/main.cpp b/examples/debug/main.cpp index 30f368b..b086498 100644 --- a/examples/debug/main.cpp +++ b/examples/debug/main.cpp @@ -118,8 +118,8 @@ int main(int argc, char** argv) camera.LookAt(0.0f, 0.0f, 0.0f); shader->Use(); - shader->SetUniform("texture1", crate, 0); - shader->SetUniform("texture2", opengl, 1); + shader->SetUniformTexture("texture1", crate, 0); + shader->SetUniformTexture("texture2", opengl, 1); shader->SetUniform("model", square); shader->SetUniformMatrix4fv("view", 1, GL_FALSE, glm::value_ptr(camera.GetMatrix())); shader->SetUniformMatrix4fv("projection", 1, GL_FALSE, glm::value_ptr(camera.GetProjection())); diff --git a/examples/movement/CMakeLists.txt b/examples/movement/CMakeLists.txt index 80b1081..e57babf 100644 --- a/examples/movement/CMakeLists.txt +++ b/examples/movement/CMakeLists.txt @@ -14,12 +14,26 @@ target_include_directories(movement PRIVATE ) target_link_libraries(movement PRIVATE - "$/$.lib" glfw ) +if(WIN32) + target_link_libraries(movement PRIVATE + "$/$.lib" + ) +else() + target_link_libraries(movement PRIVATE + $ + ) +endif() + add_custom_command(TARGET movement POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ $ $ COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/shaders $/shaders COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/assets $/assets -) \ No newline at end of file +) + +if(WIN32) + add_custom_command(TARGET movement POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $ $ + ) +endif() \ No newline at end of file diff --git a/examples/movement/main.cpp b/examples/movement/main.cpp index 9669111..e8155fb 100644 --- a/examples/movement/main.cpp +++ b/examples/movement/main.cpp @@ -220,8 +220,8 @@ int main(int argc, char** argv) ImGui::NewFrame(); shader->Use(); - shader->SetUniform("texture1", crate, 0); - shader->SetUniform("texture2", opengl, 1); + shader->SetUniformTexture("texture1", crate, 0); + shader->SetUniformTexture("texture2", opengl, 1); shader->SetUniformMatrix4fv("view", 1, GL_FALSE, glm::value_ptr(camera.GetMatrix())); shader->SetUniformMatrix4fv("projection", 1, GL_FALSE, glm::value_ptr(camera.GetProjection())); diff --git a/include/shader.hpp b/include/shader.hpp index 91d13ab..8325df5 100644 --- a/include/shader.hpp +++ b/include/shader.hpp @@ -19,6 +19,10 @@ namespace oglu typedef std::shared_ptr Texture; + class AbstractShader; + + typedef std::shared_ptr Shader; + /** * @brief An object representing an OpenGL Shader Program. * @@ -40,7 +44,7 @@ namespace oglu * * @return A shared pointer to the shader program. */ - friend std::shared_ptr OGLU_API MakeShader(const char* vertexShaderFile, const char* fragmentShaderFile); + friend Shader OGLU_API MakeShader(const char* vertexShaderFile, const char* fragmentShaderFile); /** * @brief Copy constructor. @@ -294,7 +298,7 @@ namespace oglu * @param[in] v0 Value to set the uniform to * @param[in] index Index of the texture unit */ - void SetUniform(const GLchar* name, const Texture& v0, GLbyte index = 0); + void SetUniformTexture(const GLchar* name, const Texture& v0, GLbyte index = 0); /** * @brief Set uniform color. @@ -308,7 +312,7 @@ namespace oglu * @param[in] v0 Value to set the uniform to * @param[in] index Index of the texture unit */ - void SetUniform(GLint location, const Texture& v0, GLbyte index = 0); + void SetUniformTexture(GLint location, const Texture& v0, GLbyte index = 0); /** * @brief Set uniform mat4. @@ -318,6 +322,7 @@ namespace oglu * * @param[in] name Name of the uniform * @param[in] v0 Value to set the uniform to + * @param[in] transpose Transpose matrix before setting the uniform */ void SetUniform(const GLchar* name, Transformable& v0, GLboolean transpose = GL_FALSE); @@ -329,6 +334,7 @@ namespace oglu * * @param[in] location Location of the uniform * @param[in] v0 Value to set the uniform to + * @param[in] transpose Transpose matrix before setting the uniform */ void SetUniform(GLint location, Transformable& v0, GLboolean transpose = GL_FALSE); @@ -754,7 +760,7 @@ namespace oglu GLuint program; ///< Handle to the Shader program }; - typedef std::shared_ptr Shader; + Shader OGLU_API MakeShader(const char* vertexShaderFile, const char* fragmentShaderFile); } #endif \ No newline at end of file diff --git a/include/texture.hpp b/include/texture.hpp index 31afb5e..5883197 100644 --- a/include/texture.hpp +++ b/include/texture.hpp @@ -21,6 +21,10 @@ namespace oglu */ void OGLU_API ActiveTexture(GLubyte index); + class AbstractTexture; + + typedef std::shared_ptr Texture; + /** * @brief An object representing an OpenGL Texture. * @@ -41,7 +45,7 @@ namespace oglu * * @return A shared pointer to the texture. */ - friend std::shared_ptr OGLU_API MakeTexture(const char* filename); + friend Texture OGLU_API MakeTexture(const char* filename); /** * @brief Copy constructor. @@ -93,7 +97,7 @@ namespace oglu GLuint texture; ///< OpenGL handle to the texture }; - typedef std::shared_ptr Texture; + Texture OGLU_API MakeTexture(const char* filename); } #endif \ No newline at end of file diff --git a/include/vertexArray.hpp b/include/vertexArray.hpp index 40e6c27..bab315c 100644 --- a/include/vertexArray.hpp +++ b/include/vertexArray.hpp @@ -27,6 +27,10 @@ namespace oglu /*@}*/ }; + class AbstractVertexArray; + + typedef std::shared_ptr VertexArray; + /** * @brief An object representing an OpenGL VAO. * @@ -52,7 +56,7 @@ namespace oglu * * @return A shared pointer to the texture. */ - friend std::shared_ptr OGLU_API MakeVertexArray(const GLfloat* vertices, size_t verticesSize, const GLuint* indices, size_t indicesSize, const VertexAttribute* topology, size_t topologySize); + friend VertexArray OGLU_API MakeVertexArray(const GLfloat* vertices, size_t verticesSize, const GLuint* indices, size_t indicesSize, const VertexAttribute* topology, size_t topologySize); /** * @brief Constructs a new VAO. @@ -61,7 +65,7 @@ namespace oglu * * @param[in] filepath Path to the .obj file */ - friend std::shared_ptr OGLU_API MakeVertexArray(const char* filepath); + friend VertexArray OGLU_API MakeVertexArray(const char* filepath); /** * @brief Copy constructor. @@ -127,7 +131,8 @@ namespace oglu GLsizei count; ///< Amount of indices }; - typedef std::shared_ptr VertexArray; + VertexArray OGLU_API MakeVertexArray(const GLfloat* vertices, size_t verticesSize, const GLuint* indices, size_t indicesSize, const VertexAttribute* topology, size_t topologySize); + VertexArray OGLU_API MakeVertexArray(const char* filepath); } #endif diff --git a/src/object.cpp b/src/object.cpp index 8980081..cff1799 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -2,9 +2,10 @@ namespace oglu { - Object::Object(const GLfloat* vertices, size_t verticesSize, const GLuint* indices, size_t indicesSize, const VertexAttribute* topology, size_t topologySize) : - VAO(MakeVertexArray(vertices, verticesSize, indices, indicesSize, topology, topologySize)) + Object::Object(const GLfloat* vertices, size_t verticesSize, const GLuint* indices, size_t indicesSize, const VertexAttribute* topology, size_t topologySize) //: + // VAO(MakeVertexArray(vertices, verticesSize, indices, indicesSize, topology, topologySize)) { + VAO = MakeVertexArray(vertices, verticesSize, indices, indicesSize, topology, topologySize); } Object::Object(const VertexArray& vao) : diff --git a/src/shader.cpp b/src/shader.cpp index 03f88de..5bfc247 100644 --- a/src/shader.cpp +++ b/src/shader.cpp @@ -238,12 +238,12 @@ namespace oglu glUniform4f(location, v0.r, v0.g, v0.b, v0.a); } - void AbstractShader::SetUniform(const GLchar* name, const Texture& v0, GLbyte index) + void AbstractShader::SetUniformTexture(const GLchar* name, const Texture& v0, GLbyte index) { - SetUniform(glGetUniformLocation(program, name), v0, index); + SetUniformTexture(glGetUniformLocation(program, name), v0, index); } - void AbstractShader::SetUniform(GLint location, const Texture& v0, GLbyte index) + void AbstractShader::SetUniformTexture(GLint location, const Texture& v0, GLbyte index) { v0->BindAs(index); glUniform1i(location, index);