From f7077e9f76797f88e799c09f959e7906f4adb890 Mon Sep 17 00:00:00 2001 From: tomoron Date: Thu, 6 Feb 2025 03:00:07 +0100 Subject: [PATCH] fix compilation error unused variable, make getFilePath work on windows (yavin, you should still install linux), add error callback to glfw --- scenes/lambo.rt | 2 +- scenes/sponza.rt | 10 +++++----- scenes/test.rt | 6 +++--- scenes/volumetric.rt | 2 +- srcs/class/Camera.cpp | 4 ++-- srcs/class/ObjParser.cpp | 6 +++--- srcs/class/Window.cpp | 12 +++++++----- 7 files changed, 22 insertions(+), 20 deletions(-) diff --git a/scenes/lambo.rt b/scenes/lambo.rt index eb4dc9a..19c8f89 100644 --- a/scenes/lambo.rt +++ b/scenes/lambo.rt @@ -19,7 +19,7 @@ cu 0 10 0 5 5 5 3 sp 0 10 0 1 4 -OBJ scenes/obj/lambo.obj 0 1.5 0 1 0 0 0 +OBJ obj/lambo.obj 0 1.5 0 1 0 0 0 diff --git a/scenes/sponza.rt b/scenes/sponza.rt index 57953f1..f1f51c1 100644 --- a/scenes/sponza.rt +++ b/scenes/sponza.rt @@ -7,11 +7,11 @@ MAT 255 220 50 0.0 1.0 0.5 // dragon 1 MAT 255 255 255 5.0 0.0 0.0 // light 2 sp 0 50 0 25 2 -OBJ scenes/obj/sponza.obj 0 0 0 0.025 +OBJ obj/sponza.obj 0 0 0 0.025 -# OBJ scenes/obj/Dragon_80K.obj 7 2.5 0 9 0 140 0 0 -OBJ scenes/obj/Dragon_80K.obj 9 1.35 -3.5 5 0 40 0 1 +# OBJ obj/Dragon_80K.obj 7 2.5 0 9 0 140 0 0 +OBJ obj/Dragon_80K.obj 9 1.35 -3.5 5 0 40 0 1 -OBJ scenes/obj/Dragon_800K.obj 10 3.35 -3.5 45 0 230 0 0 -# OBJ scenes/obj/Dragon_80K.obj 9 1.35 -3.5 5 0 40 0 1 +OBJ obj/Dragon_800K.obj 10 3.35 -3.5 45 0 230 0 0 +# OBJ obj/Dragon_80K.obj 9 1.35 -3.5 5 0 40 0 1 diff --git a/scenes/test.rt b/scenes/test.rt index dd47a1b..3211a29 100644 --- a/scenes/test.rt +++ b/scenes/test.rt @@ -11,8 +11,8 @@ MAT 255 255 255 0.0 0.0 0.0 // 1 sp 0 2 0 150 0 -OBJ scenes/obj/jinx.obj -10 0 0 1.25 0 0 0 -# OBJ scenes/obj/Dragon_800K.obj 0 0 0 35 0 0 0 1 +OBJ obj/jinx.obj -10 0 0 1.25 0 0 0 +# OBJ obj/Dragon_800K.obj 0 0 0 35 0 0 0 1 -OBJ scenes/obj/whitedragon.obj 0 0 0 1 0 0 0 +OBJ obj/whitedragon.obj 0 0 0 1 0 0 0 diff --git a/scenes/volumetric.rt b/scenes/volumetric.rt index 6514a96..b26bc5c 100644 --- a/scenes/volumetric.rt +++ b/scenes/volumetric.rt @@ -37,4 +37,4 @@ sp 0 2.5 0 0.5 5 # sp 0 0 0 5 1 # sp 0 0 0 15 2 -# OBJ scenes/obj/jinx.obj 0 0 -15 \ No newline at end of file +# OBJ obj/jinx.obj 0 0 -15 diff --git a/srcs/class/Camera.cpp b/srcs/class/Camera.cpp index 29975f1..21559cd 100644 --- a/srcs/class/Camera.cpp +++ b/srcs/class/Camera.cpp @@ -6,7 +6,7 @@ /* By: ycontre +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/15 14:00:38 by TheRed #+# #+# */ -/* Updated: 2025/02/05 20:09:58 by ycontre ### ########.fr */ +/* Updated: 2025/02/06 02:07:47 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -38,7 +38,7 @@ void Camera::updateCameraVectors() void Camera::updateCameraDirections() { - glm::vec3 forward_xz = glm::normalize(glm::vec3(_forward.x, 0.0f, _forward.z)); +// glm::vec3 forward_xz = glm::normalize(glm::vec3(_forward.x, 0.0f, _forward.z)); _pitch = glm::degrees(asin(_forward.y)); _yaw = glm::degrees(atan2(-_forward.x, _forward.z)); diff --git a/srcs/class/ObjParser.cpp b/srcs/class/ObjParser.cpp index 25a882e..924595a 100644 --- a/srcs/class/ObjParser.cpp +++ b/srcs/class/ObjParser.cpp @@ -6,7 +6,7 @@ /* By: ycontre +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/16 15:00:33 by tomoron #+# #+# */ -/* Updated: 2025/02/03 19:01:06 by ycontre ### ########.fr */ +/* Updated: 2025/02/06 02:19:50 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,10 +32,10 @@ std::string ObjParser::getFilePath(std::string &file) { int index; - if(file.find("/") == std::string::npos) + if(file.find("/") == std::string::npos && file.find("\\") == std::string::npos) return(""); index = file.length() - 1; - while(index && file[index] != '/') + while(index && file[index] != '/' && file[index] != '\\') index--; return(file.substr(0, index + 1)); } diff --git a/srcs/class/Window.cpp b/srcs/class/Window.cpp index 6794415..7b39616 100644 --- a/srcs/class/Window.cpp +++ b/srcs/class/Window.cpp @@ -6,12 +6,17 @@ /* By: ycontre +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/13 16:16:24 by TheRed #+# #+# */ -/* Updated: 2025/02/05 20:01:29 by ycontre ### ########.fr */ +/* Updated: 2025/02/06 02:57:16 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ #include "Window.hpp" +void GLFWErrorCallback(int error, const char* description) +{ + fprintf(stderr, "GLFW Error (%d): %s\n", error, description); +} + Window::Window(Scene *scene, int width, int height, const char *title, int sleep, Arguments &args) { _scene = scene; @@ -19,7 +24,7 @@ Window::Window(Scene *scene, int width, int height, const char *title, int sleep _frameCount = 0; _pixelisation = 0; _renderer = new Renderer(scene, this, args); - + glfwSetErrorCallback(GLFWErrorCallback); if (!glfwInit()) { fprintf( stderr, "Failed to initialize GLFW\n" ); @@ -143,9 +148,6 @@ void Window::updateDeltaTime() lastTime = currentTime; _fps = 1.0f / _delta; - - if (accumulate) - _frameCount++; } void Window::display()