vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
ui_draw_data.h
1#pragma once
2
3#include <cstdint>
4#include <vector>
5
6#include <glm/glm.hpp>
7
8#include "ecs/entity.h"
9#include "ecs/component/ui/ui_element.h"
10#include "resource/asset/font_asset.h"
11#include "resource/asset/texture_asset.h"
12
13namespace Vkm::Engine {
14
22struct UIVertex {
23 glm::vec2 pos;
24 glm::vec2 uv;
25 glm::vec4 color;
27 glm::vec4 shape;
28 glm::vec4 border;
29 float image;
30};
31
33constexpr float UI_TEXT_MARK = -1.0f;
34
40struct UIDrawCmd {
41 uint32_t firstVertex = 0;
42 uint32_t vertexCount = 0;
43
48
49 FontHandle font = {};
50 TextureHandle image = {};
51};
52
58struct UIDrawData {
59 std::vector<UIVertex> vertices;
60 std::vector<UIDrawCmd> commands;
61
68
69 void clear() {
70 vertices.clear();
71 commands.clear();
72 pointerTarget = {};
73 }
74};
75
76} // namespace Vkm::Engine
Names one entity of one Scene, for as long as that slot holds it.
Definition entity.h:23
A contiguous run of UI vertices that share draw state.
Definition ui_draw_data.h:40
UIRect clip
Screen-pixel scissor rect, viewport-relative; the whole viewport when unclipped.
Definition ui_draw_data.h:47
The backend-agnostic UI overlay for one frame, published on FrameContext::ui.
Definition ui_draw_data.h:58
EntityId pointerTarget
The topmost element under the pointer that blocks it, or none.
Definition ui_draw_data.h:67
An axis-aligned screen-space rectangle (top-left origin, pixels).
Definition ui_element.h:12
One vertex of the UI's 2D triangle stream.
Definition ui_draw_data.h:22
glm::vec2 uv
Atlas coordinates for text; the quad's own 0..1 for a solid.
Definition ui_draw_data.h:24
glm::vec4 shape
Quad width and height (screen px), corner radius (UI_TEXT_MARK on a glyph), border width.
Definition ui_draw_data.h:27
float image
Solid only: 1 when tinted by its run's image, 0 when flat.
Definition ui_draw_data.h:29
glm::vec4 border
Solid only: the border's colour.
Definition ui_draw_data.h:28