App

Overview

class App

Main class for the omdi application.

The omdi::App class owns the main GLFW window and integrates the ImGui context. It manages the main render loop and provides a simple interface to:

  • initialize the application with an omdi::State instance,

  • optionally register managers and UI components,

  • run a render loop with a user-provided rendering callback,

  • access the underlying GLFW window, ImGui IO, and GLSL version string.

Usage example

Basic setup and render loop:

auto state = omdi::State();

// Construct the application window
auto app = omdi::App(&state, "omdi Example", /*swapInterval=*/1, /*isResizable=*/true);

// Initialize managers if needed (empty by default)
app.Init(&state);

// Main loop
app.Render(&state, [&]() {
  // Simple render callback
});

Public interface

Constructor and destructor

App::App(omdi::state::State *state, const std::string &name = "omdi App", int swapInterval = 1, bool isResizable = true)

Construct the main application object and create the underlying window.

Parameters:
  • state – Pointer to the global state manager.

  • name – Window title (defaults to "omdi App").

  • swapInterval – Swap interval for VSync (typically 0 or 1).

  • isResizable – Whether the window is resizable by the user.

The constructor is responsible for setting up GLFW, the window, ImGui context, and any required graphics state.

App::~App()

Destroy the application object and release associated resources.

Cleans up the GLFW window and ImGui context, and performs any necessary shutdown for the underlying graphics APIs.

Main loop helpers

void App::processInput()

Process user input events.

Typically polls GLFW (keyboard, mouse, window events) and updates internal state / ImGui IO accordingly. Should be called once per frame.

bool App::startFrame()

Begin a new frame.

Prepares ImGui and any rendering state for a new frame.

Returns:

true if the frame should proceed, false if the application is shutting down or the window should close.

void App::renderFrame()

Render the current frame.

Issues drawing commands for ImGui and any additional application rendering. This is usually called between omdi::App::startFrame() and omdi::App::endFrame().

void App::endFrame(int &width, int &height, ImVec4 &clear_color)

Finalize the current frame and present it to the screen.

Parameters:
  • width – Output parameter receiving the current framebuffer width.

  • height – Output parameter receiving the current framebuffer height.

  • clear_color – Clear color used for the frame; may be read or updated.

This function typically handles buffer swapping and any per-frame housekeeping related to the window size and clear color.

Initialization and render loop

void App::Init(omdi::state::State *state, const std::map<std::string, void*> &managers = {})

Initialize the omdi application with the given state and optional managers.

Parameters:
  • state – Pointer to the global state manager.

  • managers – Map of optional omdi managers, keyed by string identifiers. The exact types pointed to by the values are application-specific.

This function can be used to register subsystems (e.g. logging, resource managers, backends) that the application and UI components can access through the shared omdi::state::State or other mechanisms.

void App::Render(omdi::state::State *state, const std::function<void()> &custom_render = nullptr, const std::map<std::string, void*> &components = {}, const std::map<std::string, void*> &managers = {})

Run the main render loop using the provided state, optional custom render callback, UI components, and managers.

Parameters:
  • state – Pointer to the global state manager.

  • custom_render – User-provided callback invoked each frame to perform custom rendering (e.g. ImGui windows, scene drawing). If nullptr, only the built-in omdi components/managers are rendered.

  • components – Map of optional omdi UI components, keyed by string identifiers.

  • managers – Map of optional omdi managers, keyed by string identifiers.

Internally, omdi::App::Render() typically loops until omdi::App::windowShouldClose() returns non-zero, calling omdi::App::processInput(), omdi::App::startFrame(), the custom_render callback (if provided), omdi::App::renderFrame(), and omdi::App::endFrame() each frame.

Window and context accessors

int App::windowShouldClose() const

Check whether the window should close.

Returns:

Non-zero if the user requested to close the window (e.g. via the window close button), zero otherwise.

This is a thin wrapper around glfwWindowShouldClose().

GLFWwindow *App::window() const

Get the underlying GLFW window handle.

Returns:

Pointer to the GLFWwindow owned by the application.

This may be useful for low-level integration with other libraries that operate directly on the GLFW window.

ImGuiIO *App::io()

Get the ImGui IO object associated with this application.

Returns:

Pointer to the ImGuiIO instance used by ImGui.

Use this to access input state, configuration flags, or other ImGui IO properties.

const char *App::glsl_version() const

Get the GLSL version string used by the application.

Returns:

Null-terminated string describing the GLSL version (e.g. "#version 130"), suitable for use in shader source.

Notes