diff --git a/includes/Camera.hpp b/includes/Camera.hpp new file mode 100644 index 0000000..7324c41 --- /dev/null +++ b/includes/Camera.hpp @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Camera.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: TheRed +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/10/15 13:59:57 by TheRed #+# #+# */ +/* Updated: 2024/10/15 13:59:57 by TheRed ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef RT_CAMERA__HPP +# define RT_CAMERA__HPP + + +class Camera +{ + public: + + Camera(void); + Camera(Camera const &src); + ~Camera(void); + + Camera &operator=(Camera const &rhs); + + private: + +}; + +#endif \ No newline at end of file diff --git a/includes/Window.hpp b/includes/Window.hpp index f28efbe..41f7db4 100644 --- a/includes/Window.hpp +++ b/includes/Window.hpp @@ -39,6 +39,8 @@ class Window private: GLFWwindow *_window; RT::Vec2i _mousePos; + RT::Vec2i _prevMousePos; + RT::Vec2i _mouseDelta; float _fps; diff --git a/shaders/frag.frag b/shaders/frag.frag index c09c17d..3c840a6 100644 --- a/shaders/frag.frag +++ b/shaders/frag.frag @@ -56,7 +56,7 @@ void main() uv.x *= u_resolution.x / u_resolution.y; vec3 rayOrigin = vec3(0.0, 0.0, 0.0); - vec3 rayDirection = normalize(vec3(uv, -1.0)); + vec3 rayDirection = normalize(vec3(uv, -1.0)); Ray ray = Ray(rayOrigin, rayDirection); diff --git a/srcs/Camera.cpp b/srcs/Camera.cpp new file mode 100644 index 0000000..79b7795 --- /dev/null +++ b/srcs/Camera.cpp @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Camera.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: TheRed +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/10/15 14:00:38 by TheRed #+# #+# */ +/* Updated: 2024/10/15 14:00:38 by TheRed ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "Camera.hpp" + +Camera::Camera(void) +{ +} + +Camera::Camera(Camera const &src) +{ + *this = src; +} + +Camera::~Camera(void) +{ +} + +Camera &Camera::operator=(Camera const &rhs) +{ + if (this != &rhs) + { + } + return (*this); +} \ No newline at end of file diff --git a/srcs/RT.cpp b/srcs/RT.cpp index 7a02580..1178946 100644 --- a/srcs/RT.cpp +++ b/srcs/RT.cpp @@ -29,7 +29,7 @@ int main(void) size_t size = sizeof(vertices) / sizeof(RT::Vec2f) / 3; shader.setupVertexBuffer(vertices, size); - + while (!window.shouldClose()) { glClear(GL_COLOR_BUFFER_BIT); diff --git a/srcs/Window.cpp b/srcs/Window.cpp index e308bf0..e8c9dde 100644 --- a/srcs/Window.cpp +++ b/srcs/Window.cpp @@ -72,7 +72,10 @@ void Window::mouseMoveCallback(GLFWwindow* window, double xpos, double ypos) Window* win = static_cast(glfwGetWindowUserPointer(window)); (void) win; (void) xpos; (void) ypos; + win->_prevMousePos = win->_mousePos; win->_mousePos = RT::Vec2i(xpos, ypos); + + win->_mouseDelta = win->_mousePos - win->_prevMousePos; } void Window::mouseButtonCallback(GLFWwindow* window, int button, int action, int mods) {