+ | Starting camera handling

This commit is contained in:
TheRedShip
2024-10-15 14:11:49 +02:00
parent 1c25a29c38
commit a006174ce5
6 changed files with 72 additions and 2 deletions

31
includes/Camera.hpp Normal file
View File

@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Camera.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: TheRed <TheRed@students.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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

View File

@ -39,6 +39,8 @@ class Window
private: private:
GLFWwindow *_window; GLFWwindow *_window;
RT::Vec2i _mousePos; RT::Vec2i _mousePos;
RT::Vec2i _prevMousePos;
RT::Vec2i _mouseDelta;
float _fps; float _fps;

34
srcs/Camera.cpp Normal file
View File

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Camera.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: TheRed <TheRed@students.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View File

@ -72,7 +72,10 @@ void Window::mouseMoveCallback(GLFWwindow* window, double xpos, double ypos)
Window* win = static_cast<Window*>(glfwGetWindowUserPointer(window)); Window* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
(void) win; (void) xpos; (void) ypos; (void) win; (void) xpos; (void) ypos;
win->_prevMousePos = win->_mousePos;
win->_mousePos = RT::Vec2i(xpos, ypos); win->_mousePos = RT::Vec2i(xpos, ypos);
win->_mouseDelta = win->_mousePos - win->_prevMousePos;
} }
void Window::mouseButtonCallback(GLFWwindow* window, int button, int action, int mods) void Window::mouseButtonCallback(GLFWwindow* window, int button, int action, int mods)
{ {