Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove obsolete BackendType selection #96

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/ci_vcpkg_package_tests/ci_vcpkg_package_tests_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ int main(int argc, char**argv)

try
{
runnerParams.backendType = HelloImGui::BackendType::Glfw;
runnerParams.platformBackendType = HelloImGui::PlatformBackendType::Glfw;

if (argc == 2 && strcmp(argv[1], "sdl") == 0)
runnerParams.backendType = HelloImGui::BackendType::Sdl;
runnerParams.platformBackendType = HelloImGui::PlatformBackendType::Sdl;

if (runnerParams.backendType == HelloImGui::BackendType::Glfw)
if (runnerParams.platformBackendType == HelloImGui::PlatformBackendType::Glfw)
printf("Using GLFW backend\n");
else
printf("Using SDL backend\n");
Expand Down
2 changes: 1 addition & 1 deletion hello_imgui_cmake/overlay_vcpkg/test_vcpkg_himgui/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
int main()
{
HelloImGui::RunnerParams runnerParams;
runnerParams.backendType = HelloImGui::BackendType::Glfw; // Sdl fails with Vulkan
runnerParams.platformBackendType = HelloImGui::PlatformBackendType::Glfw; // Sdl fails with Vulkan
runnerParams.callbacks.ShowGui = []() {
#ifdef HELLOIMGUI_HAS_OPENGL
ImGui::Text("HELLOIMGUI_HAS_OPENGL");
Expand Down
14 changes: 2 additions & 12 deletions src/hello_imgui/doc_params.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,10 @@ struct RunnerParams
// Options for the renderer backend
RendererBackendOptions rendererBackendOptions;

// `backendType`: _enum BackendType, default=PlatformBackendType::FirstAvailable_
// `platformBackendType`: _enum PlatformBackendType, default=PlatformBackendType::FirstAvailable_
// Select the wanted platform backend type between `Sdl`, `Glfw`.
// if `FirstAvailable`, Glfw will be preferred over Sdl when both are available.
// Only useful when multiple backend are compiled and available.
// (for compatibility with older versions, you can use BackendType instead of PlatformBackendType)
PlatformBackendType platformBackendType = PlatformBackendType::FirstAvailable;

// `renderingBackendType`: _enum RenderingBackendType, default=RenderingBackendType::FirstAvailable_
Expand Down Expand Up @@ -195,11 +194,6 @@ struct RunnerParams
// Set the application refresh rate
// (only used on emscripten: 0 stands for "let the app or the browser decide")
int emscripten_fps = 0;

// --------------- Legacy -------------------`
#ifndef HELLOIMGUI_DISABLE_OBSOLETE_BACKEND
PlatformBackendType& backendType = platformBackendType; // a synonym, for backward compatibility
#endif
};
```

Expand All @@ -209,7 +203,7 @@ struct RunnerParams
```cpp

// You can select the platform backend type (SDL, GLFW) and the rendering backend type
// via RunnerParams.backendType and RunnerParams.renderingBackendType.
// via RunnerParams.platformBackendType and RunnerParams.renderingBackendType.

// Platform backend type (SDL, GLFW)
// They are listed in the order of preference when FirstAvailable is selected.
Expand All @@ -220,10 +214,6 @@ enum class PlatformBackendType
Sdl,
};

#ifndef HELLOIMGUI_DISABLE_OBSOLETE_BACKEND
using BackendType = PlatformBackendType; // for backward compatibility
#endif

// Rendering backend type (OpenGL3, Metal, Vulkan, DirectX11, DirectX12)
// They are listed in the order of preference when FirstAvailable is selected.
enum class RendererBackendType
Expand Down
2 changes: 1 addition & 1 deletion src/hello_imgui/doc_params.src.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ See [runner_params.h](https://github.com/pthom/hello_imgui/blob/master/src/hello


```cpp
@import "runner_params.h" {md_id=BackendType}
@import "runner_params.h" {md_id=PlatformBackendType}
```


Expand Down
4 changes: 2 additions & 2 deletions src/hello_imgui/internal/backend_impls/runner_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ void ChooseBackendTypesIfSelectedAsFirstAvailable(RunnerParams* runnerParams)
std::unique_ptr<AbstractRunner> FactorRunner(RunnerParams& params)
{
ChooseBackendTypesIfSelectedAsFirstAvailable(&params);
if(params.backendType == BackendType::Glfw)
if (params.platformBackendType == PlatformBackendType::Glfw)
{
#ifdef HELLOIMGUI_USE_GLFW3
return std::make_unique<RunnerGlfw3>(params);
#else
return nullptr;
#endif
}
else if (params.backendType == BackendType::Sdl)
else if (params.platformBackendType == PlatformBackendType::Sdl)
{
#if defined(__EMSCRIPTEN__)
return std::make_unique<RunnerSdlEmscripten>(params);
Expand Down
18 changes: 3 additions & 15 deletions src/hello_imgui/runner_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@
#include "hello_imgui/dpi_aware.h"
#include <vector>

// #define HELLOIMGUI_DISABLE_OBSOLETE_BACKEND

namespace HelloImGui
{

// --------------------------------------------------------------------------------------------------------------------

// @@md#BackendType
// @@md#PlatformBackendType

// You can select the platform backend type (SDL, GLFW) and the rendering backend type
// via RunnerParams.backendType and RunnerParams.renderingBackendType.
// via RunnerParams.platformBackendType and RunnerParams.renderingBackendType.

// Platform backend type (SDL, GLFW)
// They are listed in the order of preference when FirstAvailable is selected.
Expand All @@ -29,10 +27,6 @@ enum class PlatformBackendType
Sdl,
};

#ifndef HELLOIMGUI_DISABLE_OBSOLETE_BACKEND
using BackendType = PlatformBackendType; // for backward compatibility
#endif

// Rendering backend type (OpenGL3, Metal, Vulkan, DirectX11, DirectX12)
// They are listed in the order of preference when FirstAvailable is selected.
enum class RendererBackendType
Expand Down Expand Up @@ -186,11 +180,10 @@ struct RunnerParams
// Options for the renderer backend
RendererBackendOptions rendererBackendOptions;

// `backendType`: _enum BackendType, default=PlatformBackendType::FirstAvailable_
// `platformBackendType`: _enum PlatformBackendType, default=PlatformBackendType::FirstAvailable_
// Select the wanted platform backend type between `Sdl`, `Glfw`.
// if `FirstAvailable`, Glfw will be preferred over Sdl when both are available.
// Only useful when multiple backend are compiled and available.
// (for compatibility with older versions, you can use BackendType instead of PlatformBackendType)
PlatformBackendType platformBackendType = PlatformBackendType::FirstAvailable;

// `renderingBackendType`: _enum RenderingBackendType, default=RenderingBackendType::FirstAvailable_
Expand Down Expand Up @@ -263,11 +256,6 @@ struct RunnerParams
// Set the application refresh rate
// (only used on emscripten: 0 stands for "let the app or the browser decide")
int emscripten_fps = 0;

// --------------- Legacy -------------------`
#ifndef HELLOIMGUI_DISABLE_OBSOLETE_BACKEND
PlatformBackendType& backendType = platformBackendType; // a synonym, for backward compatibility
#endif
};
// @@md

Expand Down
Loading