Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
Loading...
Searching...
No Matches
app_ui.c File Reference
#include "app_ui.h"
#include "adaptive_sampler.h"
#include "app.h"
#include "app_binding.h"
#include "app_input_state.h"
#include "app_profiling.h"
#include "app_settings.h"
#include "app_ui_layout.h"
#include "bool_utils.h"
#include "effects/fx_bloom.h"
#include "env_manager.h"
#include "gamepad_input.h"
#include "glad/glad.h"
#include "ibl_coordinator.h"
#include "nbody.h"
#include "nbody_types.h"
#include "postprocess_internal.h"
#include "postprocess_readback.h"
#include "postprocess_setters.h"
#include "pp_params.h"
#include "scene.h"
#include "scene_simulation.h"
#include "texture.h"
#include "ui.h"
#include "utils.h"
#include <GLFW/glfw3.h>
#include <cglm/types.h>
#include <cglm/util.h>
#include <cglm/vec3.h>
#include <math.h>
#include <stdbool.h>
#include <string.h>
Include dependency graph for app_ui.c:

Functions

static void draw_exposure_overlay (const App *app, UILayout *layout)
 
static void draw_nbody_overlay (const App *app, UILayout *layout)
 
static void draw_loading_indicator (const App *app)
 
static void draw_help_overlay_keys (const App *app, float start_x, float start_y, float total_h, const KeyboardLayoutConfig *scaled_cfg)
 
static void draw_key_layer_base (UIContext *ui_ctx, const AppUIOverlay *overlay, const KeyboardLayoutConfig *scaled_cfg, const KeyPos *pos, float pos_x, float pos_y, const vec3 base_col, bool has_binding, bool is_pressed, bool is_hovered, float global_dim_mult, int screen_width, int screen_height)
 
static void draw_key_layer_effects (UIContext *ui_ctx, const AppUIOverlay *overlay, const KeyboardLayoutConfig *scaled_cfg, const KeyPos *pos, float pos_x, float pos_y, const vec3 base_col, bool is_pressed, bool is_hovered, int screen_width, int screen_height)
 
static void draw_key_layer_label (UIContext *ui_ctx, const KeyboardLayoutConfig *scaled_cfg, const KeyPos *pos, float pos_x, float pos_y, int screen_width, int screen_height)
 
static void draw_text_centered (UIContext *ui_ctx, const char *text, float pos_x, float pos_y, float scale, int screen_width, int screen_height)
 
static const AppBinding * get_active_binding (const AppBindingRegistry *registry, int key, int mods, int *out_effective_mods)
 
void app_ui_init (AppUIOverlay *overlay)
 
void app_ui_cleanup (AppUIOverlay *overlay)
 
void app_ui_update (AppUIOverlay *overlay, double delta_time)
 
void app_ui_handle_mouse (AppUIOverlay *overlay, double xpos, double ypos, int screen_width, int screen_height)
 
static void get_key_base_color (const AppBindingRegistry *registry, int key, vec3 out_col, bool *out_has_binding)
 
static bool is_modifier_relevant (int key, int pressed_key, int pressed_mods)
 
void app_draw_help_overlay (const App *app)
 Draws the help overlay with keyboard shortcuts.
 
static void draw_gamepad_control (const App *app, const GamepadControlPos *ctrl, float origin_x, float origin_y, float unit_size, float unit_pad, float ui_scale, int hovered_idx, int ctrl_idx, bool is_pressed, float dim_mult)
 
static bool gp_axis_active (const float *axes, int axis_id, const GamepadState *pad)
 Test whether a raw GLFW axis value exceeds its activation threshold.
 
static void gp_overlay_poll_active (const App *app, bool active[GAMEPAD_LAYOUT_COUNT])
 Poll live gamepad state and mark active controls.
 
static int gp_overlay_find_hovered (float origin_x, float origin_y, float unit_size, float unit_pad, float step)
 Find the hovered gamepad control via mouse hit-test.
 
void app_draw_gamepad_help_overlay (const App *app)
 Draws the gamepad help overlay with controller bindings.
 
static bool is_key_active_in_overlay (int key_to_test, int active_key, int active_mods)
 
static void draw_exposure_debug_text (const App *app)
 
static void draw_luminance_histogram_graph (const App *app, const int *buckets, int size, float min_lum, float max_lum)
 
