mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-28 02:58:35 +02:00
+ | Basic camera but glitched for now
This commit is contained in:
@ -14,7 +14,7 @@
|
||||
|
||||
Window::Window(int width, int height, const char *title, int sleep)
|
||||
{
|
||||
camera = new Camera(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f), -90.0f, 0.0f);
|
||||
_camera = new Camera(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f), -90.0f, 0.0f);
|
||||
|
||||
if (!glfwInit())
|
||||
{
|
||||
@ -47,7 +47,7 @@ Window::Window(int width, int height, const char *title, int sleep)
|
||||
|
||||
Window::~Window(void)
|
||||
{
|
||||
delete camera;
|
||||
delete _camera;
|
||||
|
||||
glfwTerminate();
|
||||
}
|
||||
@ -57,10 +57,16 @@ void Window::keyCallback(GLFWwindow* window, int key, int scancode, int action,
|
||||
{
|
||||
Window* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
|
||||
(void) win; (void) key; (void) scancode; (void) mods;
|
||||
if (action == GLFW_PRESS)
|
||||
{
|
||||
|
||||
}
|
||||
bool forward = glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS;
|
||||
bool backward = glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS;
|
||||
bool left = glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS;
|
||||
bool right = glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS;
|
||||
bool up = glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS;
|
||||
bool down = glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS;
|
||||
|
||||
// Update the camera position based on keyboard input
|
||||
win->_camera->process_keyboard(forward, backward, left, right, up, down);
|
||||
|
||||
}
|
||||
void Window::mouseMoveCallback(GLFWwindow* window, double xpos, double ypos)
|
||||
{
|
||||
@ -76,17 +82,16 @@ void Window::mouseMoveCallback(GLFWwindow* window, double xpos, double ypos)
|
||||
lastY = ypos;
|
||||
}
|
||||
|
||||
double xoffset = xpos - lastX;
|
||||
double yoffset = lastY - ypos;
|
||||
double xoffset = lastX - xpos;
|
||||
double yoffset = ypos - lastY;
|
||||
|
||||
if (glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS)
|
||||
{
|
||||
win->camera->process_movement(xoffset, yoffset, true);
|
||||
win->_camera->process_mouse(xoffset, yoffset, true);
|
||||
|
||||
// scene.frameCount = 0;
|
||||
}
|
||||
|
||||
|
||||
lastX = xpos;
|
||||
lastY = ypos;
|
||||
}
|
||||
@ -121,6 +126,11 @@ bool Window::shouldClose()
|
||||
return glfwWindowShouldClose(_window);
|
||||
}
|
||||
|
||||
Camera *Window::get_camera(void) const
|
||||
{
|
||||
return (_camera);
|
||||
}
|
||||
|
||||
GLFWwindow *Window::getWindow(void) const
|
||||
{
|
||||
return (_window);
|
||||
|
Reference in New Issue
Block a user