+ | Going to start object systems

This commit is contained in:
RedShip
2024-12-23 19:47:34 +01:00
parent ffc26d6078
commit e931b496ee
15 changed files with 172 additions and 22 deletions

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/27 14:51:49 by TheRed #+# #+# */
/* Updated: 2024/10/14 19:54:42 by ycontre ### ########.fr */
/* Updated: 2024/12/23 18:38:38 by ycontre ### ########.fr */
/* */
/* ************************************************************************** */
@ -31,8 +31,8 @@ int main(void)
glClear(GL_COLOR_BUFFER_BIT);
shader.set_vec2("u_resolution", glm::vec2(WIDTH, HEIGHT));
shader.set_vec3("u_cameraPosition", window.get_camera()->get_position());
shader.set_mat4("u_viewMatrix", window.get_camera()->get_view_matrix());
shader.set_vec3("u_cameraPosition", window.getScene()->getCamera()->get_position());
shader.set_mat4("u_viewMatrix", window.getScene()->getCamera()->get_view_matrix());
glUseProgram(shader.getProgram());
shader.drawTriangles(size);

12
srcs/class/Object.cpp Normal file
View File

@ -0,0 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Object.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/23 18:44:00 by ycontre #+# #+# */
/* Updated: 2024/12/23 18:44:01 by ycontre ### ########.fr */
/* */
/* ************************************************************************** */

28
srcs/class/Scene.cpp Normal file
View File

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Scene.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/23 18:29:41 by ycontre #+# #+# */
/* Updated: 2024/12/23 18:40:17 by ycontre ### ########.fr */
/* */
/* ************************************************************************** */
#include "Scene.hpp"
Scene::Scene()
{
_camera = new Camera(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f), -90.0f, 0.0f);
}
Scene::~Scene()
{
delete _camera;
}
Camera *Scene::getCamera(void) const
{
return (_camera);
}

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/13 16:16:24 by TheRed #+# #+# */
/* Updated: 2024/12/23 17:39:55 by ycontre ### ########.fr */
/* Updated: 2024/12/23 18:39:37 by ycontre ### ########.fr */
/* */
/* ************************************************************************** */
@ -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);
_scene = new Scene();
if (!glfwInit())
{
@ -47,7 +47,7 @@ Window::Window(int width, int height, const char *title, int sleep)
Window::~Window(void)
{
delete _camera;
delete _scene;
glfwTerminate();
}
@ -65,7 +65,7 @@ void Window::keyCallback(GLFWwindow* window, int key, int scancode, int action,
bool up = glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS;
bool down = glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS;
win->_camera->process_keyboard(forward, backward, left, right, up, down);
win->_scene->getCamera()->process_keyboard(forward, backward, left, right, up, down);
}
void Window::mouseMoveCallback(GLFWwindow* window, double xpos, double ypos)
{
@ -86,7 +86,7 @@ void Window::mouseMoveCallback(GLFWwindow* window, double xpos, double ypos)
if (glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS)
{
win->_camera->process_mouse(xoffset, yoffset, true);
win->_scene->getCamera()->process_mouse(xoffset, yoffset, true);
// scene.frameCount = 0;
}
@ -125,16 +125,16 @@ bool Window::shouldClose()
return glfwWindowShouldClose(_window);
}
Camera *Window::get_camera(void) const
{
return (_camera);
}
GLFWwindow *Window::getWindow(void) const
{
return (_window);
}
Scene *Window::getScene(void) const
{
return (_scene);
}
float Window::getFps(void) const
{
return (_fps);

12
srcs/parsing/parsing.cpp Normal file
View File

@ -0,0 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parsing.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/23 18:28:59 by ycontre #+# #+# */
/* Updated: 2024/12/23 18:29:00 by ycontre ### ########.fr */
/* */
/* ************************************************************************** */