Skip to content

Commit

Permalink
ext/agui: synced agui
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasdr committed Feb 21, 2025
1 parent 338fd14 commit 4d6fc12
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 3 deletions.
86 changes: 86 additions & 0 deletions ext/a-gui/src/agui/application/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <agui/audio/Audio.h>
#include <agui/gui/textures/GUITexture.h>
#include <agui/gui/fileio/TextureReader.h>
#include <agui/gui/renderer/ApplicationGL3Renderer.h>
#include <agui/gui/renderer/GUIRendererBackend.h>
#include <agui/gui/GUIEventHandler.h>
#include <agui/os/filesystem/FileSystem.h>
Expand All @@ -66,6 +67,7 @@ using agui::application::Application;
using agui::audio::Audio;
using agui::gui::textures::GUITexture;
using agui::gui::fileio::TextureReader;
using agui::gui::renderer::ApplicationGL3Renderer;
using agui::gui::renderer::GUIRendererBackend;
using agui::gui::GUIEventHandler;
using agui::os::filesystem::FileSystem;
Expand Down Expand Up @@ -564,6 +566,22 @@ int Application::run(int argc, char** argv, const string& title, GUIEventHandler
}
}

// renderer backend library
string rendererBackendType = "opengl3core";
for (auto i = 1; i < argc; i++) {
auto argValue = string(argv[i]);
if (argValue == "--debug") debuggingEnabled = true; else
if (argValue == "--gles2") rendererBackendType = "opengles2"; else
if (argValue == "--gl2") rendererBackendType = "opengl2"; else
if (argValue == "--gl3core") rendererBackendType = "opengl3core"; else
if (argValue == "--vulkan") rendererBackendType = "vulkan";
}

// load engine renderer backend plugin
if (loadGUIRendererPlugin(rendererBackendType) == false) {
return EXITCODE_FAILURE;
}

// window hints
if ((windowHints & WINDOW_HINT_NOTRESIZEABLE) == WINDOW_HINT_NOTRESIZEABLE) glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
if ((windowHints & WINDOW_HINT_NOTDECORATED) == WINDOW_HINT_NOTDECORATED) glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);
Expand Down Expand Up @@ -663,6 +681,74 @@ int Application::run(int argc, char** argv, const string& title, GUIEventHandler
return localExitCode;
}

bool Application::loadGUIRendererPlugin(const string& rendererType) {
string guiRendererBackendLibrary = "libgui" + rendererType + "renderer";
#if defined(_WIN32)
guiRendererBackendLibrary = guiRendererBackendLibrary + ".dll";
#elif defined(__APPLE__)
guiRendererBackendLibrary = guiRendererBackendLibrary + ".dylib";
#else
guiRendererBackendLibrary = guiRendererBackendLibrary + ".so";
#endif

// renderer
Console::printLine("Application::run(): Opening GUI renderer backend library: " + guiRendererBackendLibrary);

#if defined(_MSC_VER)
//
auto guiRendererBackendLibraryHandle = LoadLibrary(guiRendererBackendLibrary.c_str());
if (guiRendererBackendLibraryHandle == nullptr) {
Console::printLine("Application::run(): Could not open GUI renderer backend library");
glfwTerminate();
return false;
}
//
GUIRendererBackend* (*guiRendererBackendCreateInstance)() = (GUIRendererBackend*(*)())GetProcAddress(guiRendererBackendLibraryHandle, "createInstance");
//
if (guiRendererBackendCreateInstance == nullptr) {
Console::printLine("Application::run(): Could not find GUI renderer backend library createInstance() entry point");
glfwTerminate();
return false;
}
//
guiRendererBackend = unique_ptr<GUIRendererBackend>((GUIRendererBackend*)guiRendererBackendCreateInstance());
if (guiRendererBackend == nullptr) {
Console::printLine("Application::run(): Could not create renderer backend");
glfwTerminate();
return false;
}
#else
//
#if defined(__HAIKU__)
auto guiRendererBackendLibraryHandle = dlopen(("lib/" + guiRendererBackendLibrary).c_str(), RTLD_NOW);
#else
auto guiRendererBackendLibraryHandle = dlopen(guiRendererBackendLibrary.c_str(), RTLD_NOW);
#endif
if (guiRendererBackendLibraryHandle == nullptr) {
Console::printLine("Application::run(): Could not open GUI renderer backend library");
glfwTerminate();
return false;
}
//
GUIRendererBackend* (*guiRendererBackendCreateInstance)() = (GUIRendererBackend*(*)())dlsym(guiRendererBackendLibraryHandle, "createInstance");
//
if (guiRendererBackendCreateInstance == nullptr) {
Console::printLine("Application::run(): Could not find GUI renderer backend library createInstance() entry point");
glfwTerminate();
return false;
}
//
guiRendererBackend = unique_ptr<GUIRendererBackend>((GUIRendererBackend*)guiRendererBackendCreateInstance());
if (guiRendererBackend == nullptr) {
Console::printLine("Application::run(): Could not create GUI renderer backend");
glfwTerminate();
return false;
}
#endif
//
return true;
}

void Application::setIcon() {
auto logoFileName = StringTools::replace(StringTools::toLowerCase(executableFileName), ".exe", "") + "-icon.png";
if (FileSystem::getInstance()->exists("resources/platforms/icons/" + logoFileName) == false) logoFileName = "default-icon.png";
Expand Down
6 changes: 6 additions & 0 deletions ext/a-gui/src/agui/application/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,12 @@ class agui::application::Application: public GUIApplication
unordered_set<int> connectedGamepads;
array<array<int64_t, 16>, 16> joystickButtons;

/**
* Load GUI renderer backend plugin
* @param rendererType renderer type
*/
bool loadGUIRendererPlugin(const string& rendererType);

/**
* Set application icon
*/
Expand Down
4 changes: 2 additions & 2 deletions ext/a-gui/src/agui/gui/GUIVersion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ using std::string;
using agui::gui::GUIVersion;

string GUIVersion::getVersion() {
return "0.9.85";
return "0.9.86";
}

string GUIVersion::getCopyright() {
return "Developed 2012-2023 by Andreas Drewke, Dominik Hepp, Kolja Gumpert, drewke.net, mindty.com. Please see the license @ https://github.com/andreasdr/a-gui/blob/master/LICENSE";
return "Developed 2012-2025 by Andreas Drewke, Dominik Hepp, Kolja Gumpert, drewke.net, mindty.com. Please see the license @ https://github.com/andreasdr/a-gui/blob/master/LICENSE";
}
2 changes: 1 addition & 1 deletion ext/a-gui/src/agui/gui/renderer/GUIRendererBackendPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class agui::gui::renderer::GUIRendererBackendPlugin
* @returns renderer version
*/
inline static const string getRendererVersion() {
return "0.9.85";
return "0.9.86";
}

};

0 comments on commit 4d6fc12

Please sign in to comment.