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)
{
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();
}

View File

@@ -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 {

View File

@@ -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)

View File

@@ -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()