diff --git a/.objs/srcs/Camera.o b/.objs/srcs/Camera.o deleted file mode 100644 index 4a6966d..0000000 Binary files a/.objs/srcs/Camera.o and /dev/null differ diff --git a/.objs/srcs/RT.o b/.objs/srcs/RT.o deleted file mode 100644 index c7c96bd..0000000 Binary files a/.objs/srcs/RT.o and /dev/null differ diff --git a/.objs/srcs/Shader.o b/.objs/srcs/Shader.o deleted file mode 100644 index 92b2336..0000000 Binary files a/.objs/srcs/Shader.o and /dev/null differ diff --git a/.objs/srcs/Window.o b/.objs/srcs/Window.o deleted file mode 100644 index fb73af5..0000000 Binary files a/.objs/srcs/Window.o and /dev/null differ diff --git a/.objs/srcs/gl.o b/.objs/srcs/gl.o deleted file mode 100644 index 2c35e15..0000000 Binary files a/.objs/srcs/gl.o and /dev/null differ diff --git a/RT.exe b/RT.exe deleted file mode 100644 index 9eede27..0000000 Binary files a/RT.exe and /dev/null differ diff --git a/includes/RT.hpp b/includes/RT.hpp index 329818c..29242ee 100644 --- a/includes/RT.hpp +++ b/includes/RT.hpp @@ -24,7 +24,6 @@ # include # include "Camera.hpp" -# include "Vector/Vector.hpp" # include "Window.hpp" # include "Shader.hpp" diff --git a/includes/Shader.hpp b/includes/Shader.hpp index 97d42ef..389ec62 100644 --- a/includes/Shader.hpp +++ b/includes/Shader.hpp @@ -26,7 +26,7 @@ class Shader // void compile(const char *vertexSource, const char *fragmentSource); void attach(void); - void setupVertexBuffer(const RT::Vec2f* vertices, size_t size); + void setupVertexBuffer(const glm::vec2* vertices, size_t size); void drawTriangles(size_t size); @@ -34,7 +34,7 @@ class Shader // 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 setVec2f(const std::string &name, const RT::Vec2f &value) const; + void setVec2f(const std::string &name, const glm::vec2 &value) const; // void setVec3(const std::string &name, const RT::Vec3f &value) const; // void setVec4(const std::string &name, const RT::Vec4f &value) const; // void setMat4(const std::string &name, const RT::Mat4f &value) const; diff --git a/includes/Vector/Vec2.hpp b/includes/Vector/Vec2.hpp deleted file mode 100644 index 059a123..0000000 --- a/includes/Vector/Vec2.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* Vec2.hpp :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: TheRed +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/10/13 17:16:11 by TheRed #+# #+# */ -/* Updated: 2024/10/13 17:16:11 by TheRed ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef RT_VEC2__HPP -#define RT_VEC2__HPP - -# include "Vector/Vector.hpp" - -namespace RT -{ - template - class Vec2 : public Vector, T, 2> - { - public: - using Vector, T, 2>::Vector; - - constexpr Vec2(T x, T y) - { - this->data[0] = x; - this->data[1] = y; - } - }; - - using Vec2f = Vec2; - using Vec2d = Vec2; - using Vec2i = Vec2; -} - -#endif \ No newline at end of file diff --git a/includes/Vector/Vec3.hpp b/includes/Vector/Vec3.hpp deleted file mode 100644 index e3f4f69..0000000 --- a/includes/Vector/Vec3.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* Vec3.hpp :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ycontre +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/10/13 17:17:04 by TheRed #+# #+# */ -/* Updated: 2024/10/13 20:32:13 by ycontre ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef RT_VEC3__HPP -# define RT_VEC3__HPP - -# include "Vector/Vector.hpp" -# include - -namespace RT -{ - template - class Vec3 : public Vector, T, 3> - { - public: - using Vector, T, 3>::Vector; - - constexpr Vec3(T x, T y, T z) - { - this->data[0] = x; - this->data[1] = y; - this->data[2] = z; - } - - constexpr T Distance(const Vec3& other) const - { - T dx = this->data[0] - other.data[0]; - T dy = this->data[1] - other.data[1]; - T dz = this->data[2] - other.data[2]; - - return std::sqrt(dx * dx + dy * dy + dz * dz); - } - }; - - using Vec3f = Vec3; - using Vec3d = Vec3; - using Vec3i = Vec3; -} - -#endif \ No newline at end of file diff --git a/includes/Vector/Vec4.hpp b/includes/Vector/Vec4.hpp deleted file mode 100644 index f5761b0..0000000 --- a/includes/Vector/Vec4.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* Vec4.hpp :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: TheRed +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/10/13 17:18:35 by TheRed #+# #+# */ -/* Updated: 2024/10/13 17:18:35 by TheRed ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef RT_VEC4__HPP -# define RT_VEC4__HPP - -# include "Vector/Vector.hpp" - -namespace RT -{ - template - class Vec4 : public Vector, T, 4> - { - public: - using Vector, T, 4>::Vector; - - constexpr Vec4(T r, T g, T b, T a) - { - this->data[0] = r; - this->data[1] = g; - this->data[2] = b; - this->data[3] = a; - } - }; - - using Vec4f = Vec4; - using Vec4d = Vec4; - using Vec4i = Vec4; -} - -#endif \ No newline at end of file diff --git a/includes/Vector/Vector.hpp b/includes/Vector/Vector.hpp deleted file mode 100644 index b2c3d5e..0000000 --- a/includes/Vector/Vector.hpp +++ /dev/null @@ -1,111 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* Vector.hpp :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: TheRed +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/10/13 17:13:03 by TheRed #+# #+# */ -/* Updated: 2024/10/13 17:13:03 by TheRed ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef RT_VECTOR__HPP -#define RT_VECTOR__HPP - -#include -#include - -namespace RT -{ - template - class Vector - { - public: - std::array data; - - constexpr Vector() { data.fill(0); } - - constexpr Vector(std::initializer_list values) { std::copy(values.begin(), values.end(), data.begin()); } - - constexpr T& operator[](std::size_t i) { return data[i]; } - constexpr const T& operator[](std::size_t i) const { return data[i]; } - - constexpr Derived operator+(const Vector& vec) const - { - Derived result; - for (std::size_t i = 0; i < N; ++i) - result[i] = data[i] + vec[i]; - return result; - } - constexpr Derived operator-(const Vector& vec) const - { - Derived result; - for (std::size_t i = 0; i < N; ++i) - result[i] = data[i] - vec[i]; - return result; - } - constexpr Derived operator*(T scalar) const - { - Derived result; - for (std::size_t i = 0; i < N; ++i) - result[i] = data[i] * scalar; - return result; - } - constexpr Derived operator/(T scalar) const - { - Derived result; - for (std::size_t i = 0; i < N; ++i) - result[i] = data[i] / scalar; - return result; - } - - constexpr Derived& operator+=(const Vector& vec) - { - *this = *this + vec; - return static_cast(*this); - } - constexpr Derived& operator-=(const Vector& vec) - { - *this = *this - vec; - return static_cast(*this); - } - constexpr Derived& operator*=(const Vector& vec) - { - *this = *this * vec; - return static_cast(*this); - } - constexpr Derived& operator/=(const Vector& vec) - { - *this = *this / vec; - return static_cast(*this); - } - - constexpr Derived& operator*=(T scalar) - { - *this = *this * scalar; - return static_cast(*this); - } - constexpr Derived& operator/=(T scalar) - { - *this = *this / scalar; - return static_cast(*this); - } - - void print() const - { - std::cout << "Vec" << N << "("; - for (std::size_t i = 0; i < N; ++i) { - std::cout << data[i]; - if (i < N - 1) std::cout << ", "; - } - std::cout << ")" << std::endl; - } - }; -} - -#include "Vector/Vec2.hpp" -#include "Vector/Vec3.hpp" -#include "Vector/Vec4.hpp" - -#endif \ No newline at end of file diff --git a/srcs/RT.cpp b/srcs/RT.cpp index 1178946..7314497 100644 --- a/srcs/RT.cpp +++ b/srcs/RT.cpp @@ -19,14 +19,14 @@ int main(void) shader.attach(); - // RT::Vec2f vertices[6] = { + // glm::vec2 vertices[6] = { // { -1.0f, -1.0f }, { 1.0f, -1.0f }, { -1.0f, 1.0f }, // { 1.0f, -1.0f }, { 1.0f, 1.0f }, { -1.0f, 1.0f } // }; - RT::Vec2f vertices[3] = { + glm::vec2 vertices[3] = { {-1.0f, -1.0f}, {3.0f, -1.0f}, {-1.0f, 3.0f} }; - size_t size = sizeof(vertices) / sizeof(RT::Vec2f) / 3; + size_t size = sizeof(vertices) / sizeof(glm::vec2) / 3; shader.setupVertexBuffer(vertices, size); @@ -34,7 +34,7 @@ int main(void) { glClear(GL_COLOR_BUFFER_BIT); - shader.setVec2f("u_resolution", RT::Vec2f(WIDTH, HEIGHT)); + shader.setVec2f("u_resolution", glm::vec2(WIDTH, HEIGHT)); glUseProgram(shader.getProgram()); shader.drawTriangles(size); diff --git a/srcs/Shader.cpp b/srcs/Shader.cpp index 7fe2892..b75accb 100644 --- a/srcs/Shader.cpp +++ b/srcs/Shader.cpp @@ -102,7 +102,7 @@ void Shader::checkCompileErrors(GLuint shader) } } -void Shader::setupVertexBuffer(const RT::Vec2f* vertices, size_t size) +void Shader::setupVertexBuffer(const glm::vec2* vertices, size_t size) { glGenVertexArrays(1, &_screen_VAO); glGenBuffers(1, &_screen_VBO); @@ -110,7 +110,7 @@ void Shader::setupVertexBuffer(const RT::Vec2f* vertices, size_t size) glBindVertexArray(_screen_VAO); glBindBuffer(GL_ARRAY_BUFFER, _screen_VBO); - glBufferData(GL_ARRAY_BUFFER, size * 3 * sizeof(RT::Vec2f), vertices, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, size * 3 * sizeof(glm::vec2), vertices, GL_STATIC_DRAW); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), (void*)0); glEnableVertexAttribArray(0); @@ -126,7 +126,7 @@ void Shader::drawTriangles(size_t size) } -void Shader::setVec2f(const std::string &name, const RT::Vec2f &value) const +void Shader::setVec2f(const std::string &name, const glm::vec2 &value) const { glUniform2f(glGetUniformLocation(_program, name.c_str()), value[0], value[1]); } diff --git a/srcs/Window.cpp b/srcs/Window.cpp index d018b92..0d57ceb 100644 --- a/srcs/Window.cpp +++ b/srcs/Window.cpp @@ -82,7 +82,6 @@ void Window::mouseMoveCallback(GLFWwindow* window, double xpos, double ypos) if (glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS) { win->camera->process_movement(xoffset, yoffset, true); - glfwSetCursorPos(window, WIDTH / 2, HEIGHT / 2); // scene.frameCount = 0; }