From f272e33d4ee64259efa679891444b608d0395b6f Mon Sep 17 00:00:00 2001 From: Benjamin Kyd Date: Thu, 12 Oct 2023 16:18:58 +0100 Subject: [PATCH] it just segfaults and does nothing else git --- src/inferno.cpp | 141 ++++++++++++++++++++++--------------------- src/inferno.hpp | 4 +- src/scene/camera.cpp | 4 +- src/window.cpp | 4 ++ 4 files changed, 79 insertions(+), 74 deletions(-) diff --git a/src/inferno.cpp b/src/inferno.cpp index d9a35c6..c857780 100644 --- a/src/inferno.cpp +++ b/src/inferno.cpp @@ -57,7 +57,7 @@ InfernoApp* inferno_create() void inferno_cleanup(InfernoApp* app) { graphics::window_cleanup(); - app.reset(); + delete app; } static void inferno_gui_help_marker(const char* desc) @@ -140,78 +140,79 @@ int inferno_run(InfernoApp* app) if (!graphics::window_new_frame()) break; - // set the main window to the dockspace and then on the first launch set the preset - ImGuiID dockspace_id = ImGui::GetID("main"); - static ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_PassthruCentralNode; - if (ImGui::DockBuilderGetNode(dockspace_id) == NULL) { - inferno_preset_gui(app); - } - ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags); + // // set the main window to the dockspace and then on the first launch set the preset + // ImGuiID dockspace_id = ImGui::GetID("main"); + // static ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_PassthruCentralNode; + // if (ImGui::DockBuilderGetNode(dockspace_id) == NULL) { + // inferno_preset_gui(app); + // } + // ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags); + // + // yolo::debug("{} {} {}", app->Scene->Camera, app->Input, app->Input->MouseDelta.x); + // if (glm::length(app->Input->MouseDelta) > 0.0f) + // graphics::camera_mouse_move(app->Scene->Camera, app->Input->MouseDelta); + // if (app->Input->MovementDelta != 0b00000000) + // graphics::camera_move(app->Scene->Camera, app->Input->MovementDelta); - if (glm::length(app->Input->MouseDelta) > 0.0f) - graphics::camera_mouse_move(app->Scene->Camera, app->Input->MouseDelta); - if (app->Input->MovementDelta != 0b00000000) - graphics::camera_move(app->Scene->Camera, app->Input->MovementDelta); - - // Menu Bar - static bool showPreview = true; - static bool showRenderSettings = true; - static bool showDemoWindow = false; - if (ImGui::BeginMenuBar()) { - if (ImGui::BeginMenu("Menu")) { - ImGui::EndMenu(); - } - if (ImGui::BeginMenu("View")) { - ImGui::Checkbox("Show Preview", &showPreview); - ImGui::SameLine(); - inferno_gui_help_marker("Show the preview window"); - ImGui::Checkbox("Show Settings", &showRenderSettings); - ImGui::SameLine(); - inferno_gui_help_marker("Show the Inferno HART settings window"); - ImGui::Checkbox("Show Demo", &showDemoWindow); - - ImGui::EndMenu(); - } - ImGui::EndMenuBar(); - } - - if (showPreview && ImGui::Begin("Preview", nullptr, ImGuiWindowFlags_NoScrollbar)) { - if (ImGui::IsWindowHovered()) { - inferno_move_input(app); - } else { - inferno_stop_move_input(app); - } - - graphics::raster_set_viewport(scene::scene_get_camera(app->Scene), { ImGui::GetWindowSize().x, ImGui::GetWindowSize().y }); - graphics::preview_draw(app->PreviewRenderer, app->Scene); - - ImTextureID texture = (ImTextureID)graphics::preview_get_rendered_texture(app->PreviewRenderer); - ImGui::Image( - texture, - { ImGui::GetWindowSize().x, ImGui::GetWindowSize().y }, - ImVec2(0, 1), ImVec2(1, 0)); - - glBindFramebuffer(GL_FRAMEBUFFER, 0); - ImGui::End(); - } + // // Menu Bar + // static bool showPreview = true; + // static bool showRenderSettings = true; + // static bool showDemoWindow = false; + // if (ImGui::BeginMenuBar()) { + // if (ImGui::BeginMenu("Menu")) { + // ImGui::EndMenu(); + // } + // if (ImGui::BeginMenu("View")) { + // ImGui::Checkbox("Show Preview", &showPreview); + // ImGui::SameLine(); + // inferno_gui_help_marker("Show the preview window"); + // ImGui::Checkbox("Show Settings", &showRenderSettings); + // ImGui::SameLine(); + // inferno_gui_help_marker("Show the Inferno HART settings window"); + // ImGui::Checkbox("Show Demo", &showDemoWindow); + // + // ImGui::EndMenu(); + // } + // ImGui::EndMenuBar(); + // } + // + // if (showPreview && ImGui::Begin("Preview", nullptr, ImGuiWindowFlags_NoScrollbar)) { + // if (ImGui::IsWindowHovered()) { + // inferno_move_input(app); + // } else { + // inferno_stop_move_input(app); + // } + // + // graphics::raster_set_viewport(scene::scene_get_camera(app->Scene), { ImGui::GetWindowSize().x, ImGui::GetWindowSize().y }); + // graphics::preview_draw(app->PreviewRenderer, app->Scene); + // + // ImTextureID texture = (ImTextureID)graphics::preview_get_rendered_texture(app->PreviewRenderer); + // ImGui::Image( + // texture, + // { ImGui::GetWindowSize().x, ImGui::GetWindowSize().y }, + // ImVec2(0, 1), ImVec2(1, 0)); + // + // glBindFramebuffer(GL_FRAMEBUFFER, 0); + // ImGui::End(); + // } // clang-format off - GLenum err; - while((err = glGetError()) != GL_NO_ERROR) { - std::string error; - switch (err) { - case GL_INVALID_ENUM: error = "INVALID_ENUM"; break; - case GL_INVALID_VALUE: error = "INVALID_VALUE"; break; - case GL_INVALID_OPERATION: error = "INVALID_OPERATION"; break; - case GL_STACK_OVERFLOW: error = "STACK_OVERFLOW"; break; - case GL_STACK_UNDERFLOW: error = "STACK_UNDERFLOW"; break; - case GL_OUT_OF_MEMORY: error = "OUT_OF_MEMORY"; break; - case GL_INVALID_FRAMEBUFFER_OPERATION: error = "INVALID_FRAMEBUFFER_OPERATION"; break; - default: error = std::to_string((uint32_t)err); break; - } - yolo::error("[GL]: {} {}", err, error); - } - + // GLenum err; + // while((err = glGetError()) != GL_NO_ERROR) { + // std::string error; + // switch (err) { + // case GL_INVALID_ENUM: error = "INVALID_ENUM"; break; + // case GL_INVALID_VALUE: error = "INVALID_VALUE"; break; + // case GL_INVALID_OPERATION: error = "INVALID_OPERATION"; break; + // case GL_STACK_OVERFLOW: error = "STACK_OVERFLOW"; break; + // case GL_STACK_UNDERFLOW: error = "STACK_UNDERFLOW"; break; + // case GL_OUT_OF_MEMORY: error = "OUT_OF_MEMORY"; break; + // case GL_INVALID_FRAMEBUFFER_OPERATION: error = "INVALID_FRAMEBUFFER_OPERATION"; break; + // default: error = std::to_string((uint32_t)err); break; + // } + // yolo::error("[GL]: {} {}", err, error); + // } + // graphics::window_render(); } diff --git a/src/inferno.hpp b/src/inferno.hpp index d74b59a..5d895bf 100644 --- a/src/inferno.hpp +++ b/src/inferno.hpp @@ -19,8 +19,8 @@ namespace scene { } typedef struct InfernoInput { - glm::vec2 MouseDelta; - uint8_t MovementDelta; + glm::vec2 MouseDelta = {0.0f, 0.0f}; + uint8_t MovementDelta = 0; } InfernoInput; typedef struct InfernoApp { diff --git a/src/scene/camera.cpp b/src/scene/camera.cpp index 4f77f37..9e6b380 100644 --- a/src/scene/camera.cpp +++ b/src/scene/camera.cpp @@ -31,8 +31,8 @@ Camera* camera_create() void camera_cleanup(Camera* camera) { - camera->_impl.reset(); - camera.reset(); + delete camera->_impl; + delete camera; } void camera_update(Camera* camera) diff --git a/src/window.cpp b/src/window.cpp index 41758e5..fd99e83 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -60,6 +60,10 @@ void setupGLFW(std::string title) glfwMakeContextCurrent(Window); gladLoadGLLoader((GLADloadproc)glfwGetProcAddress); glfwSwapInterval(1); // Enable vsync + yolo::info("GLFW {} initialized", glfwGetVersionString()); + yolo::info("OpenGL {} initialized", glGetString(GL_VERSION)); + yolo::info("GLSL {} initialized", glGetString(GL_SHADING_LANGUAGE_VERSION)); + yolo::info("INFERNO HART Running on ", glGetString(GL_RENDERER)); } void setupImGui()