feat(cpp/framework): extender AppConfig con about, panels, layouts_cb, init_gl_loader
This commit is contained in:
@@ -9,7 +9,9 @@
|
||||
#include "core/icon_font.h"
|
||||
#include "core/app_settings.h"
|
||||
#include "core/app_about.h"
|
||||
#include "core/app_menubar.h"
|
||||
#include "core/fps_overlay.h"
|
||||
#include "gfx/gl_loader.h"
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <cstdio>
|
||||
@@ -49,6 +51,17 @@ int run_app(AppConfig config, std::function<void()> render_fn) {
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwSwapInterval(config.vsync ? 1 : 0);
|
||||
|
||||
// Carga punteros a funciones GL >= 2.0 si la app lo pide. En Linux es
|
||||
// no-op; en Windows usa wglGetProcAddress (requiere ctx GL activo).
|
||||
if (config.init_gl_loader) {
|
||||
if (!fn::gfx::gl_loader_init()) {
|
||||
fprintf(stderr, "Failed to initialize GL function loader\n");
|
||||
glfwDestroyWindow(window);
|
||||
glfwTerminate();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Setup ImGui
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
@@ -63,6 +76,14 @@ int run_app(AppConfig config, std::function<void()> render_fn) {
|
||||
// fuentes. Si no existe el .ini, los defaults se aplican.
|
||||
fn_ui::settings_load();
|
||||
|
||||
// Registra info de la ventana About si la app la proveyo en AppConfig.
|
||||
if (config.about.name != nullptr) {
|
||||
fn_ui::about_window_set_info(
|
||||
config.about.name,
|
||||
config.about.version ? config.about.version : "",
|
||||
config.about.description ? config.about.description : "");
|
||||
}
|
||||
|
||||
// Texto vectorial (Karla / Roboto / DroidSans / Cousine, segun settings)
|
||||
// + iconos Tabler mergeados al mismo tamaño en el mismo ImFont.
|
||||
fn_ui::load_fonts_from_settings();
|
||||
@@ -127,6 +148,13 @@ int run_app(AppConfig config, std::function<void()> render_fn) {
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
// Menubar canonica (View / Layouts / Settings / About) si la app la
|
||||
// configuro en AppConfig. Se renderiza ANTES del render_fn para que
|
||||
// el render_fn pueda hacer DockSpaceOverViewport debajo.
|
||||
if (config.panels != nullptr || config.layouts_cb != nullptr) {
|
||||
fn_ui::app_menubar(config.panels, config.panel_count, config.layouts_cb);
|
||||
}
|
||||
|
||||
render_fn();
|
||||
|
||||
// Ventana de Settings (no-op si esta cerrada).
|
||||
|
||||
Reference in New Issue
Block a user