Skip to content

Commit

Permalink
small reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
WinteryFox committed Dec 20, 2023
1 parent 8a4a1ea commit 5066848
Show file tree
Hide file tree
Showing 22 changed files with 361 additions and 278 deletions.
32 changes: 32 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 19 additions & 5 deletions .idea/editor.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions src/editor/shaders/triangle.frag
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ layout(location = 1) in vec2 uv;

layout(location = 0) out vec4 color;

layout(binding = 1) uniform sampler2D albedo;
layout(binding = 1) uniform sampler2D diffuse;

void main() {
color = texture(albedo, uv) * vec4(vertex_color, 1.0);
}
color = vec4(vertex_color, 1.0);
color = texture(diffuse, uv);
}
2 changes: 1 addition & 1 deletion src/editor/shaders/triangle.vert
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ void main() {
gl_Position = mvp.projection * mvp.view * mvp.model * vec4(position, 1.0);
out_color = color;
out_uv = uv;
}
}
10 changes: 6 additions & 4 deletions src/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project("Vixen Engine")

find_package(GLFW3 3.3 REQUIRED)
pkg_check_modules(GLM REQUIRED IMPORTED_TARGET glm)
pkg_check_modules(GLFW REQUIRED IMPORTED_TARGET glfw3)
pkg_check_modules(ASSIMP REQUIRED IMPORTED_TARGET assimp)
pkg_check_modules(SPDLOG REQUIRED IMPORTED_TARGET spdlog)

Expand All @@ -14,13 +14,15 @@ set(
Camera.cpp
)

link_libraries(
add_library(Vixen STATIC ${SOURCES})
target_link_libraries(
Vixen
PUBLIC
glfw
PkgConfig::GLM
PkgConfig::GLFW
PkgConfig::ASSIMP
PkgConfig::SPDLOG
)
add_library(Vixen STATIC ${SOURCES})

if (ENABLE_VULKAN)
add_subdirectory(vk)
Expand Down
64 changes: 34 additions & 30 deletions src/engine/Camera.cpp
Original file line number Diff line number Diff line change
@@ -1,34 +1,47 @@
#include "Camera.h"

namespace Vixen {
Camera::Camera(const glm::vec3 position, const float fieldOfView, const float nearPlane, const float farPlane,
const glm::vec3 clearColor)
: position(position),
// rotation(glm::quat{}),
rotation({}),
fieldOfView(fieldOfView),
nearPlane(nearPlane),
farPlane(farPlane),
clearColor(clearColor) {}
Camera::Camera(
const glm::vec3 position,
const glm::vec3 rotation,
const float fieldOfView,
const float nearPlane,
const float farPlane
) : position(position),
rotation(rotation),
fieldOfView(fieldOfView),
nearPlane(nearPlane),
farPlane(farPlane) {}

/**
* \brief Calculates the view matrix for this camera.
* \return Returns the view matrix.
*/
glm::mat4 Camera::view() const {
// glm::vec3 front;
// front.x = static_cast<float>(cos(glm::radians(rotation.x)) * cos(glm::radians(rotation.y)));
// front.y = static_cast<float>(sin(glm::radians(rotation.y)));
// front.z = static_cast<float>(sin(glm::radians(rotation.x)) * cos(glm::radians(rotation.y)));
//
// front = normalize(front);
// const auto &right = normalize(cross(front, glm::vec3(0.0f, 1.0f, 0.0f)));
// const auto &up = normalize(cross(right, front));
//
// return lookAt(position, position + front, up);
const auto& direction = normalize(glm::vec3(
cos(rotation.x) * sin(rotation.y),
sin(rotation.y),
cos(rotation.x) * cos(rotation.y)
));
const auto& right = normalize(glm::vec3(
sin(rotation.y - M_PI / 2.0f),
0.0f,
cos(rotation.y - M_PI / 2.0f)
));
const auto& up = cross(right, direction);

return lookAt(
position,
glm::vec3(0, 0, 0),
{0.0f, 1.0f, 0.0f}
position + direction,
up
);
}

/**
* \brief Calculates the perspective matrix for a given aspect ratio and the current camera's settings.
* \param aspectRatio The aspect ratio (width / height) in degrees.
* \return Returns the perspective matrix for the given aspect ratio and camera settings.
*/
glm::mat4 Camera::perspective(const float aspectRatio) const {
return glm::perspective(
glm::radians(fieldOfView),
Expand All @@ -42,12 +55,7 @@ namespace Vixen {
return position;
}

// const glm::quat &Camera::getRotation() const {
// return rotation;
// }

glm::vec3 Camera::getEulerRotation() const {
// return glm::eulerAngles(rotation);
return rotation;
}

Expand All @@ -58,8 +66,4 @@ namespace Vixen {
float Camera::getFarPlane() const {
return farPlane;
}

const glm::vec3& Camera::getClearColor() const {
return clearColor;
}
}
Loading

0 comments on commit 5066848

Please sign in to comment.