$darkmode
Minimal immediate-mode User Interface (UI) library. More...
Go to the source code of this file.
Data Structures | |
| struct | GlyphInfo |
| Metrics and texture coordinates for a single font character. More... | |
| struct | UIVertex |
| Vertex data for the batch renderer. More... | |
| struct | UIContext |
| Persistent state for the UI system. More... | |
| struct | UILayout |
| Helper for automatic vertical stacking of UI elements. More... | |
Macros | |
| #define | ASCII_CHAR_COUNT 96 |
| Number of supported glyphs in the font atlas. More... | |
| #define | UI_MAX_BATCH_VERTICES 8192 |
| Maximum number of vertices per UI batch. More... | |
Functions | |
| int | ui_init (UIContext *ui_context, const char *font_path, float font_size) |
| Initializes the UI system. More... | |
| void | ui_destroy (UIContext *ui_context) |
| Releases UI resources. More... | |
| void | ui_begin (UIContext *ui_context, int screen_width, int screen_height) |
| Begins a new UI batch. More... | |
| void | ui_flush (UIContext *ui_context) |
| Flushes the current UI batch to the GPU. More... | |
| void | ui_end (UIContext *ui_context) |
| Ends the current UI batch and restores OpenGL state. More... | |
| void | ui_layout_init (UILayout *layout, UIContext *ui_ctx, float pos_x, float pos_y, float padding, int screen_width, int screen_height) |
| Initializes a layout helper for a frame. More... | |
| void | ui_layout_text (UILayout *layout, const char *text, const vec3 color) |
| Draws text and advances the layout cursor. More... | |
| void | ui_layout_separator (UILayout *layout, float space) |
| Adds vertical space to the layout. More... | |
| void | ui_draw_text (UIContext *ui_context, const char *text, float pos_x, float pos_y, const vec3 color, int screen_width, int screen_height) |
| Draws a single text string at a specific coordinate. More... | |
| float | ui_measure_text (const UIContext *ui_context, const char *text) |
| Measures the width of a text string in pixels. More... | |
| void | ui_draw_text_ex (UIContext *ui_context, const char *text, float pos_x, float pos_y, const vec3 color, float alpha, int screen_width, int screen_height) |
| Draws text with custom alpha transparency. More... | |
| void | ui_draw_text_scaled (UIContext *ui_context, const char *text, float pos_x, float pos_y, const vec3 color, float alpha, float scale, int screen_width, int screen_height) |
| Draws text with custom alpha transparency and a scale factor. More... | |
| void | ui_draw_rect (UIContext *ui_context, float rect_x, float rect_y, float width, float height, const vec3 color, int screen_width, int screen_height) |
| Draws a solid color rectangle. More... | |
| void | ui_draw_rect_ex (UIContext *ui_context, float rect_x, float rect_y, float width, float height, const vec3 color, float alpha, int screen_width, int screen_height) |
| Draws a solid color rectangle with custom alpha transparency. More... | |
| void | ui_draw_spinner (UIContext *ui_context, float center_x, float center_y, float size, float angle, const vec3 color, int screen_width, int screen_height) |
| Draws a rotating loading spinner. More... | |
| void | ui_draw_rounded_rect (UIContext *ui_context, float rect_x, float rect_y, float width, float height, float radius, const vec3 color, float alpha, int screen_width, int screen_height) |
| Draws a rounded rectangle with custom alpha. More... | |
| void | ui_draw_glow_rect (UIContext *ui_context, float rect_x, float rect_y, float width, float height, float radius, const vec3 color, float alpha, int screen_width, int screen_height) |
| Draws an SDF neon glow border around a rounded rectangle area. More... | |
| void | ui_draw_textured_quad (UIContext *ui_context, GLuint texture, float rect_x, float rect_y, float width, float height, const vec3 tint, float alpha, int screen_width, int screen_height) |
| Draws a textured quad tinted by a color (mode 3). More... | |
| void | ui_draw_bloom_quad (UIContext *ui_context, GLuint texture, float rect_x, float rect_y, float width, float height, const vec3 tint, float intensity, int screen_width, int screen_height) |
| Draws a textured quad with additive blending for bloom effects (mode 4). More... | |
Minimal immediate-mode User Interface (UI) library.
This module provides basic text rendering and shape drawing for overlays, debug information, and menus. It uses a custom font atlas.
| #define ASCII_CHAR_COUNT 96 |
Number of supported glyphs in the font atlas.
| #define UI_MAX_BATCH_VERTICES 8192 |
Maximum number of vertices per UI batch.
| void ui_begin | ( | UIContext * | ui_context, |
| int | screen_width, | ||
| int | screen_height | ||
| ) |
Begins a new UI batch.
| ui_context | Pointer to the UI context. |
| screen_width | Current window width. |
| screen_height | Current window height. |
| void ui_destroy | ( | UIContext * | ui_context | ) |
Releases UI resources.
| ui_context | Pointer to the struct. |
| void ui_draw_bloom_quad | ( | UIContext * | ui_context, |
| GLuint | texture, | ||
| float | rect_x, | ||
| float | rect_y, | ||
| float | width, | ||
| float | height, | ||
| const vec3 | tint, | ||
| float | intensity, | ||
| int | screen_width, | ||
| int | screen_height | ||
| ) |
Draws a textured quad with additive blending for bloom effects (mode 4).
Uses GL_ONE, GL_ONE blending so dark pixels are invisible and bright pixels add light on top of existing content. The texture should be a radial bloom (bright center, black surround). The tint parameter allows coloring the bloom.
| texture | OpenGL texture handle (bloom PNG, black background). |
| tint | Color of the bloom light (e.g. white or cyan). |
| intensity | Bloom brightness (0.0 = invisible, 1.0 = full). |
| void ui_draw_glow_rect | ( | UIContext * | ui_context, |
| float | rect_x, | ||
| float | rect_y, | ||
| float | width, | ||
| float | height, | ||
| float | radius, | ||
| const vec3 | color, | ||
| float | alpha, | ||
| int | screen_width, | ||
| int | screen_height | ||
| ) |
Draws an SDF neon glow border around a rounded rectangle area.
| void ui_draw_rect | ( | UIContext * | ui_context, |
| float | rect_x, | ||
| float | rect_y, | ||
| float | width, | ||
| float | height, | ||
| const vec3 | color, | ||
| int | screen_width, | ||
| int | screen_height | ||
| ) |
Draws a solid color rectangle.
| void ui_draw_rect_ex | ( | UIContext * | ui_context, |
| float | rect_x, | ||
| float | rect_y, | ||
| float | width, | ||
| float | height, | ||
| const vec3 | color, | ||
| float | alpha, | ||
| int | screen_width, | ||
| int | screen_height | ||
| ) |
Draws a solid color rectangle with custom alpha transparency.
| void ui_draw_rounded_rect | ( | UIContext * | ui_context, |
| float | rect_x, | ||
| float | rect_y, | ||
| float | width, | ||
| float | height, | ||
| float | radius, | ||
| const vec3 | color, | ||
| float | alpha, | ||
| int | screen_width, | ||
| int | screen_height | ||
| ) |
Draws a rounded rectangle with custom alpha.
| void ui_draw_spinner | ( | UIContext * | ui_context, |
| float | center_x, | ||
| float | center_y, | ||
| float | size, | ||
| float | angle, | ||
| const vec3 | color, | ||
| int | screen_width, | ||
| int | screen_height | ||
| ) |
Draws a rotating loading spinner.
| void ui_draw_text | ( | UIContext * | ui_context, |
| const char * | text, | ||
| float | pos_x, | ||
| float | pos_y, | ||
| const vec3 | color, | ||
| int | screen_width, | ||
| int | screen_height | ||
| ) |
Draws a single text string at a specific coordinate.
| void ui_draw_text_ex | ( | UIContext * | ui_context, |
| const char * | text, | ||
| float | pos_x, | ||
| float | pos_y, | ||
| const vec3 | color, | ||
| float | alpha, | ||
| int | screen_width, | ||
| int | screen_height | ||
| ) |
Draws text with custom alpha transparency.
| void ui_draw_text_scaled | ( | UIContext * | ui_context, |
| const char * | text, | ||
| float | pos_x, | ||
| float | pos_y, | ||
| const vec3 | color, | ||
| float | alpha, | ||
| float | scale, | ||
| int | screen_width, | ||
| int | screen_height | ||
| ) |
Draws text with custom alpha transparency and a scale factor.
| void ui_draw_textured_quad | ( | UIContext * | ui_context, |
| GLuint | texture, | ||
| float | rect_x, | ||
| float | rect_y, | ||
| float | width, | ||
| float | height, | ||
| const vec3 | tint, | ||
| float | alpha, | ||
| int | screen_width, | ||
| int | screen_height | ||
| ) |
Draws a textured quad tinted by a color (mode 3).
The PNG texture's RGB is multiplied by the tint color, and its alpha channel is scaled by the alpha parameter. Use for keycaps and panel frame.
| texture | OpenGL texture handle (RGBA PNG). |
| tint | Tint color multiplied against the texture RGB. |
| alpha | Overall opacity. |
| void ui_end | ( | UIContext * | ui_context | ) |
Ends the current UI batch and restores OpenGL state.
| ui_context | Pointer to the UI context. |
| void ui_flush | ( | UIContext * | ui_context | ) |
Flushes the current UI batch to the GPU.
| ui_context | Pointer to the UI context. |
| int ui_init | ( | UIContext * | ui_context, |
| const char * | font_path, | ||
| float | font_size | ||
| ) |
Initializes the UI system.
| ui_context | Pointer to the struct. |
| font_path | Path to the binary font metrics/texture. |
| font_size | Default scale. |
| void ui_layout_init | ( | UILayout * | layout, |
| UIContext * | ui_ctx, | ||
| float | pos_x, | ||
| float | pos_y, | ||
| float | padding, | ||
| int | screen_width, | ||
| int | screen_height | ||
| ) |
Initializes a layout helper for a frame.
| void ui_layout_separator | ( | UILayout * | layout, |
| float | space | ||
| ) |
Adds vertical space to the layout.
| void ui_layout_text | ( | UILayout * | layout, |
| const char * | text, | ||
| const vec3 | color | ||
| ) |
Draws text and advances the layout cursor.
| float ui_measure_text | ( | const UIContext * | ui_context, |
| const char * | text | ||
| ) |
Measures the width of a text string in pixels.
| ui_context | Pointer to the context. |
| text | The text to measure. |