it just segfaults and does nothing else

git
This commit is contained in:
Benjamin Kyd
2023-10-12 16:18:58 +01:00
parent 88921241f1
commit f272e33d4e
4 changed files with 79 additions and 74 deletions

View File

@@ -57,7 +57,7 @@ InfernoApp* inferno_create()
void inferno_cleanup(InfernoApp* app) void inferno_cleanup(InfernoApp* app)
{ {
graphics::window_cleanup(); graphics::window_cleanup();
app.reset(); delete app;
} }
static void inferno_gui_help_marker(const char* desc) static void inferno_gui_help_marker(const char* desc)
@@ -140,78 +140,79 @@ int inferno_run(InfernoApp* app)
if (!graphics::window_new_frame()) if (!graphics::window_new_frame())
break; break;
// set the main window to the dockspace and then on the first launch set the preset // // set the main window to the dockspace and then on the first launch set the preset
ImGuiID dockspace_id = ImGui::GetID("main"); // ImGuiID dockspace_id = ImGui::GetID("main");
static ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_PassthruCentralNode; // static ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_PassthruCentralNode;
if (ImGui::DockBuilderGetNode(dockspace_id) == NULL) { // if (ImGui::DockBuilderGetNode(dockspace_id) == NULL) {
inferno_preset_gui(app); // inferno_preset_gui(app);
} // }
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags); // 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) // // Menu Bar
graphics::camera_mouse_move(app->Scene->Camera, app->Input->MouseDelta); // static bool showPreview = true;
if (app->Input->MovementDelta != 0b00000000) // static bool showRenderSettings = true;
graphics::camera_move(app->Scene->Camera, app->Input->MovementDelta); // static bool showDemoWindow = false;
// if (ImGui::BeginMenuBar()) {
// Menu Bar // if (ImGui::BeginMenu("Menu")) {
static bool showPreview = true; // ImGui::EndMenu();
static bool showRenderSettings = true; // }
static bool showDemoWindow = false; // if (ImGui::BeginMenu("View")) {
if (ImGui::BeginMenuBar()) { // ImGui::Checkbox("Show Preview", &showPreview);
if (ImGui::BeginMenu("Menu")) { // ImGui::SameLine();
ImGui::EndMenu(); // inferno_gui_help_marker("Show the preview window");
} // ImGui::Checkbox("Show Settings", &showRenderSettings);
if (ImGui::BeginMenu("View")) { // ImGui::SameLine();
ImGui::Checkbox("Show Preview", &showPreview); // inferno_gui_help_marker("Show the Inferno HART settings window");
ImGui::SameLine(); // ImGui::Checkbox("Show Demo", &showDemoWindow);
inferno_gui_help_marker("Show the preview window"); //
ImGui::Checkbox("Show Settings", &showRenderSettings); // ImGui::EndMenu();
ImGui::SameLine(); // }
inferno_gui_help_marker("Show the Inferno HART settings window"); // ImGui::EndMenuBar();
ImGui::Checkbox("Show Demo", &showDemoWindow); // }
//
ImGui::EndMenu(); // if (showPreview && ImGui::Begin("Preview", nullptr, ImGuiWindowFlags_NoScrollbar)) {
} // if (ImGui::IsWindowHovered()) {
ImGui::EndMenuBar(); // inferno_move_input(app);
} // } else {
// inferno_stop_move_input(app);
if (showPreview && ImGui::Begin("Preview", nullptr, ImGuiWindowFlags_NoScrollbar)) { // }
if (ImGui::IsWindowHovered()) { //
inferno_move_input(app); // graphics::raster_set_viewport(scene::scene_get_camera(app->Scene), { ImGui::GetWindowSize().x, ImGui::GetWindowSize().y });
} else { // graphics::preview_draw(app->PreviewRenderer, app->Scene);
inferno_stop_move_input(app); //
} // ImTextureID texture = (ImTextureID)graphics::preview_get_rendered_texture(app->PreviewRenderer);
// ImGui::Image(
graphics::raster_set_viewport(scene::scene_get_camera(app->Scene), { ImGui::GetWindowSize().x, ImGui::GetWindowSize().y }); // texture,
graphics::preview_draw(app->PreviewRenderer, app->Scene); // { ImGui::GetWindowSize().x, ImGui::GetWindowSize().y },
// ImVec2(0, 1), ImVec2(1, 0));
ImTextureID texture = (ImTextureID)graphics::preview_get_rendered_texture(app->PreviewRenderer); //
ImGui::Image( // glBindFramebuffer(GL_FRAMEBUFFER, 0);
texture, // ImGui::End();
{ ImGui::GetWindowSize().x, ImGui::GetWindowSize().y }, // }
ImVec2(0, 1), ImVec2(1, 0));
glBindFramebuffer(GL_FRAMEBUFFER, 0);
ImGui::End();
}
// clang-format off // clang-format off
GLenum err; // GLenum err;
while((err = glGetError()) != GL_NO_ERROR) { // while((err = glGetError()) != GL_NO_ERROR) {
std::string error; // std::string error;
switch (err) { // switch (err) {
case GL_INVALID_ENUM: error = "INVALID_ENUM"; break; // case GL_INVALID_ENUM: error = "INVALID_ENUM"; break;
case GL_INVALID_VALUE: error = "INVALID_VALUE"; break; // case GL_INVALID_VALUE: error = "INVALID_VALUE"; break;
case GL_INVALID_OPERATION: error = "INVALID_OPERATION"; break; // case GL_INVALID_OPERATION: error = "INVALID_OPERATION"; break;
case GL_STACK_OVERFLOW: error = "STACK_OVERFLOW"; break; // case GL_STACK_OVERFLOW: error = "STACK_OVERFLOW"; break;
case GL_STACK_UNDERFLOW: error = "STACK_UNDERFLOW"; break; // case GL_STACK_UNDERFLOW: error = "STACK_UNDERFLOW"; break;
case GL_OUT_OF_MEMORY: error = "OUT_OF_MEMORY"; break; // case GL_OUT_OF_MEMORY: error = "OUT_OF_MEMORY"; break;
case GL_INVALID_FRAMEBUFFER_OPERATION: error = "INVALID_FRAMEBUFFER_OPERATION"; break; // case GL_INVALID_FRAMEBUFFER_OPERATION: error = "INVALID_FRAMEBUFFER_OPERATION"; break;
default: error = std::to_string((uint32_t)err); break; // default: error = std::to_string((uint32_t)err); break;
} // }
yolo::error("[GL]: {} {}", err, error); // yolo::error("[GL]: {} {}", err, error);
} // }
//
graphics::window_render(); graphics::window_render();
} }

View File

@@ -19,8 +19,8 @@ namespace scene {
} }
typedef struct InfernoInput { typedef struct InfernoInput {
glm::vec2 MouseDelta; glm::vec2 MouseDelta = {0.0f, 0.0f};
uint8_t MovementDelta; uint8_t MovementDelta = 0;
} InfernoInput; } InfernoInput;
typedef struct InfernoApp { typedef struct InfernoApp {

View File

@@ -31,8 +31,8 @@ Camera* camera_create()
void camera_cleanup(Camera* camera) void camera_cleanup(Camera* camera)
{ {
camera->_impl.reset(); delete camera->_impl;
camera.reset(); delete camera;
} }
void camera_update(Camera* camera) void camera_update(Camera* camera)

View File

@@ -60,6 +60,10 @@ void setupGLFW(std::string title)
glfwMakeContextCurrent(Window); glfwMakeContextCurrent(Window);
gladLoadGLLoader((GLADloadproc)glfwGetProcAddress); gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
glfwSwapInterval(1); // Enable vsync 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() void setupImGui()