Skip to content
Snippets Groups Projects
Verified Commit a6b6fbb1 authored by Tobias Frisch's avatar Tobias Frisch
Browse files

[#35] Moved code into own module directory, added submodule, removed glfw dependency

parent 9ddd711f
No related branches found
No related tags found
1 merge request!26Resolve "Kamera - Erstellung und Handling"
Pipeline #25037 failed
[submodule "lib/glfw"]
path = lib/glfw
url = https://github.com/glfw/glfw.git
[submodule "modules/camera/lib/glm"]
path = modules/camera/lib/glm
url = https://github.com/g-truc/glm.git
# Add new modules here:
add_subdirectory(camera)
add_subdirectory(testing)
cmake_minimum_required(VERSION 3.16)
project(vkcv_camera)
# setting c++ standard for the project
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(vkcv_camera_source ${PROJECT_SOURCE_DIR}/src)
set(vkcv_camera_include ${PROJECT_SOURCE_DIR}/include)
set(vkcv_camera_sources
${vkcv_camera_include}/vkcv/camera/Camera.hpp
${vkcv_camera_source}/vkcv/camera/Camera.cpp
${vkcv_camera_include}/vkcv/camera/TrackballCamera.hpp
${vkcv_camera_source}/vkcv/camera/TrackballCamera.cpp
)
# adding source files to the project
add_library(vkcv_camera STATIC ${vkcv_camera_sources})
# Setup some path variables to load libraries
set(vkcv_camera_lib lib)
set(vkcv_camera_lib_path ${PROJECT_SOURCE_DIR}/${vkcv_camera_lib})
include(config/GLM.cmake)
target_link_libraries(vkcv_camera PUBLIC ${vkcv_camera_libraries})
# add the own include directory for public headers
target_include_directories(vkcv_camera BEFORE PUBLIC ${vkcv_camera_include} ${vkcv_camera_includes})
find_package(glm QUIET)
if (glm_FOUND)
list(APPEND vkcv_camera_includes ${GLM_INCLUDE_DIRS})
list(APPEND vkcv_camera_libraries glm)
else()
if (EXISTS "${vkcv_camera_lib_path}/glm")
add_subdirectory(${vkcv_camera_lib}/glm)
list(APPEND vkcv_camera_libraries glm)
else()
message(WARNING "GLM is required..! Update the submodules!")
endif ()
endif ()
#pragma once
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/matrix_access.hpp>
......@@ -9,8 +8,6 @@ namespace vkcv {
class Camera {
protected:
GLFWwindow *m_window;
glm::mat4 m_view, m_projection;
int m_width, m_height;
......@@ -26,8 +23,6 @@ namespace vkcv {
~Camera();
virtual void update(GLFWwindow *window) {};
void setPerspective(float fov, float ratio, float near, float far);
const glm::mat4 &getView();
......@@ -38,7 +33,7 @@ namespace vkcv {
void lookAt(glm::vec3 position, glm::vec3 center, glm::vec3 up);
const glm::mat4 &Camera::getProjection();
const glm::mat4& getProjection();
void setProjection(const glm::mat4 projection);
......
#pragma once
#include "vkcv/camera/Camera.hpp"
#include "Camera.hpp"
namespace vkcv {
......@@ -13,8 +13,6 @@ namespace vkcv {
~TrackballCamera();
void update( GLFWwindow* window);
float getSensitivity() const;
void setSensitivity(float sensitivity);
......
Subproject commit 66062497b104ca7c297321bd0e970869b1e6ece5
......@@ -59,8 +59,8 @@ namespace vkcv{
{
}
void TrackballCamera::update( GLFWwindow* window) {
// TODO: Can be done as events... (mouseMove, mouseDown, mouseUp)
/*void TrackballCamera::update( GLFWwindow* window) {
double x, y;
......@@ -94,7 +94,7 @@ namespace vkcv{
m_view = glm::lookAt( m_position, m_center, m_up);
}
}*/
float TrackballCamera::getSensitivity() const {
return m_sensitivity;
......
......@@ -11,21 +11,11 @@ set(vkcv_testing_include ${PROJECT_SOURCE_DIR}/include)
set(vkcv_testing_sources
${vkcv_testing_include}/vkcv/testing/Test.hpp
${vkcv_testing_source}/vkcv/testing/Test.cpp
${vkcv_testing_include}/vkcv/camera/Camera.hpp
${vkcv_testing_source}/vkcv/camera/Camera.cpp
${vkcv_testing_include}/vkcv/camera/TrackballCamera.hpp
${vkcv_testing_source}/vkcv/camera/TrackballCamera.cpp
)
)
# adding source files to the project
add_library(vkcv_testing STATIC ${vkcv_testing_sources})
#include(GLM.cmake) # libglm-dev
#include(GLFW.cmake) # libglfw3-dev
find_package(glfw3 QUIET)
find_package(glm QUIET)
target_link_libraries(vkcv_testing PUBLIC glm glfw)
# add the own include directory for public headers
target_include_directories(vkcv_testing BEFORE PUBLIC ${vkcv_testing_include})
find_package(glfw3 QUIET)
if (glfw3_FOUND)
list(APPEND vkcv_libraries glfw)
message(${vkcv_config_msg} " GLFW - " ${glfw3_VERSION})
else()
if (EXISTS "${vkcv_lib_path}/glfw")
add_subdirectory(${vkcv_lib}/glfw)
list(APPEND vkcv_libraries glfw)
message(${vkcv_config_msg} " GLFW - " ${glfw3_VERSION})
else()
message(WARNING "GLFW is required..! Update the submodules!")
endif ()
endif ()
find_package(glm REQUIRED)
if (glm_FOUND)
# list(APPEND vkcv_includes ${GLM_INCLUDE_DIRS})
# list(APPEND vkcv_libraries glm)
message(STATUS "GLM included at ${GLM_INCLUDE_DIR}")
message(STATUS ${GLM_INCLUDE_DIR})
message(STATUS ${GLM_INCLUDE_DIRS})
message(STATUS ${GLM_LIBRARIES})
message(${vkcv_config_msg} " GLM - " ${glm_VERSION})
else()
if (EXISTS "${vkcv_lib_path}/glfw")
add_subdirectory(${vkcv_lib}/glfw)
list(APPEND vkcv_libraries glfw)
message(${vkcv_config_msg} " GLFW - " ${glfw3_VERSION})
else()
message(WARNING "GLFW is required..! Update the submodules!")
endif ()
endif ()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment