Skip to content

Commit 4d6fc12

Browse files
committed
ext/agui: synced agui
1 parent 338fd14 commit 4d6fc12

File tree

4 files changed

+95
-3
lines changed

4 files changed

+95
-3
lines changed

ext/a-gui/src/agui/application/Application.cpp

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <agui/audio/Audio.h>
4141
#include <agui/gui/textures/GUITexture.h>
4242
#include <agui/gui/fileio/TextureReader.h>
43+
#include <agui/gui/renderer/ApplicationGL3Renderer.h>
4344
#include <agui/gui/renderer/GUIRendererBackend.h>
4445
#include <agui/gui/GUIEventHandler.h>
4546
#include <agui/os/filesystem/FileSystem.h>
@@ -66,6 +67,7 @@ using agui::application::Application;
6667
using agui::audio::Audio;
6768
using agui::gui::textures::GUITexture;
6869
using agui::gui::fileio::TextureReader;
70+
using agui::gui::renderer::ApplicationGL3Renderer;
6971
using agui::gui::renderer::GUIRendererBackend;
7072
using agui::gui::GUIEventHandler;
7173
using agui::os::filesystem::FileSystem;
@@ -564,6 +566,22 @@ int Application::run(int argc, char** argv, const string& title, GUIEventHandler
564566
}
565567
}
566568

569+
// renderer backend library
570+
string rendererBackendType = "opengl3core";
571+
for (auto i = 1; i < argc; i++) {
572+
auto argValue = string(argv[i]);
573+
if (argValue == "--debug") debuggingEnabled = true; else
574+
if (argValue == "--gles2") rendererBackendType = "opengles2"; else
575+
if (argValue == "--gl2") rendererBackendType = "opengl2"; else
576+
if (argValue == "--gl3core") rendererBackendType = "opengl3core"; else
577+
if (argValue == "--vulkan") rendererBackendType = "vulkan";
578+
}
579+
580+
// load engine renderer backend plugin
581+
if (loadGUIRendererPlugin(rendererBackendType) == false) {
582+
return EXITCODE_FAILURE;
583+
}
584+
567585
// window hints
568586
if ((windowHints & WINDOW_HINT_NOTRESIZEABLE) == WINDOW_HINT_NOTRESIZEABLE) glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
569587
if ((windowHints & WINDOW_HINT_NOTDECORATED) == WINDOW_HINT_NOTDECORATED) glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);
@@ -663,6 +681,74 @@ int Application::run(int argc, char** argv, const string& title, GUIEventHandler
663681
return localExitCode;
664682
}
665683

684+
bool Application::loadGUIRendererPlugin(const string& rendererType) {
685+
string guiRendererBackendLibrary = "libgui" + rendererType + "renderer";
686+
#if defined(_WIN32)
687+
guiRendererBackendLibrary = guiRendererBackendLibrary + ".dll";
688+
#elif defined(__APPLE__)
689+
guiRendererBackendLibrary = guiRendererBackendLibrary + ".dylib";
690+
#else
691+
guiRendererBackendLibrary = guiRendererBackendLibrary + ".so";
692+
#endif
693+
694+
// renderer
695+
Console::printLine("Application::run(): Opening GUI renderer backend library: " + guiRendererBackendLibrary);
696+
697+
#if defined(_MSC_VER)
698+
//
699+
auto guiRendererBackendLibraryHandle = LoadLibrary(guiRendererBackendLibrary.c_str());
700+
if (guiRendererBackendLibraryHandle == nullptr) {
701+
Console::printLine("Application::run(): Could not open GUI renderer backend library");
702+
glfwTerminate();
703+
return false;
704+
}
705+
//
706+
GUIRendererBackend* (*guiRendererBackendCreateInstance)() = (GUIRendererBackend*(*)())GetProcAddress(guiRendererBackendLibraryHandle, "createInstance");
707+
//
708+
if (guiRendererBackendCreateInstance == nullptr) {
709+
Console::printLine("Application::run(): Could not find GUI renderer backend library createInstance() entry point");
710+
glfwTerminate();
711+
return false;
712+
}
713+
//
714+
guiRendererBackend = unique_ptr<GUIRendererBackend>((GUIRendererBackend*)guiRendererBackendCreateInstance());
715+
if (guiRendererBackend == nullptr) {
716+
Console::printLine("Application::run(): Could not create renderer backend");
717+
glfwTerminate();
718+
return false;
719+
}
720+
#else
721+
//
722+
#if defined(__HAIKU__)
723+
auto guiRendererBackendLibraryHandle = dlopen(("lib/" + guiRendererBackendLibrary).c_str(), RTLD_NOW);
724+
#else
725+
auto guiRendererBackendLibraryHandle = dlopen(guiRendererBackendLibrary.c_str(), RTLD_NOW);
726+
#endif
727+
if (guiRendererBackendLibraryHandle == nullptr) {
728+
Console::printLine("Application::run(): Could not open GUI renderer backend library");
729+
glfwTerminate();
730+
return false;
731+
}
732+
//
733+
GUIRendererBackend* (*guiRendererBackendCreateInstance)() = (GUIRendererBackend*(*)())dlsym(guiRendererBackendLibraryHandle, "createInstance");
734+
//
735+
if (guiRendererBackendCreateInstance == nullptr) {
736+
Console::printLine("Application::run(): Could not find GUI renderer backend library createInstance() entry point");
737+
glfwTerminate();
738+
return false;
739+
}
740+
//
741+
guiRendererBackend = unique_ptr<GUIRendererBackend>((GUIRendererBackend*)guiRendererBackendCreateInstance());
742+
if (guiRendererBackend == nullptr) {
743+
Console::printLine("Application::run(): Could not create GUI renderer backend");
744+
glfwTerminate();
745+
return false;
746+
}
747+
#endif
748+
//
749+
return true;
750+
}
751+
666752
void Application::setIcon() {
667753
auto logoFileName = StringTools::replace(StringTools::toLowerCase(executableFileName), ".exe", "") + "-icon.png";
668754
if (FileSystem::getInstance()->exists("resources/platforms/icons/" + logoFileName) == false) logoFileName = "default-icon.png";

ext/a-gui/src/agui/application/Application.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,12 @@ class agui::application::Application: public GUIApplication
379379
unordered_set<int> connectedGamepads;
380380
array<array<int64_t, 16>, 16> joystickButtons;
381381

382+
/**
383+
* Load GUI renderer backend plugin
384+
* @param rendererType renderer type
385+
*/
386+
bool loadGUIRendererPlugin(const string& rendererType);
387+
382388
/**
383389
* Set application icon
384390
*/

ext/a-gui/src/agui/gui/GUIVersion.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ using std::string;
99
using agui::gui::GUIVersion;
1010

1111
string GUIVersion::getVersion() {
12-
return "0.9.85";
12+
return "0.9.86";
1313
}
1414

1515
string GUIVersion::getCopyright() {
16-
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";
16+
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";
1717
}

ext/a-gui/src/agui/gui/renderer/GUIRendererBackendPlugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class agui::gui::renderer::GUIRendererBackendPlugin
1818
* @returns renderer version
1919
*/
2020
inline static const string getRendererVersion() {
21-
return "0.9.85";
21+
return "0.9.86";
2222
}
2323

2424
};

0 commit comments

Comments
 (0)