diff --git a/src/preview_renderer/shader.hpp b/src/preview_renderer/shader.hpp index c43bd7f..9d83457 100644 --- a/src/preview_renderer/shader.hpp +++ b/src/preview_renderer/shader.hpp @@ -39,6 +39,5 @@ GLuint shader_get_uniform(std::unique_ptr& shader, const std::string& un void shader_use(std::unique_ptr& shader); void shader_unuse(std::unique_ptr& shader); - } diff --git a/src/window.cpp b/src/window.cpp index 121a470..2eba72b 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -4,21 +4,26 @@ #include "yolo/yolo.hpp" -using namespace inferno; +using namespace inferno::graphics; -Window::Window() {} +static WINDOW_MODE WinMode = WINDOW_MODE::WIN_MODE_DEFAULT; +static KeyCallback KeyCallback = nullptr; +static int Width, Height; +static const char* GlslVersion; +static GLFWwindow* Gindow; -Window::~Window() { +static void glfwErrorCallback(int error, const char* description); + +void window_cleanup() { shutdownImGui(); shutdownGLFW(); } -void Window::init(std::string title, int width, int height) { - this->width = width; - this->height = height; +void window_create(std::string title, int width, int height) { + Width = width; + Height = height; setupGLFW(title); glfwSetKeyCallback(getGLFWWindow(), glfwKeyCallback); - setupImGui(); } diff --git a/src/window.hpp b/src/window.hpp index 6063da9..ab2bd57 100644 --- a/src/window.hpp +++ b/src/window.hpp @@ -7,7 +7,7 @@ #define WINDOW_FLAGS ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus | ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoCollapse -namespace inferno { +namespace inferno::graphics { typedef void (*KeyCallback)(int key, int scan, int action, int mod); typedef void (*MouseCallback)(double x, double y); @@ -18,48 +18,24 @@ enum WINDOW_MODE WIN_MODE_FPS, }; -class Window : public helpers::Singleton -{ -public: - Window(); - ~Window(); +void window_create(std::string title, int width, int height); +void window_cleanup(); - void init(std::string title, int width, int height); +void window_set_title(std::string title); - bool newFrame(); - void render(); +void window_set_size(int w, int h); +void window_set_pos(int x, int y); +glm::vec2 window_get_size(); +void window_get_pos(int& x, int& y); - void setTitle(std::string title); - void setSize(int w, int h); - void setPos(int x, int y); +GLFWwindow* window_get_glfw_window(); +void window_set_fps_mode(); - glm::vec2 getSize(); - void getPos(int& x, int& y); - GLFWwindow* getGLFWWindow() { return window; } +void window_set_key_callback(KeyCallback callback); +KeyCallback window_get_key_callback(); - void setFPSMode(); - - void setKeyCallback(KeyCallback callback); - KeyCallback getKeyCallback(); - -private: - WINDOW_MODE mWinMode = WIN_MODE_DEFAULT; - -private: - void setupGLFW(std::string title); - void setupImGui(); - void shutdownImGui(); - void shutdownGLFW(); - - static void glfwKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods); - KeyCallback mKeyCallback = nullptr; - -private: - static void glfwErrorCallback(int error, const char* description); - - int width, height; - const char* glslVersion; - GLFWwindow* window; -}; +bool window_new_frame(); +void window_render(); } +