Fixed macos build problems

This commit is contained in:
Lauchmelder23 2021-01-25 02:33:21 +01:00
parent 265a7253cc
commit 3fdeb074c1
13 changed files with 73 additions and 27 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

2
.gitignore vendored
View file

@ -1,3 +1,5 @@
.vs .vs
out out
build
*.json *.json

View file

@ -11,7 +11,7 @@ if(WIN32)
set(EXPOSE_OPENGL OFF CACHE BOOL "If you want to use raw OpenGL functions in your app (e.g. to use ImGui) check this") set(EXPOSE_OPENGL OFF CACHE BOOL "If you want to use raw OpenGL functions in your app (e.g. to use ImGui) check this")
endif() endif()
if(${build_documentation}) if(${BUILD_DOCUMENTATION})
find_package(Doxygen REQUIRED) find_package(Doxygen REQUIRED)
endif() endif()
@ -49,7 +49,7 @@ target_include_directories(openglu PUBLIC
vendor/include vendor/include
) )
if(${build_documentation}) if(${BUILD_DOCUMENTATION})
configure_file(doxyfile.in ${CMAKE_BINARY_DIR}/doxyfile @ONLY) configure_file(doxyfile.in ${CMAKE_BINARY_DIR}/doxyfile @ONLY)
add_custom_target(openglu_doc ALL add_custom_target(openglu_doc ALL
COMMAND ${DOXYGEN_EXECUTABLE} "${CMAKE_BINARY_DIR}/doxyfile" COMMAND ${DOXYGEN_EXECUTABLE} "${CMAKE_BINARY_DIR}/doxyfile"
@ -58,7 +58,7 @@ if(${build_documentation})
) )
endif() endif()
if(${build_examples}) if(${BUILD_EXAMPLES})
macro(subdirlist result curdir) macro(subdirlist result curdir)
file(GLOB children RELATIVE ${curdir} ${curdir}/*) file(GLOB children RELATIVE ${curdir} ${curdir}/*)
set(dirlist "") set(dirlist "")

BIN
examples/.DS_Store vendored Normal file

Binary file not shown.

View file

@ -7,12 +7,26 @@ target_include_directories(debug PRIVATE
) )
target_link_libraries(debug PRIVATE target_link_libraries(debug PRIVATE
"$<TARGET_FILE_DIR:openglu>/$<TARGET_FILE_BASE_NAME:openglu>.lib"
glfw glfw
) )
if(WIN32)
target_link_libraries(debug PRIVATE
"$<TARGET_FILE_DIR:openglu>/$<TARGET_FILE_BASE_NAME:openglu>.lib"
)
else()
target_link_libraries(debug PRIVATE
$<TARGET_FILE:openglu>
)
endif()
add_custom_command(TARGET debug POST_BUILD add_custom_command(TARGET debug POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:openglu> $<TARGET_FILE:glfw> $<TARGET_FILE_DIR:debug>
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/shaders $<TARGET_FILE_DIR:debug>/shaders COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/shaders $<TARGET_FILE_DIR:debug>/shaders
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/assets $<TARGET_FILE_DIR:debug>/assets COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/assets $<TARGET_FILE_DIR:debug>/assets
) )
if(WIN32)
add_custom_command(TARGET debug POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:openglu> $<TARGET_FILE:glfw> $<TARGET_FILE_DIR:debug>
)
endif()

View file

@ -118,8 +118,8 @@ int main(int argc, char** argv)
camera.LookAt(0.0f, 0.0f, 0.0f); camera.LookAt(0.0f, 0.0f, 0.0f);
shader->Use(); shader->Use();
shader->SetUniform("texture1", crate, 0); shader->SetUniformTexture("texture1", crate, 0);
shader->SetUniform("texture2", opengl, 1); shader->SetUniformTexture("texture2", opengl, 1);
shader->SetUniform("model", square); shader->SetUniform("model", square);
shader->SetUniformMatrix4fv("view", 1, GL_FALSE, glm::value_ptr(camera.GetMatrix())); shader->SetUniformMatrix4fv("view", 1, GL_FALSE, glm::value_ptr(camera.GetMatrix()));
shader->SetUniformMatrix4fv("projection", 1, GL_FALSE, glm::value_ptr(camera.GetProjection())); shader->SetUniformMatrix4fv("projection", 1, GL_FALSE, glm::value_ptr(camera.GetProjection()));

View file

@ -14,12 +14,26 @@ target_include_directories(movement PRIVATE
) )
target_link_libraries(movement PRIVATE target_link_libraries(movement PRIVATE
"$<TARGET_FILE_DIR:openglu>/$<TARGET_FILE_BASE_NAME:openglu>.lib"
glfw glfw
) )
if(WIN32)
target_link_libraries(movement PRIVATE
"$<TARGET_FILE_DIR:openglu>/$<TARGET_FILE_BASE_NAME:openglu>.lib"
)
else()
target_link_libraries(movement PRIVATE
$<TARGET_FILE:openglu>
)
endif()
add_custom_command(TARGET movement POST_BUILD add_custom_command(TARGET movement POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:openglu> $<TARGET_FILE:glfw> $<TARGET_FILE_DIR:movement>
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/shaders $<TARGET_FILE_DIR:movement>/shaders COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/shaders $<TARGET_FILE_DIR:movement>/shaders
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/assets $<TARGET_FILE_DIR:movement>/assets COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/assets $<TARGET_FILE_DIR:movement>/assets
) )
if(WIN32)
add_custom_command(TARGET movement POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:openglu> $<TARGET_FILE:glfw> $<TARGET_FILE_DIR:movementt>
)
endif()

View file

@ -220,8 +220,8 @@ int main(int argc, char** argv)
ImGui::NewFrame(); ImGui::NewFrame();
shader->Use(); shader->Use();
shader->SetUniform("texture1", crate, 0); shader->SetUniformTexture("texture1", crate, 0);
shader->SetUniform("texture2", opengl, 1); shader->SetUniformTexture("texture2", opengl, 1);
shader->SetUniformMatrix4fv("view", 1, GL_FALSE, glm::value_ptr(camera.GetMatrix())); shader->SetUniformMatrix4fv("view", 1, GL_FALSE, glm::value_ptr(camera.GetMatrix()));
shader->SetUniformMatrix4fv("projection", 1, GL_FALSE, glm::value_ptr(camera.GetProjection())); shader->SetUniformMatrix4fv("projection", 1, GL_FALSE, glm::value_ptr(camera.GetProjection()));

View file

@ -19,6 +19,10 @@ namespace oglu
typedef std::shared_ptr<AbstractTexture> Texture; typedef std::shared_ptr<AbstractTexture> Texture;
class AbstractShader;
typedef std::shared_ptr<AbstractShader> Shader;
/** /**
* @brief An object representing an OpenGL Shader Program. * @brief An object representing an OpenGL Shader Program.
* *
@ -40,7 +44,7 @@ namespace oglu
* *
* @return A shared pointer to the shader program. * @return A shared pointer to the shader program.
*/ */
friend std::shared_ptr<AbstractShader> OGLU_API MakeShader(const char* vertexShaderFile, const char* fragmentShaderFile); friend Shader OGLU_API MakeShader(const char* vertexShaderFile, const char* fragmentShaderFile);
/** /**
* @brief Copy constructor. * @brief Copy constructor.
@ -294,7 +298,7 @@ namespace oglu
* @param[in] v0 Value to set the uniform to * @param[in] v0 Value to set the uniform to
* @param[in] index Index of the texture unit * @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. * @brief Set uniform color.
@ -308,7 +312,7 @@ namespace oglu
* @param[in] v0 Value to set the uniform to * @param[in] v0 Value to set the uniform to
* @param[in] index Index of the texture unit * @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. * @brief Set uniform mat4.
@ -318,6 +322,7 @@ namespace oglu
* *
* @param[in] name Name of the uniform * @param[in] name Name of the uniform
* @param[in] v0 Value to set the uniform to * @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); 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] location Location of the uniform
* @param[in] v0 Value to set the uniform to * @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); void SetUniform(GLint location, Transformable& v0, GLboolean transpose = GL_FALSE);
@ -754,7 +760,7 @@ namespace oglu
GLuint program; ///< Handle to the Shader program GLuint program; ///< Handle to the Shader program
}; };
typedef std::shared_ptr<AbstractShader> Shader; Shader OGLU_API MakeShader(const char* vertexShaderFile, const char* fragmentShaderFile);
} }
#endif #endif

View file

@ -21,6 +21,10 @@ namespace oglu
*/ */
void OGLU_API ActiveTexture(GLubyte index); void OGLU_API ActiveTexture(GLubyte index);
class AbstractTexture;
typedef std::shared_ptr<AbstractTexture> Texture;
/** /**
* @brief An object representing an OpenGL Texture. * @brief An object representing an OpenGL Texture.
* *
@ -41,7 +45,7 @@ namespace oglu
* *
* @return A shared pointer to the texture. * @return A shared pointer to the texture.
*/ */
friend std::shared_ptr<AbstractTexture> OGLU_API MakeTexture(const char* filename); friend Texture OGLU_API MakeTexture(const char* filename);
/** /**
* @brief Copy constructor. * @brief Copy constructor.
@ -93,7 +97,7 @@ namespace oglu
GLuint texture; ///< OpenGL handle to the texture GLuint texture; ///< OpenGL handle to the texture
}; };
typedef std::shared_ptr<AbstractTexture> Texture; Texture OGLU_API MakeTexture(const char* filename);
} }
#endif #endif

View file

@ -27,6 +27,10 @@ namespace oglu
/*@}*/ /*@}*/
}; };
class AbstractVertexArray;
typedef std::shared_ptr<AbstractVertexArray> VertexArray;
/** /**
* @brief An object representing an OpenGL VAO. * @brief An object representing an OpenGL VAO.
* *
@ -52,7 +56,7 @@ namespace oglu
* *
* @return A shared pointer to the texture. * @return A shared pointer to the texture.
*/ */
friend std::shared_ptr<AbstractVertexArray> 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. * @brief Constructs a new VAO.
@ -61,7 +65,7 @@ namespace oglu
* *
* @param[in] filepath Path to the .obj file * @param[in] filepath Path to the .obj file
*/ */
friend std::shared_ptr<AbstractVertexArray> OGLU_API MakeVertexArray(const char* filepath); friend VertexArray OGLU_API MakeVertexArray(const char* filepath);
/** /**
* @brief Copy constructor. * @brief Copy constructor.
@ -127,7 +131,8 @@ namespace oglu
GLsizei count; ///< Amount of indices GLsizei count; ///< Amount of indices
}; };
typedef std::shared_ptr<AbstractVertexArray> 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 #endif

View file

@ -2,9 +2,10 @@
namespace oglu namespace oglu
{ {
Object::Object(const GLfloat* vertices, size_t verticesSize, const GLuint* indices, size_t indicesSize, const VertexAttribute* topology, size_t 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))
{ {
VAO = MakeVertexArray(vertices, verticesSize, indices, indicesSize, topology, topologySize);
} }
Object::Object(const VertexArray& vao) : Object::Object(const VertexArray& vao) :

View file

@ -238,12 +238,12 @@ namespace oglu
glUniform4f(location, v0.r, v0.g, v0.b, v0.a); 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); v0->BindAs(index);
glUniform1i(location, index); glUniform1i(location, index);