diff --git a/src/hello_imgui/internal/backend_impls/runner_factory.cpp b/src/hello_imgui/internal/backend_impls/runner_factory.cpp index a285f824..b42f0c9d 100644 --- a/src/hello_imgui/internal/backend_impls/runner_factory.cpp +++ b/src/hello_imgui/internal/backend_impls/runner_factory.cpp @@ -1,10 +1,10 @@ #include "hello_imgui/internal/backend_impls/runner_factory.h" +#include "hello_imgui/hello_imgui_error.h" #include "hello_imgui/internal/backend_impls/runner_emscripten.h" -#include "hello_imgui/internal/backend_impls/runner_glfw_opengl3.h" +#include "hello_imgui/internal/backend_impls/runner_glfw3.h" #include "hello_imgui/internal/backend_impls/runner_qt.h" -#include "hello_imgui/internal/backend_impls/runner_sdl_opengl3.h" -#include "hello_imgui/hello_imgui_error.h" +#include "hello_imgui/internal/backend_impls/runner_sdl2.h" #include @@ -14,14 +14,14 @@ namespace HelloImGui #ifdef HELLOIMGUI_USE_GLFW_OPENGL3 std::unique_ptr FactorRunnerGlfwOpenGl3(RunnerParams& params) { - return std::make_unique(params); + return std::make_unique(params); } #endif #ifdef HELLOIMGUI_USE_SDL_OPENGL3 std::unique_ptr FactorRunnerSdlOpenGl3(RunnerParams& params) { - return std::make_unique(params); + return std::make_unique(params); } #endif diff --git a/src/hello_imgui/internal/backend_impls/runner_glfw_opengl3.cpp b/src/hello_imgui/internal/backend_impls/runner_glfw3.cpp similarity index 81% rename from src/hello_imgui/internal/backend_impls/runner_glfw_opengl3.cpp rename to src/hello_imgui/internal/backend_impls/runner_glfw3.cpp index ef0bc9b4..dc6e45dd 100644 --- a/src/hello_imgui/internal/backend_impls/runner_glfw_opengl3.cpp +++ b/src/hello_imgui/internal/backend_impls/runner_glfw3.cpp @@ -11,14 +11,13 @@ #include "hello_imgui/internal/stb_image.h" #include "hello_imgui/hello_imgui_assets.h" +#include "backend_window_helper/glfw_window_helper.h" +#include "hello_imgui/hello_imgui_error.h" +#include "runner_glfw3.h" #include #include #include #include -#include "hello_imgui/hello_imgui_error.h" -#include "runner_glfw_opengl3.h" -#include "backend_window_helper/glfw_window_helper.h" - namespace HelloImGui { @@ -30,13 +29,13 @@ namespace HelloImGui fprintf(stderr, "Glfw Error %d: %s\n", error, description); } - RunnerGlfwOpenGl3::RunnerGlfwOpenGl3(RunnerParams & runnerParams) + RunnerGlfw3::RunnerGlfw3(RunnerParams & runnerParams) : AbstractRunner(runnerParams) { mBackendWindowHelper = std::make_unique(); } - void RunnerGlfwOpenGl3::Impl_InitBackend() + void RunnerGlfw3::Impl_InitBackend() { glfwSetErrorCallback(glfw_error_callback); #ifdef __APPLE__ @@ -50,7 +49,7 @@ namespace HelloImGui } - void RunnerGlfwOpenGl3::Impl_CreateWindow() + void RunnerGlfw3::Impl_CreateWindow() { BackendApi::BackendOptions backendOptions; @@ -58,7 +57,7 @@ namespace HelloImGui params.backendPointers.glfwWindow = mWindow; } - void RunnerGlfwOpenGl3::Impl_PollEvents() + void RunnerGlfw3::Impl_PollEvents() { // Poll and handle events (inputs, window resize, etc.) // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants @@ -73,9 +72,9 @@ namespace HelloImGui params.appShallExit = true; } - void RunnerGlfwOpenGl3::Impl_NewFrame_Backend() { ImGui_ImplGlfw_NewFrame(); } + void RunnerGlfw3::Impl_NewFrame_Backend() { ImGui_ImplGlfw_NewFrame(); } - void RunnerGlfwOpenGl3::Impl_UpdateAndRenderAdditionalPlatformWindows() + void RunnerGlfw3::Impl_UpdateAndRenderAdditionalPlatformWindows() { GLFWwindow* backup_current_context = glfwGetCurrentContext(); ImGui::UpdatePlatformWindows(); @@ -83,7 +82,7 @@ namespace HelloImGui glfwMakeContextCurrent(backup_current_context); } - void RunnerGlfwOpenGl3::Impl_Cleanup() + void RunnerGlfw3::Impl_Cleanup() { ImGui_ImplGlfw_Shutdown(); ImGui::DestroyContext(); @@ -92,9 +91,9 @@ namespace HelloImGui glfwTerminate(); } - void RunnerGlfwOpenGl3::Impl_SwapBuffers() { glfwSwapBuffers((GLFWwindow *)mWindow); } + void RunnerGlfw3::Impl_SwapBuffers() { glfwSwapBuffers((GLFWwindow *)mWindow); } - void RunnerGlfwOpenGl3::Impl_SetWindowIcon() + void RunnerGlfw3::Impl_SetWindowIcon() { std::string iconFile = "app_settings/icon.png"; if (!HelloImGui::AssetExists(iconFile)) @@ -128,28 +127,28 @@ namespace HelloImGui // /////////////////////////////////////////////////////////////////////////////////////////////// #ifdef HELLOIMGUI_HAS_OPENGL - void RunnerGlfwOpenGl3::Impl_LinkWindowingToRenderingBackend() + void RunnerGlfw3::Impl_LinkWindowingToRenderingBackend() { ImGui_ImplGlfw_InitForOpenGL((GLFWwindow *)mWindow, true); ImGui_ImplOpenGL3_Init(Impl_GlslVersion().c_str()); } - void RunnerGlfwOpenGl3::Impl_InitRenderBackendCallbacks() + void RunnerGlfw3::Impl_InitRenderBackendCallbacks() { mRenderingBackendCallbacks = CreateOpenGl3RenderingBackendCallbacks(); } - void RunnerGlfwOpenGl3::Impl_CreateGlContext() + void RunnerGlfw3::Impl_CreateGlContext() { glfwMakeContextCurrent((GLFWwindow *) mWindow); // OpenGl! glfwSwapInterval(1); // Enable vsync (openGL only, not vulkan) } - void RunnerGlfwOpenGl3::Impl_Select_Gl_Version() { gOpenGlHelper.SelectOpenGlVersion(); } + void RunnerGlfw3::Impl_Select_Gl_Version() { gOpenGlHelper.SelectOpenGlVersion(); } - std::string RunnerGlfwOpenGl3::Impl_GlslVersion() { return gOpenGlHelper.GlslVersion(); } + std::string RunnerGlfw3::Impl_GlslVersion() { return gOpenGlHelper.GlslVersion(); } - void RunnerGlfwOpenGl3::Impl_InitGlLoader() { gOpenGlHelper.InitGlLoader(); } + void RunnerGlfw3::Impl_InitGlLoader() { gOpenGlHelper.InitGlLoader(); } #endif // #ifdef HELLOIMGUI_HAS_OPENGL diff --git a/src/hello_imgui/internal/backend_impls/runner_glfw_opengl3.h b/src/hello_imgui/internal/backend_impls/runner_glfw3.h similarity index 90% rename from src/hello_imgui/internal/backend_impls/runner_glfw_opengl3.h rename to src/hello_imgui/internal/backend_impls/runner_glfw3.h index 3d968bc0..a473f899 100644 --- a/src/hello_imgui/internal/backend_impls/runner_glfw_opengl3.h +++ b/src/hello_imgui/internal/backend_impls/runner_glfw3.h @@ -7,11 +7,11 @@ namespace HelloImGui { -class RunnerGlfwOpenGl3 : public AbstractRunner +class RunnerGlfw3 : public AbstractRunner { public: - RunnerGlfwOpenGl3(RunnerParams & runnerParams); - virtual ~RunnerGlfwOpenGl3() = default; + RunnerGlfw3(RunnerParams & runnerParams); + virtual ~RunnerGlfw3() = default; protected: // diff --git a/src/hello_imgui/internal/backend_impls/runner_sdl_opengl3.cpp b/src/hello_imgui/internal/backend_impls/runner_sdl2.cpp similarity index 85% rename from src/hello_imgui/internal/backend_impls/runner_sdl_opengl3.cpp rename to src/hello_imgui/internal/backend_impls/runner_sdl2.cpp index 545a4b51..88f0dd49 100644 --- a/src/hello_imgui/internal/backend_impls/runner_sdl_opengl3.cpp +++ b/src/hello_imgui/internal/backend_impls/runner_sdl2.cpp @@ -1,7 +1,7 @@ #ifdef HELLOIMGUI_USE_SDL #ifdef HELLOIMGUI_HAS_OPENGL -#include "runner_sdl_opengl3.h" +#include "runner_sdl2.h" #include #endif @@ -26,20 +26,20 @@ namespace HelloImGui int HandleAppEvents(void *runnerSdlOpenGl3_void, SDL_Event *event) { - RunnerSdlOpenGl3 * runnerSdlOpenGl3 = (RunnerSdlOpenGl3 *)(runnerSdlOpenGl3_void); + RunnerSdl2 * runnerSdlOpenGl3 = (RunnerSdl2 *)(runnerSdlOpenGl3_void); if (runnerSdlOpenGl3->priv_HandleMobileDeviceEvent(event->type)) return 0; else return 1; } - RunnerSdlOpenGl3::RunnerSdlOpenGl3(RunnerParams & runnerParams) : AbstractRunner(runnerParams) + RunnerSdl2::RunnerSdl2(RunnerParams & runnerParams) : AbstractRunner(runnerParams) { mBackendWindowHelper = std::make_unique(); } - void RunnerSdlOpenGl3::Impl_InitBackend() + void RunnerSdl2::Impl_InitBackend() { auto flags = SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER; #ifdef __EMSCRIPTEN__ @@ -54,7 +54,7 @@ namespace HelloImGui SDL_SetEventFilter(HandleAppEvents, this); } - void RunnerSdlOpenGl3::Impl_CreateWindow() + void RunnerSdl2::Impl_CreateWindow() { BackendApi::BackendOptions backendOptions; @@ -62,7 +62,7 @@ namespace HelloImGui params.backendPointers.sdlWindow = mWindow; } - void RunnerSdlOpenGl3::Impl_PollEvents() + void RunnerSdl2::Impl_PollEvents() { SDL_Event event; while (SDL_PollEvent(&event)) @@ -83,7 +83,7 @@ namespace HelloImGui } } - void RunnerSdlOpenGl3::Impl_UpdateAndRenderAdditionalPlatformWindows() + void RunnerSdl2::Impl_UpdateAndRenderAdditionalPlatformWindows() { SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow(); SDL_GLContext backup_current_context = SDL_GL_GetCurrentContext(); @@ -92,7 +92,7 @@ namespace HelloImGui SDL_GL_MakeCurrent(backup_current_window, backup_current_context); } - void RunnerSdlOpenGl3::Impl_Cleanup() + void RunnerSdl2::Impl_Cleanup() { ImGui_ImplSDL2_Shutdown(); ImGui::DestroyContext(); @@ -102,11 +102,11 @@ namespace HelloImGui SDL_Quit(); } - void RunnerSdlOpenGl3::Impl_SwapBuffers() { SDL_GL_SwapWindow((SDL_Window *)mWindow); } + void RunnerSdl2::Impl_SwapBuffers() { SDL_GL_SwapWindow((SDL_Window *)mWindow); } - bool RunnerSdlOpenGl3::priv_HandleMobileDeviceEvent(unsigned int sdl_EventType) + bool RunnerSdl2::priv_HandleMobileDeviceEvent(unsigned int sdl_EventType) { #ifdef HELLOIMGUI_MOBILEDEVICE switch(sdl_EventType) @@ -158,7 +158,7 @@ namespace HelloImGui #endif } - void RunnerSdlOpenGl3::Impl_SetWindowIcon() + void RunnerSdl2::Impl_SetWindowIcon() { std::string iconFile = "app_settings/icon.png"; if (!HelloImGui::AssetExists(iconFile)) @@ -190,7 +190,7 @@ namespace HelloImGui HelloImGui::FreeAssetFileData(&imageAsset); } - void RunnerSdlOpenGl3::Impl_NewFrame_Backend() { ImGui_ImplSDL2_NewFrame(); } + void RunnerSdl2::Impl_NewFrame_Backend() { ImGui_ImplSDL2_NewFrame(); } /////////////////////////////////////////////////////////////////////////////////////////////// // @@ -198,18 +198,18 @@ namespace HelloImGui // /////////////////////////////////////////////////////////////////////////////////////////////// #ifdef HELLOIMGUI_HAS_OPENGL - void RunnerSdlOpenGl3::Impl_InitRenderBackendCallbacks() + void RunnerSdl2::Impl_InitRenderBackendCallbacks() { mRenderingBackendCallbacks = CreateOpenGl3RenderingBackendCallbacks(); } - void RunnerSdlOpenGl3::Impl_LinkWindowingToRenderingBackend() + void RunnerSdl2::Impl_LinkWindowingToRenderingBackend() { ImGui_ImplSDL2_InitForOpenGL((SDL_Window *)mWindow, mGlContext); ImGui_ImplOpenGL3_Init(Impl_GlslVersion().c_str()); } - void RunnerSdlOpenGl3::Impl_CreateGlContext() + void RunnerSdl2::Impl_CreateGlContext() { mGlContext = SDL_GL_CreateContext((SDL_Window *)mWindow); IM_ASSERT(mGlContext != nullptr); @@ -218,9 +218,9 @@ namespace HelloImGui SDL_GL_SetSwapInterval(1); // Enable vsync params.backendPointers.sdlGlContext = mGlContext; } - void RunnerSdlOpenGl3::Impl_InitGlLoader() { gOpenGlSetupSdl.InitGlLoader(); } - void RunnerSdlOpenGl3::Impl_Select_Gl_Version() { gOpenGlSetupSdl.SelectOpenGlVersion(); } - std::string RunnerSdlOpenGl3::Impl_GlslVersion() { return gOpenGlSetupSdl.GlslVersion(); } + void RunnerSdl2::Impl_InitGlLoader() { gOpenGlSetupSdl.InitGlLoader(); } + void RunnerSdl2::Impl_Select_Gl_Version() { gOpenGlSetupSdl.SelectOpenGlVersion(); } + std::string RunnerSdl2::Impl_GlslVersion() { return gOpenGlSetupSdl.GlslVersion(); } #endif // HELLOIMGUI_HAS_OPENGL diff --git a/src/hello_imgui/internal/backend_impls/runner_sdl_opengl3.h b/src/hello_imgui/internal/backend_impls/runner_sdl2.h similarity index 90% rename from src/hello_imgui/internal/backend_impls/runner_sdl_opengl3.h rename to src/hello_imgui/internal/backend_impls/runner_sdl2.h index f3b1e69c..d04db852 100644 --- a/src/hello_imgui/internal/backend_impls/runner_sdl_opengl3.h +++ b/src/hello_imgui/internal/backend_impls/runner_sdl2.h @@ -7,11 +7,11 @@ namespace HelloImGui { - class RunnerSdlOpenGl3 : public AbstractRunner + class RunnerSdl2 : public AbstractRunner { public: - RunnerSdlOpenGl3(RunnerParams & runnerParams); - virtual ~RunnerSdlOpenGl3() = default; + RunnerSdl2(RunnerParams & runnerParams); + virtual ~RunnerSdl2() = default; protected: //