diff --git a/libhart/hardware_accelerator.hpp b/libhart/hardware_accelerator.hpp index 6eb9245..dcd100e 100644 --- a/libhart/hardware_accelerator.hpp +++ b/libhart/hardware_accelerator.hpp @@ -5,7 +5,7 @@ namespace inferno { enum ACCEL_TYPE { - RAY_TRI_ONLY, + ACCEL_TYPE_RAY_TRI_ONLY, }; class Accelerator diff --git a/libhart/scene/camera.hpp b/libhart/scene/camera.hpp index e9129c6..4d4945a 100644 --- a/libhart/scene/camera.hpp +++ b/libhart/scene/camera.hpp @@ -42,7 +42,4 @@ private: }; - } - - diff --git a/src/inferno.cpp b/src/inferno.cpp index 6de00c0..d410a45 100644 --- a/src/inferno.cpp +++ b/src/inferno.cpp @@ -4,7 +4,6 @@ #include "gui/layout.hpp" #include "window.hpp" -#include #include #include @@ -13,7 +12,7 @@ namespace inferno { -Inferno::Inferno(int argc, char** argv) +Inferno::Inferno() { // MOTD spdlog::info("INFERNO HART v" INFERNO_VERSION); @@ -48,9 +47,12 @@ int Inferno::run() { mWin->setKeyCallback(&handleKbd); mWin->setMouseCallback(&handlePtr); + mWin->setFPSMode(); while (true) { if (!mWin->newFrame()) { break; } + + // UI ImGuiID dockspace_id = ImGui::GetID("main"); // set the main window to the dockspace and then on the first launch set the preset @@ -58,28 +60,10 @@ int Inferno::run() if (ImGui::DockBuilderGetNode(dockspace_id) == NULL) { this->uiPreset(); } ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags); - // Menu Bar - // if (ImGui::BeginMenuBar()) - // { - // if (ImGui::BeginMenu("Menu")) - // { - // if (ImGui::MenuItem("New")) {} - // if (ImGui::MenuItem("Open", "Ctrl+O")) {} - // if (ImGui::BeginMenu("Open Recent")) - // { - // ImGui::EndMenu(); - // } - // if (ImGui::MenuItem("Save", "Ctrl+S")) {} - // if (ImGui::MenuItem("Save As..")) {} + // KBD & MOUSE + std::cout << mouseDelta.x << " " << mouseDelta.y << std::endl; + - // ImGui::Separator(); - // if (ImGui::BeginMenu("Options")) - // { - // ImGui::EndMenu(); - // } - // } - // ImGui::EndMenuBar(); - // } ImGui::Begin("Preview"); ImGui::End(); @@ -119,7 +103,13 @@ void handleKbd(int key, int scan, int action, int mod) void handlePtr(double x, double y) { - + int iX = floor(x); + int iY = floor(x); + static int oX, oY; + glm::vec2 mouseDelta = { iX - oX, iY - oY }; + Inferno::GetInstance().mouseDelta = mouseDelta; + oX = iX; + oY = iY; } } diff --git a/src/inferno.hpp b/src/inferno.hpp index 5bba487..0c5e215 100644 --- a/src/inferno.hpp +++ b/src/inferno.hpp @@ -1,27 +1,30 @@ #pragma once +#include "graphics.hpp" + +#include namespace inferno { class Window; class GLFWwindow; - class RasterizeRenderer; class Scene; -class Inferno +class Inferno : public helpers::Singleton { public: - Inferno(int argc, char** argv); + Inferno(); ~Inferno(); void uiPreset(); int run(); +public: + glm::vec2 mouseDelta; + glm::vec3 kbdDelta; private: - double mLastMouseX, mLastMouseY; - friend void handleKbd(int key, int scan, int action, int mod); friend void handlePtr(double x, double y); diff --git a/src/main.cpp b/src/main.cpp index 9380328..497c509 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,8 +7,7 @@ int main(int argc, char** argv) { try { - inferno::Inferno inferno(argc, argv); - return inferno.run(); + return inferno::Inferno::GetInstance().run(); } catch (std::exception e) { diff --git a/src/version.hpp b/src/version.hpp index 5ce945d..9e5aad7 100644 --- a/src/version.hpp +++ b/src/version.hpp @@ -1,2 +1,3 @@ #pragma once -#define INFERNO_VERSION "3.0.1_alpha" + +#define INFERNO_VERSION "3.0.1_alpha" diff --git a/src/window.cpp b/src/window.cpp index efba1b3..45efd95 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -55,6 +55,12 @@ void Window::getPos(int& x, int& y) glfwGetWindowPos(window, &x, &y); } +void Window::setFPSMode() +{ + mWinMode = WIN_MODE_FPS; + glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); +} + void Window::setKeyCallback(KeyCallback callback) { mKeyCallback = callback; @@ -98,6 +104,12 @@ bool Window::newFrame() void Window::render() { + if (mWinMode == WIN_MODE_FPS) + { + glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); + glfwSetCursorPos(window, (double)width / 2, (double)height / 2); + } + ImGui::End(); ImGui::Render(); auto io = ImGui::GetIO(); diff --git a/src/window.hpp b/src/window.hpp index e9f57f4..539941b 100644 --- a/src/window.hpp +++ b/src/window.hpp @@ -12,6 +12,12 @@ namespace inferno { typedef void (*KeyCallback)(int key, int scan, int action, int mod); typedef void (*MouseCallback)(double x, double y); +enum WINDOW_MODE +{ + WIN_MODE_DEFAULT, + WIN_MODE_FPS, +}; + class Window : public helpers::Singleton { public: @@ -31,11 +37,16 @@ public: void getPos(int& x, int& y); GLFWwindow* getGLFWWindow() { return window; } + void setFPSMode(); + void setKeyCallback(KeyCallback callback); void setMouseCallback(MouseCallback callback); KeyCallback getKeyCallback(); MouseCallback getMouseCallback(); +private: + WINDOW_MODE mWinMode = WIN_MODE_DEFAULT; + private: void setupGLFW(std::string title); void setupImGui(); @@ -47,12 +58,12 @@ private: KeyCallback mKeyCallback = nullptr; MouseCallback mMouseCallback = nullptr; +private: static void glfwErrorCallback(int error, const char* description); - int width, height; const char* glslVersion; GLFWwindow* window; }; -} \ No newline at end of file +}