static void draw_bloom_debug_status (const App *app, UILayout *layout)
 
void app_draw_debug_overlay (const App *app)
 Draws the debug overlay with performance metrics and settings.
 
static void draw_main_info_overlay (const App *app, UILayout *layout)
 
static void draw_cinematic_overlay (const App *app, UILayout *layout)
 
void app_render_ui (const App *app)
 Main UI rendering entry point.
 
int compute_luminance_histogram (const App *app, int *buckets, int size, float *min_lum, float *max_lum)
 Computes the luminance histogram from current frame data.
 

Variables

static const float GP_LAYOUT_COLS = 12.0F
 
static const float GP_LAYOUT_ROWS = 7.0F
 
static const float GP_GLOW_BASE_SIZE = 12.0F
 
static const float GP_GLOW_SIDES = 2.0F
 
static const float GP_SMALL_LABEL_SCALE = 0.7F
 
static const float GP_TRIGGER_NORM = 0.5F
 

Function Documentation

◆ app_draw_debug_overlay()

void app_draw_debug_overlay ( const App *  app)

Draws the debug overlay with performance metrics and settings.

Parameters
appPointer to the application state.
Here is the call graph for this function:

◆ app_draw_gamepad_help_overlay()

void app_draw_gamepad_help_overlay ( const App *  app)

Draws the gamepad help overlay with controller bindings.

Parameters
appPointer to the application state.
Here is the call graph for this function:

◆ app_draw_help_overlay()

void app_draw_help_overlay ( const App *  app)

Draws the help overlay with keyboard shortcuts.

Parameters
appPointer to the application state.
Here is the call graph for this function:

◆ app_render_ui()

void app_render_ui ( const App *  app)

Main UI rendering entry point.

Orchestrates all UI elements (overlays, histograms, loading spinners).

Parameters
appPointer to the application state.
Here is the call graph for this function:

◆ app_ui_cleanup()

void app_ui_cleanup ( AppUIOverlay *  overlay)
Here is the call graph for this function:

◆ app_ui_handle_mouse()

void app_ui_handle_mouse ( AppUIOverlay *  overlay,
double  xpos,
double  ypos,
int  screen_width,
int  screen_height 
)

◆ app_ui_init()

void app_ui_init ( AppUIOverlay *  overlay)
Here is the call graph for this function:

◆ app_ui_update()

void app_ui_update ( AppUIOverlay *  overlay,
double  delta_time 
)

◆ compute_luminance_histogram()

int compute_luminance_histogram ( const App *  app,
int *  buckets,
int  size,
float *  min_lum,
float *  max_lum 
)

Computes the luminance histogram from current frame data.

Scans the luminance buffer to populate buckets for visualization.

Parameters
appPointer to the application state.
bucketsArray to fill with histogram data.
sizeNumber of buckets in the array.
[out]min_lumMinimum luminance found in the data.
[out]max_lumMaximum luminance found in the data.
Returns
Number of samples processed or error code.
Here is the call graph for this function:

◆ draw_bloom_debug_status()

static void draw_bloom_debug_status ( const App *  app,
UILayout *  layout 
)
static
Here is the call graph for this function:

◆ draw_cinematic_overlay()

static void draw_cinematic_overlay ( const App *  app,
UILayout *  layout 
)
static
Here is the call graph for this function:

◆ draw_exposure_debug_text()

static void draw_exposure_debug_text ( const App *  app)
static
Here is the call graph for this function:

◆ draw_exposure_overlay()

static void draw_exposure_overlay ( const App *  app,
UILayout *  layout 
)
static
Here is the call graph for this function:

◆ draw_gamepad_control()

static void draw_gamepad_control ( const App *  app,
const GamepadControlPos *  ctrl,
float  origin_x,
float  origin_y,
float  unit_size,
float  unit_pad,
float  ui_scale,
int  hovered_idx,
int  ctrl_idx,
bool  is_pressed,
float  dim_mult 
)
static
Here is the call graph for this function:

◆ draw_help_overlay_keys()

static void draw_help_overlay_keys ( const App *  app,
float  start_x,
float  start_y,
float  total_h,
const KeyboardLayoutConfig *  scaled_cfg 
)
static
Here is the call graph for this function:

◆ draw_key_layer_base()

