diff --git a/RT b/RT deleted file mode 100644 index 6b7d682..0000000 Binary files a/RT and /dev/null differ diff --git a/includes/RT/Window.hpp b/includes/RT/Window.hpp index 6a0e23f..d6392e1 100644 --- a/includes/RT/Window.hpp +++ b/includes/RT/Window.hpp @@ -6,7 +6,7 @@ /* By: ycontre +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/13 16:15:41 by TheRed #+# #+# */ -/* Updated: 2024/12/23 18:35:35 by ycontre ### ########.fr */ +/* Updated: 2025/01/11 16:14:11 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,8 +37,7 @@ class Window float getFps(void) const; int getFrameCount(void) const; - int &getPixelisationAmount(void); - int isPixelated(void); + int getPixelisation(void); bool &getAccumulate(void); @@ -49,10 +48,9 @@ class Window float _fps; float _delta; int _frameCount; + int _pixelisation; bool accumulate = true; - int pixelisation_amount = 5; - }; -#endif \ No newline at end of file +#endif diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..117df0c --- /dev/null +++ b/shell.nix @@ -0,0 +1,5 @@ +{ pkgs ? import {} }: + pkgs.mkShell { + nativeBuildInputs = with pkgs; [ libGL xorg.libX11 libGLU glfw]; +} + diff --git a/srcs/RT.cpp b/srcs/RT.cpp index b900535..735965c 100644 --- a/srcs/RT.cpp +++ b/srcs/RT.cpp @@ -6,7 +6,7 @@ /* By: ycontre +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/09/27 14:51:49 by TheRed #+# #+# */ -/* Updated: 2025/01/10 19:12:40 by ycontre ### ########.fr */ +/* Updated: 2025/01/11 16:14:24 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -79,7 +79,7 @@ int main(int argc, char **argv) shader.set_int("u_frameCount", window.getFrameCount()); shader.set_int("u_objectsNum", object_data.size()); - shader.set_int("u_pixelisation", window.isPixelated() * window.getPixelisationAmount() + 1); + shader.set_int("u_pixelisation", window.getPixelisation()); shader.set_float("u_time", (float)(glfwGetTime())); shader.set_vec2("u_resolution", glm::vec2(WIDTH, HEIGHT)); @@ -97,7 +97,6 @@ int main(int argc, char **argv) ImGui::Begin("Settings"); ImGui::Text("Fps: %d", int(window.getFps())); - ImGui::SliderInt("Pixelisation", &window.getPixelisationAmount(), 0, 30); ImGui::Checkbox("Accumulate", &window.getAccumulate()); ImGui::End(); diff --git a/srcs/class/Window.cpp b/srcs/class/Window.cpp index f31edeb..345feae 100644 --- a/srcs/class/Window.cpp +++ b/srcs/class/Window.cpp @@ -6,7 +6,7 @@ /* By: ycontre +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/13 16:16:24 by TheRed #+# #+# */ -/* Updated: 2025/01/09 16:34:48 by tomoron ### ########.fr */ +/* Updated: 2025/01/11 16:13:40 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,6 +16,7 @@ Window::Window(Scene *scene, int width, int height, const char *title, int sleep { _scene = scene; _frameCount = 0; + _pixelisation = 0; if (!glfwInit()) { @@ -54,7 +55,6 @@ Window::~Window(void) void Window::process_input() { - 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; @@ -166,22 +166,24 @@ int Window::getFrameCount(void) const return (_frameCount); } -int &Window::getPixelisationAmount(void) -{ - return (pixelisation_amount); -} - bool &Window::getAccumulate(void) { return (accumulate); } -int Window::isPixelated(void) +int Window::getPixelisation(void) { bool mouse = glfwGetMouseButton(_window, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS; bool movement = _scene->getCamera()->getVelocity() > 0.0f; if (mouse || movement) - return (1); - return (0); -} \ No newline at end of file + { + if(_fps < 60 && _pixelisation < 16) + _pixelisation++; + if(_fps > 90 && _pixelisation > 0) + _pixelisation--; + } + else if(_pixelisation) + _pixelisation = 0; + return (_pixelisation + 1); +}