mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-28 11:08:36 +02:00
+ | Going to start object systems
This commit is contained in:
44
includes/RT/Camera.hpp
Normal file
44
includes/RT/Camera.hpp
Normal file
@ -0,0 +1,44 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Camera.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/15 13:59:57 by TheRed #+# #+# */
|
||||
/* Updated: 2024/12/23 17:42:18 by ycontre ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef RT_CAMERA__HPP
|
||||
# define RT_CAMERA__HPP
|
||||
|
||||
# include "RT.hpp"
|
||||
|
||||
class Camera
|
||||
{
|
||||
public:
|
||||
|
||||
Camera(glm::vec3 startPos, glm::vec3 startUp, float startYaw, float startPitch);
|
||||
~Camera(void);
|
||||
|
||||
void update_camera_vectors();
|
||||
|
||||
glm::mat4 get_view_matrix();
|
||||
glm::vec3 get_position();
|
||||
|
||||
void process_mouse(float xoffset, float yoffset, bool constrainPitch);
|
||||
void process_keyboard(bool forward, bool backward, bool left, bool right, bool up, bool down);
|
||||
|
||||
private:
|
||||
|
||||
glm::vec3 _forward;
|
||||
glm::vec3 _position;
|
||||
glm::vec3 _up;
|
||||
glm::vec3 _right;
|
||||
|
||||
float _pitch;
|
||||
float _yaw;
|
||||
};
|
||||
|
||||
#endif
|
30
includes/RT/Object.hpp
Normal file
30
includes/RT/Object.hpp
Normal file
@ -0,0 +1,30 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Object.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/12/23 18:44:18 by ycontre #+# #+# */
|
||||
/* Updated: 2024/12/23 19:12:39 by ycontre ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef RT_OBJECT__HPP
|
||||
# define RT_OBJECT__HPP
|
||||
|
||||
class Object
|
||||
{
|
||||
public:
|
||||
glm::vec3 position;
|
||||
glm::vec3 color;
|
||||
|
||||
Object(const glm::vec3& pos, const glm::vec3& col) : position(pos), color(col) {}
|
||||
virtual ~Object() = default;
|
||||
|
||||
// virtual bool hit(const glm::vec3& rayOrigin, const glm::vec3& rayDir, float& t, glm::vec3& hitNormal) const = 0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
34
includes/RT/Scene.hpp
Normal file
34
includes/RT/Scene.hpp
Normal file
@ -0,0 +1,34 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Scene.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/12/23 18:30:18 by ycontre #+# #+# */
|
||||
/* Updated: 2024/12/23 18:46:13 by ycontre ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef RT_SCENE__HPP
|
||||
# define RT_SCENE__HPP
|
||||
|
||||
# include "RT.hpp"
|
||||
|
||||
class Camera;
|
||||
|
||||
class Scene
|
||||
{
|
||||
public:
|
||||
Scene();
|
||||
~Scene();
|
||||
|
||||
Camera *getCamera(void) const;
|
||||
// Object *getObjects(void) const;
|
||||
|
||||
private:
|
||||
// Object *_objects;
|
||||
Camera *_camera;
|
||||
};
|
||||
|
||||
#endif
|
56
includes/RT/Shader.hpp
Normal file
56
includes/RT/Shader.hpp
Normal file
@ -0,0 +1,56 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Shader.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/13 18:10:10 by TheRed #+# #+# */
|
||||
/* Updated: 2024/10/14 19:51:46 by ycontre ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef RT_SHADER__HPP
|
||||
# define RT_SHADER__HPP
|
||||
|
||||
# include "RT.hpp"
|
||||
|
||||
class Shader
|
||||
{
|
||||
public:
|
||||
Shader(std::string vertexPath, std::string fragmentPath);
|
||||
Shader(Shader const &src);
|
||||
~Shader(void);
|
||||
|
||||
Shader &operator=(Shader const &rhs);
|
||||
|
||||
// void compile(const char *vertexSource, const char *fragmentSource);
|
||||
void attach(void);
|
||||
void setupVertexBuffer(const glm::vec2* vertices, size_t size);
|
||||
void drawTriangles(size_t size);
|
||||
|
||||
|
||||
|
||||
// void setBool(const std::string &name, bool value) const;
|
||||
// void setInt(const std::string &name, int value) const;
|
||||
// void setFloat(const std::string &name, float value) const;
|
||||
void set_vec2(const std::string &name, const glm::vec2 &value) const;
|
||||
void set_vec3(const std::string &name, const glm::vec3 &value) const;
|
||||
// void setVec4(const std::string &name, const RT::Vec4f &value) const;
|
||||
void set_mat4(const std::string &name, const glm::mat4 &value) const;
|
||||
|
||||
GLuint getProgram(void) const;
|
||||
|
||||
|
||||
private:
|
||||
GLuint _screen_VAO, _screen_VBO;
|
||||
|
||||
GLuint _program;
|
||||
|
||||
GLuint _vertex;
|
||||
GLuint _fragment;
|
||||
|
||||
void checkCompileErrors(unsigned int shader);
|
||||
};
|
||||
|
||||
#endif
|
46
includes/RT/Window.hpp
Normal file
46
includes/RT/Window.hpp
Normal file
@ -0,0 +1,46 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Window.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/13 16:15:41 by TheRed #+# #+# */
|
||||
/* Updated: 2024/12/23 18:35:35 by ycontre ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef RT_WINDOW__HPP
|
||||
# define RT_WINDOW__HPP
|
||||
|
||||
# include "RT.hpp"
|
||||
|
||||
class Scene;
|
||||
|
||||
class Window
|
||||
{
|
||||
public:
|
||||
Window(int width, int height, const char *title, int sleep);
|
||||
~Window(void);
|
||||
|
||||
GLFWwindow *getWindow(void) const;
|
||||
Scene *getScene(void) const;
|
||||
float getFps(void) const;
|
||||
|
||||
void display();
|
||||
void pollEvents();
|
||||
bool shouldClose();
|
||||
|
||||
static void keyCallback(GLFWwindow *window, int key, int scancode, int action, int mods);
|
||||
static void mouseMoveCallback(GLFWwindow *window, double xpos, double ypos);
|
||||
static void mouseButtonCallback(GLFWwindow *window, int button, int action, int mods);
|
||||
|
||||
private:
|
||||
GLFWwindow *_window;
|
||||
Scene *_scene;
|
||||
|
||||
float _fps;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
30
includes/RT/objects/Sphere.hpp
Normal file
30
includes/RT/objects/Sphere.hpp
Normal file
@ -0,0 +1,30 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Sphere.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/12/23 19:12:51 by ycontre #+# #+# */
|
||||
/* Updated: 2024/12/23 19:47:09 by ycontre ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef RT_SPHERE__HPP
|
||||
# define RT_SPHERE__HPP
|
||||
|
||||
# include "RT.hpp"
|
||||
|
||||
class Sphere : public Object
|
||||
{
|
||||
public:
|
||||
float radius;
|
||||
glm::vec3 position;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user