static void draw_key_layer_base ( UIContext *  ui_ctx,
const AppUIOverlay *  overlay,
const KeyboardLayoutConfig *  scaled_cfg,
const KeyPos *  pos,
float  pos_x,
float  pos_y,
const vec3  base_col,
bool  has_binding,
bool  is_pressed,
bool  is_hovered,
float  global_dim_mult,
int  screen_width,
int  screen_height 
)
static
Here is the call graph for this function:

◆ draw_key_layer_effects()

static void draw_key_layer_effects ( UIContext *  ui_ctx,
const AppUIOverlay *  overlay,
const KeyboardLayoutConfig *  scaled_cfg,
const KeyPos *  pos,
float  pos_x,
float  pos_y,
const vec3  base_col,
bool  is_pressed,
bool  is_hovered,
int  screen_width,
int  screen_height 
)
static
Here is the call graph for this function:

◆ draw_key_layer_label()

static void draw_key_layer_label ( UIContext *  ui_ctx,
const KeyboardLayoutConfig *  scaled_cfg,
const KeyPos *  pos,
float  pos_x,
float  pos_y,
int  screen_width,
int  screen_height 
)
static
Here is the call graph for this function:

◆ draw_loading_indicator()

static void draw_loading_indicator ( const App *  app)
static
Here is the call graph for this function:

◆ draw_luminance_histogram_graph()

static void draw_luminance_histogram_graph ( const App *  app,
const int *  buckets,
int  size,
float  min_lum,
float  max_lum 
)
static
Here is the call graph for this function:

◆ draw_main_info_overlay()

static void draw_main_info_overlay ( const App *  app,
UILayout *  layout 
)
static
Here is the call graph for this function:

◆ draw_nbody_overlay()

static void draw_nbody_overlay ( const App *  app,
UILayout *  layout 
)
static
Here is the call graph for this function:

◆ draw_text_centered()

static void draw_text_centered ( UIContext *  ui_ctx,
const char *  text,
float  pos_x,
float  pos_y,
float  scale,
int  screen_width,
int  screen_height 
)
static
Here is the call graph for this function:

◆ get_active_binding()

static const AppBinding * get_active_binding ( const AppBindingRegistry *  registry,
int  key,
int  mods,
int *  out_effective_mods 
)
static
Here is the call graph for this function:

◆ get_key_base_color()

static void get_key_base_color ( const AppBindingRegistry *  registry,
int  key,
vec3  out_col,
bool *  out_has_binding 
)
static
Here is the call graph for this function:

◆ gp_axis_active()

static bool gp_axis_active ( const float *  axes,
int  axis_id,
const GamepadState *  pad 
)
static

Test whether a raw GLFW axis value exceeds its activation threshold.

Triggers (axes 4-5) rest at -1.0 and range to +1.0, so they are normalised to [0,1] before comparing against the trigger threshold. Stick axes (0-3) are centred at 0.0 and compared via fabsf against the deadzone.

◆ gp_overlay_find_hovered()

static int gp_overlay_find_hovered ( float  origin_x,
float  origin_y,
float  unit_size,
float  unit_pad,
float  step 
)
static

Find the hovered gamepad control via mouse hit-test.

◆ gp_overlay_poll_active()

static void gp_overlay_poll_active ( const App *  app,
bool  active[GAMEPAD_LAYOUT_COUNT] 
)
static

Poll live gamepad state and mark active controls.

Here is the call graph for this function:

◆ is_key_active_in_overlay()

static bool is_key_active_in_overlay ( int  key_to_test,
int  active_key,
int  active_mods 
)
static
Here is the call graph for this function:

◆ is_modifier_relevant()

static bool is_modifier_relevant ( int  key,
int  pressed_key,
int  pressed_mods 
)
static

Variable Documentation

◆ GP_GLOW_BASE_SIZE

const float GP_GLOW_BASE_SIZE = 12.0F
static

◆ GP_GLOW_SIDES

const float GP_GLOW_SIDES = 2.0F
static

◆ GP_LAYOUT_COLS

const float GP_LAYOUT_COLS = 12.0F
static

Gamepad layout spans 12 units wide × 7 units tall.

◆ GP_LAYOUT_ROWS

const float GP_LAYOUT_ROWS = 7.0F
static

◆ GP_SMALL_LABEL_SCALE

const float GP_SMALL_LABEL_SCALE = 0.7F
static

◆ GP_TRIGGER_NORM

const float GP_TRIGGER_NORM = 0.5F
static