From 724cf7f77935877e87997252162965a82dfd6015 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 17 Jul 2021 12:38:40 -0500 Subject: [PATCH] [nostalgia/core] Setup Imgui drawing --- src/nostalgia/core/glfw/gfx.cpp | 8 ++++++-- src/nostalgia/core/userland/gfx_opengl.cpp | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/nostalgia/core/glfw/gfx.cpp b/src/nostalgia/core/glfw/gfx.cpp index f384dafa..3f066b7e 100644 --- a/src/nostalgia/core/glfw/gfx.cpp +++ b/src/nostalgia/core/glfw/gfx.cpp @@ -8,6 +8,7 @@ #include #include +#include #include @@ -18,7 +19,7 @@ namespace nostalgia::core { constexpr auto Scale = 5; static void handleGlfwError(int err, const char *desc) { - oxErrf("GLFW error ({}): {}", err, desc); + oxErrf("GLFW error ({}): {}\n", err, desc); } ox::Error initGfx(Context *ctx) noexcept { @@ -39,7 +40,10 @@ ox::Error initGfx(Context *ctx) noexcept { glfwMakeContextCurrent(id->window); IMGUI_CHECKVERSION(); ImGui::CreateContext(); - ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; + auto &io = ImGui::GetIO(); + io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; + io.MouseDrawCursor = true; + ImGui_ImplGlfw_InitForOpenGL(id->window, true); oxReturnError(renderer::init(ctx)); return OxError(0); } diff --git a/src/nostalgia/core/userland/gfx_opengl.cpp b/src/nostalgia/core/userland/gfx_opengl.cpp index 5c2ccc99..06b1b86c 100644 --- a/src/nostalgia/core/userland/gfx_opengl.cpp +++ b/src/nostalgia/core/userland/gfx_opengl.cpp @@ -12,6 +12,7 @@ #define IMGUI_IMPL_OPENGL_ES3 #include +#include #include #include @@ -269,11 +270,18 @@ void setBgStatus(Context *ctx, unsigned bg, bool status) noexcept { void draw(Context *ctx) noexcept { const auto id = ctx->rendererData(); renderer::tickFps(id); + ImGui_ImplOpenGL3_NewFrame(); + ImGui_ImplGlfw_NewFrame(); + ImGui::NewFrame(); // clear screen glClearColor(0, 0, 0, 1); glClear(GL_COLOR_BUFFER_BIT); // render + //bool showDemo = true; + //ImGui::ShowDemoWindow(&showDemo); renderer::drawBackgrounds(id); + ImGui::Render(); + ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); } void clearTileLayer(Context *ctx, int layer) noexcept {