basic flow layout

This commit is contained in:
Dynamitos
2025-01-12 11:26:52 +01:00
parent e487867f96
commit 2915db8898
18 changed files with 415 additions and 172 deletions
+7 -6
View File
@@ -4,6 +4,7 @@ struct GlyphInstanceData
{ {
float x; float x;
float y; float y;
float z;
float width; float width;
float height; float height;
uint glyphIndex; uint glyphIndex;
@@ -40,15 +41,15 @@ VertexOutput vertexMain(VertexInput input)
float h = pText.glyphs[input.instanceId].height; float h = pText.glyphs[input.instanceId].height;
const float4 coordinates[4] = { const float4 coordinates[4] = {
float4(xpos, ypos, 0, 1), float4(xpos, ypos, 0, 0),
float4(xpos, ypos + h, 0, 0), float4(xpos, ypos + h, 0, 1),
float4(xpos + w, ypos, 1, 1), float4(xpos + w, ypos, 1, 0),
float4(xpos + w, ypos + h, 1, 0), float4(xpos + w, ypos + h, 1, 1),
}; };
float4 vertex = coordinates[input.vertexId]; float4 vertex = coordinates[input.vertexId];
VertexOutput output; VertexOutput output;
output.texCoords = vertex.zw; output.texCoords = vertex.zw;
output.position = mul(pViewParams.projectionMatrix, float4(vertex.xy, 0, 1)); output.position = mul(pViewParams.projectionMatrix, float4(vertex.xy, pText.glyphs[input.instanceId].z-1, 1));
output.glyphIndex = pText.glyphs[input.instanceId].glyphIndex; output.glyphIndex = pText.glyphs[input.instanceId].glyphIndex;
return output; return output;
} }
@@ -60,5 +61,5 @@ float4 fragmentMain(
uint glyphIndex : GLYPHINDEX uint glyphIndex : GLYPHINDEX
) : SV_Target ) : SV_Target
{ {
return float4(1, 0, 0, pText.glyphTextures[glyphIndex].Sample(pText.glyphSampler, texCoords)); return float4(0,0,0,pText.glyphTextures[glyphIndex].Sample(pText.glyphSampler, texCoords));
} }
+26 -29
View File
@@ -2,44 +2,41 @@ import Common;
struct RenderElementStyle struct RenderElementStyle
{ {
float3 position; float x;
uint backgroundImageIndex; float y;
float3 backgroundColor; float w;
float h;
float3 color;
float opacity; float opacity;
//float4 borderBottomColor; float z;
//float4 borderLeftColor; uint textureIndex;
//float4 borderRightColor; uint pad0;
//float4 borderTopColor; uint pad1;
//float borderBottomLeftRadius;
//float borderBottomRightRadius;
//float borderTopLeftRadius;
//float borderTopRightRadius;
float2 dimensions;
}; };
struct UIParameter struct UIParameter
{ {
SamplerState backgroundSampler; StructuredBuffer<RenderElementStyle> elements;
uint numBackgroundTextures; SamplerState sampler;
Texture2D<float4> backgroundTextures[]; Texture2D textures[];
} };
ParameterBlock<UIParameter> pParams; ParameterBlock<UIParameter> pParams;
struct VertexOutput struct VertexOutput
{ {
float4 position : SV_Position; float4 position : SV_Position;
float2 texCoords : TEXCOORD; float2 texCoords : TEXCOORD;
RenderElementStyle style : RENDER_STYLE; RenderElementStyle style : STYLE;
}; };
[shader("vertex")] [shader("vertex")]
VertexOutput vertexMain(uint vertexId : SV_VertexID, RenderElementStyle style) VertexOutput vertexMain(uint vertexId : SV_VertexID, uint instanceId: SV_InstanceID)
{ {
float xMin = style.position.x; RenderElementStyle style = pParams.elements[instanceId];
float xMax = xMin + style.dimensions.x; float xMin = style.x;
float yMin = style.position.y; float xMax = xMin + style.w;
float yMax = yMin + style.dimensions.y; float yMin = style.y;
float yMax = yMin + style.h;
float4 coordinates[] = { float4 coordinates[] = {
float4(xMin, yMin, 0, 0), float4(xMin, yMin, 0, 0),
float4(xMin, yMax, 0, 1), float4(xMin, yMax, 0, 1),
@@ -47,7 +44,7 @@ VertexOutput vertexMain(uint vertexId : SV_VertexID, RenderElementStyle style)
float4(xMax, yMax, 1, 1) float4(xMax, yMax, 1, 1)
}; };
VertexOutput output; VertexOutput output;
output.position = mul(pViewParams.projectionMatrix, float4(coordinates[vertexId].xy, style.position.z, 1)); output.position = mul(pViewParams.projectionMatrix, float4(coordinates[vertexId].xy, style.z-1, 1));
output.texCoords = coordinates[vertexId].zw; output.texCoords = coordinates[vertexId].zw;
output.style = style; output.style = style;
return output; return output;
@@ -55,12 +52,12 @@ VertexOutput vertexMain(uint vertexId : SV_VertexID, RenderElementStyle style)
[shader("fragment")] [shader("fragment")]
float4 fragmentMain( float4 fragmentMain(
float4 position : SV_Position,
float2 texCoords : TEXCOORD, float2 texCoords : TEXCOORD,
RenderElementStyle style : RENDER_STYLE RenderElementStyle style : STYLE
) : SV_Target ) : SV_Target
{ {
float4 bgTextureColor = float4(1, 1, 1, 1); if(style.textureIndex == -1) {
uint imageIndex = style.backgroundImageIndex; return float4(style.color, style.opacity);
return float4(0, 1, 0, 1); }
return float4(pParams.textures[style.textureIndex].Sample(pParams.sampler, texCoords.xy).xyz, style.opacity);
} }
+14 -2
View File
@@ -39,7 +39,7 @@ void FontLoader::import(FontImportArgs args, PFontAsset asset) {
assert(!error); assert(!error);
FT_Set_Pixel_Sizes(face, 0, 48); FT_Set_Pixel_Sizes(face, 0, 48);
for (uint32 c = 0; c < 256; ++c) { for (uint32 c = 0; c < 256; ++c) {
if (FT_Load_Char(face, c, FT_LOAD_RENDER)) { if (FT_Load_Char(face, c, FT_LOAD_RENDER | FT_LOAD_COLOR)) {
std::cout << "error loading " << (char)c << std::endl; std::cout << "error loading " << (char)c << std::endl;
continue; continue;
} }
@@ -51,10 +51,22 @@ void FontLoader::import(FontImportArgs args, PFontAsset asset) {
if (glyph.textureData.size() == 0) { if (glyph.textureData.size() == 0) {
glyph.size.x = 1; glyph.size.x = 1;
glyph.size.y = 1; glyph.size.y = 1;
glyph.textureData.add(0); // load a single transparent pixel, so that we dont have to handle empty textures later glyph.textureData.add(0);
// load a single transparent pixel, so that we dont have to handle empty textures later
} else { } else {
std::memcpy(glyph.textureData.data(), face->glyph->bitmap.buffer, glyph.textureData.size()); std::memcpy(glyph.textureData.data(), face->glyph->bitmap.buffer, glyph.textureData.size());
} }
glyph.texture = graphics->createTexture2D(TextureCreateInfo{
.sourceData =
{
.size = glyph.textureData.size(),
.data = glyph.textureData.data(),
},
.format = Gfx::SE_FORMAT_R8_UNORM,
.width = glyph.size.x,
.height = glyph.size.y,
.name = "FontGlyph",
});
} }
FT_Done_Face(face); FT_Done_Face(face);
FT_Done_FreeType(ft); FT_Done_FreeType(ft);
+4 -1
View File
@@ -3,13 +3,16 @@
#include "Asset/AssetRegistry.h" #include "Asset/AssetRegistry.h"
#include "Asset/FontLoader.h" #include "Asset/FontLoader.h"
#include "Graphics/Graphics.h" #include "Graphics/Graphics.h"
#include "UI/Element/Div.h"
#include "UI/Element/Text.h" #include "UI/Element/Text.h"
using namespace Seele; using namespace Seele;
using namespace Seele::Editor; using namespace Seele::Editor;
InspectorView::InspectorView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo) InspectorView::InspectorView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo)
: View(graphics, window, createInfo, "InspectorView"), uiSystem(new UI::System(new UI::Text("Test"))) { : View(graphics, window, createInfo, "InspectorView"),
uiSystem(new UI::System(new UI::Div(
UI::Attributes{}, {new UI::Div<W_Full, BG_Red>({}, {new UI::Text<Font_Arial>("OtherTest")}), new UI::Text<Font_Arial>("Test")}))) {
renderGraph.addPass(new UIPass(graphics, uiSystem)); renderGraph.addPass(new UIPass(graphics, uiSystem));
renderGraph.setViewport(viewport); renderGraph.setViewport(viewport);
renderGraph.createRenderPass(); renderGraph.createRenderPass();
+8 -16
View File
@@ -6,7 +6,6 @@
#include <iterator> #include <iterator>
#include <memory_resource> #include <memory_resource>
#ifndef DEFAULT_ALLOC_SIZE #ifndef DEFAULT_ALLOC_SIZE
#define DEFAULT_ALLOC_SIZE 16 #define DEFAULT_ALLOC_SIZE 16
#endif #endif
@@ -111,11 +110,12 @@ template <typename T, typename Allocator = std::pmr::polymorphic_allocator<T>> s
} }
} }
} }
template <typename = std::enable_if_t<std::is_copy_constructible_v<T>>>
constexpr Array(std::initializer_list<T> init, const allocator_type& alloc = allocator_type()) constexpr Array(std::initializer_list<T> init, const allocator_type& alloc = allocator_type())
: arraySize(init.size()), allocated(init.size()), allocator(alloc) { : arraySize(init.size()), allocated(init.size()), allocator(alloc) {
_data = allocateArray(init.size()); _data = allocateArray(init.size());
assert(_data != nullptr); assert(_data != nullptr);
std::uninitialized_move(init.begin(), init.end(), begin()); std::uninitialized_copy(init.begin(), init.end(), begin());
} }
constexpr Array(const Array& other) constexpr Array(const Array& other)
@@ -184,8 +184,7 @@ template <typename T, typename Allocator = std::pmr::polymorphic_allocator<T>> s
} }
constexpr ~Array() { clear(); } constexpr ~Array() { clear(); }
[[nodiscard]] [[nodiscard]] constexpr iterator find(const value_type& item) noexcept {
constexpr iterator find(const value_type& item) noexcept {
for (size_type i = 0; i < arraySize; ++i) { for (size_type i = 0; i < arraySize; ++i) {
if (_data[i] == item) { if (_data[i] == item) {
return iterator(&_data[i]); return iterator(&_data[i]);
@@ -193,8 +192,7 @@ template <typename T, typename Allocator = std::pmr::polymorphic_allocator<T>> s
} }
return end(); return end();
} }
[[nodiscard]] [[nodiscard]] constexpr iterator find(value_type&& item) noexcept {
constexpr iterator find(value_type&& item) noexcept {
for (size_type i = 0; i < arraySize; ++i) { for (size_type i = 0; i < arraySize; ++i) {
if (_data[i] == item) { if (_data[i] == item) {
return iterator(&_data[i]); return iterator(&_data[i]);
@@ -202,8 +200,7 @@ template <typename T, typename Allocator = std::pmr::polymorphic_allocator<T>> s
} }
return end(); return end();
} }
[[nodiscard]] [[nodiscard]] constexpr const_iterator find(const value_type& item) const noexcept {
constexpr const_iterator find(const value_type& item) const noexcept {
for (size_type i = 0; i < arraySize; ++i) { for (size_type i = 0; i < arraySize; ++i) {
if (_data[i] == item) { if (_data[i] == item) {
return const_iterator(&_data[i]); return const_iterator(&_data[i]);
@@ -211,8 +208,7 @@ template <typename T, typename Allocator = std::pmr::polymorphic_allocator<T>> s
} }
return end(); return end();
} }
[[nodiscard]] [[nodiscard]] constexpr const_iterator find(value_type&& item) const noexcept {
constexpr const_iterator find(value_type&& item) const noexcept {
for (size_type i = 0; i < arraySize; ++i) { for (size_type i = 0; i < arraySize; ++i) {
if (_data[i] == item) { if (_data[i] == item) {
return const_iterator(&_data[i]); return const_iterator(&_data[i]);
@@ -321,10 +317,7 @@ template <typename T, typename Allocator = std::pmr::polymorphic_allocator<T>> s
constexpr size_type indexOf(T& t) { return indexOf(find(t)); } constexpr size_type indexOf(T& t) { return indexOf(find(t)); }
constexpr size_type indexOf(const T& t) const { return indexOf(find(t)); } constexpr size_type indexOf(const T& t) const { return indexOf(find(t)); }
constexpr size_type size() const noexcept { return arraySize; } constexpr size_type size() const noexcept { return arraySize; }
[[nodiscard]] [[nodiscard]] constexpr bool empty() const noexcept { return arraySize == 0; }
constexpr bool empty() const noexcept {
return arraySize == 0;
}
constexpr void reserve(size_type new_cap) { constexpr void reserve(size_type new_cap) {
if (new_cap > allocated) { if (new_cap > allocated) {
T* temp = allocateArray(new_cap); T* temp = allocateArray(new_cap);
@@ -374,8 +367,7 @@ template <typename T, typename Allocator = std::pmr::polymorphic_allocator<T>> s
return geometric; // geometric growth is sufficient return geometric; // geometric growth is sufficient
} }
[[nodiscard]] [[nodiscard]] T* allocateArray(size_type size) {
T* allocateArray(size_type size) {
T* result = allocator.allocate(size); T* result = allocator.allocate(size);
assert(result != nullptr); assert(result != nullptr);
return result; return result;
@@ -63,13 +63,13 @@ RayTracingPass::RayTracingPass(Gfx::PGraphics graphics, PScene scene) : RenderPa
skyBoxSampler = graphics->createSampler({}); skyBoxSampler = graphics->createSampler({});
} }
static uint32 i = 0; static uint32 pass = 0;
static Component::Camera lastCam; static Component::Camera lastCam;
void RayTracingPass::beginFrame(const Component::Camera& cam) { void RayTracingPass::beginFrame(const Component::Camera& cam) {
RenderPass::beginFrame(cam); RenderPass::beginFrame(cam);
if (lastCam.getCameraPosition() != cam.getCameraPosition() || lastCam.getCameraForward() != cam.getCameraForward()) { if (lastCam.getCameraPosition() != cam.getCameraPosition() || lastCam.getCameraForward() != cam.getCameraForward()) {
lastCam = cam; lastCam = cam;
i = 0; pass = 0;
} }
} }
@@ -156,7 +156,7 @@ void RayTracingPass::render() {
}; };
// for (uint32 i = 0; i < sampleParams.samplesPerPixel; ++i) // for (uint32 i = 0; i < sampleParams.samplesPerPixel; ++i)
{ {
sampleParams.pass = i; sampleParams.pass = pass;
command->pushConstants(Gfx::SE_SHADER_STAGE_RAYGEN_BIT_KHR, 0, sizeof(SampleParams), &sampleParams); command->pushConstants(Gfx::SE_SHADER_STAGE_RAYGEN_BIT_KHR, 0, sizeof(SampleParams), &sampleParams);
command->traceRays(texture->getWidth(), texture->getHeight(), 1); command->traceRays(texture->getWidth(), texture->getHeight(), 1);
radianceAccumulator->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR, radianceAccumulator->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR,
@@ -164,8 +164,8 @@ void RayTracingPass::render() {
texture->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR, texture->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR,
Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR); Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR);
} }
i++; pass++;
std::cout << i << std::endl; std::cout << pass << std::endl;
texture->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR, texture->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR,
Gfx::SE_ACCESS_TRANSFER_READ_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT); Gfx::SE_ACCESS_TRANSFER_READ_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT);
Array<Gfx::ORenderCommand> commands; Array<Gfx::ORenderCommand> commands;
+99 -32
View File
@@ -8,8 +8,9 @@
using namespace Seele; using namespace Seele;
UIPass::UIPass(Gfx::PGraphics graphics, UI::PSystem system) : RenderPass(graphics) { UIPass::UIPass(Gfx::PGraphics graphics, UI::PSystem system) : RenderPass(graphics), system(system) {
glyphInstanceBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{.name = "GlyphInstanceBuffer"}); glyphInstanceBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{.name = "GlyphInstanceBuffer"});
elementBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{.name = "RenderStyleElements"});
textDescriptorLayout = graphics->createDescriptorLayout("pText"); textDescriptorLayout = graphics->createDescriptorLayout("pText");
textDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{ textDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 0, .binding = 0,
@@ -28,15 +29,24 @@ UIPass::UIPass(Gfx::PGraphics graphics, UI::PSystem system) : RenderPass(graphic
textPipelineLayout->addDescriptorLayout(viewParamsLayout); textPipelineLayout->addDescriptorLayout(viewParamsLayout);
textPipelineLayout->addDescriptorLayout(textDescriptorLayout); textPipelineLayout->addDescriptorLayout(textDescriptorLayout);
uiDescriptorLayout = graphics->createDescriptorLayout("pParams");
uiDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 0,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
});
uiDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 1,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER,
});
uiDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 2,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
.descriptorCount = 1024,
});
uiPipelineLayout = graphics->createPipelineLayout("UIPipeline"); uiPipelineLayout = graphics->createPipelineLayout("UIPipeline");
uiPipelineLayout->addDescriptorLayout(viewParamsLayout); uiPipelineLayout->addDescriptorLayout(viewParamsLayout);
uiPipelineLayout->addDescriptorLayout(uiDescriptorLayout);
// todo: // todo:
texts.add(TextRender{
.text = "TestText123",
.font = AssetRegistry::findFont("", "arial"),
.fontSize = 12,
.position = Vector2(0, 100),
});
} }
UIPass::~UIPass() {} UIPass::~UIPass() {}
@@ -45,35 +55,49 @@ void UIPass::beginFrame(const Component::Camera& cam) {
RenderPass::beginFrame(cam); RenderPass::beginFrame(cam);
glyphs.clear(); glyphs.clear();
usedTextures.clear(); usedTextures.clear();
for (TextRender& render : texts) { for (const auto& render : renderElements) {
TextResources& res = textResources[render.font].add(); float x = render.position.x;
float x = render.position.x * viewport->getContentScaleX(); float y = render.position.y;
float y = (viewport->getHeight() - render.position.y) * viewport->getContentScaleY(); if (render.text.empty()) {
for (uint32 c : render.text) { //todo: convert using actual tree depth
const FontAsset::Glyph& glyph = render.font->getGlyphData(c); elements.add(RenderElementStyle{
Vector2 bearing = Vector2(glyph.bearing) * viewport->getContentScaleX(); .x = x,
Vector2 size = Vector2(glyph.size) * viewport->getContentScaleY(); .y = y,
float xpos = x + glyph.bearing.x; .w = render.dimensions.x,
float ypos = y + (size.y - bearing.y); .h = render.dimensions.y,
.color = render.backgroundColor,
float w = size.x; .z = render.level / 100.f,
float h = size.y;
glyphs.add(GlyphInstanceData{
.x = xpos,
.y = ypos,
.width = w,
.height = h,
.glyphIndex = (uint32)usedTextures.size(),
}); });
usedTextures.add(glyph.texture); } else {
x += glyph.advance >> 6; y = y + render.fontSize;
for (uint32 c : render.text) {
const FontAsset::Glyph& glyph = render.font->getGlyphData(c);
Vector2 bearing = Vector2(glyph.bearing);
Vector2 size = Vector2(glyph.size);
float xpos = x + glyph.bearing.x;
float ypos = y - bearing.y;
float w = size.x;
float h = size.y;
glyphs.add(GlyphInstanceData{
.x = xpos,
.y = ypos,
.z = render.level / 100.0f,
.width = w,
.height = h,
.glyphIndex = (uint32)usedTextures.size(),
});
usedTextures.add(glyph.texture);
x += glyph.advance / 64.0f;
}
} }
} }
glyphInstanceBuffer->rotateBuffer(sizeof(GlyphInstanceData) * glyphs.size()); glyphInstanceBuffer->rotateBuffer(sizeof(GlyphInstanceData) * glyphs.size());
glyphInstanceBuffer->updateContents(0, sizeof(GlyphInstanceData) * glyphs.size(), glyphs.data()); glyphInstanceBuffer->updateContents(0, sizeof(GlyphInstanceData) * glyphs.size(), glyphs.data());
glyphInstanceBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT, glyphInstanceBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_VERTEX_SHADER_BIT); Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_VERTEX_SHADER_BIT);
textDescriptorLayout->reset(); textDescriptorLayout->reset();
textDescriptorSet = textDescriptorLayout->allocateDescriptorSet(); textDescriptorSet = textDescriptorLayout->allocateDescriptorSet();
textDescriptorSet->updateBuffer(0, 0, glyphInstanceBuffer); textDescriptorSet->updateBuffer(0, 0, glyphInstanceBuffer);
@@ -82,6 +106,16 @@ void UIPass::beginFrame(const Component::Camera& cam) {
textDescriptorSet->updateTexture(2, i, usedTextures[i]); textDescriptorSet->updateTexture(2, i, usedTextures[i]);
} }
textDescriptorSet->writeChanges(); textDescriptorSet->writeChanges();
elementBuffer->rotateBuffer(sizeof(RenderElementStyle) * elements.size());
elementBuffer->updateContents(0, sizeof(RenderElementStyle) * elements.size(), elements.data());
elementBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT, Gfx::SE_ACCESS_SHADER_READ_BIT,
Gfx::SE_PIPELINE_STAGE_VERTEX_SHADER_BIT);
uiDescriptorLayout->reset();
uiDescriptorSet = uiDescriptorLayout->allocateDescriptorSet();
uiDescriptorSet->updateBuffer(0, 0, elementBuffer);
uiDescriptorSet->updateSampler(1, 0, glyphSampler);
uiDescriptorSet->writeChanges();
} }
void UIPass::render() { void UIPass::render() {
@@ -89,6 +123,9 @@ void UIPass::render() {
Array<Gfx::ORenderCommand> commands; Array<Gfx::ORenderCommand> commands;
Gfx::ORenderCommand command = graphics->createRenderCommand("TextPassCommand"); Gfx::ORenderCommand command = graphics->createRenderCommand("TextPassCommand");
command->setViewport(viewport); command->setViewport(viewport);
command->bindPipeline(uiPipeline);
command->bindDescriptor({viewParamsSet, uiDescriptorSet});
command->draw(4, elements.size(), 0, 0);
command->bindPipeline(textPipeline); command->bindPipeline(textPipeline);
command->bindDescriptor({viewParamsSet, textDescriptorSet}); command->bindDescriptor({viewParamsSet, textDescriptorSet});
command->draw(4, glyphs.size(), 0, 0); command->draw(4, glyphs.size(), 0, 0);
@@ -142,7 +179,7 @@ void UIPass::createRenderPass() {
.addressModeV = Gfx::SE_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, .addressModeV = Gfx::SE_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
}); });
Gfx::LegacyPipelineCreateInfo pipelineInfo = { textPipeline = graphics->createGraphicsPipeline(Gfx::LegacyPipelineCreateInfo{
.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, .topology = Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,
.vertexShader = textVertexShader, .vertexShader = textVertexShader,
.fragmentShader = textFragmentShader, .fragmentShader = textFragmentShader,
@@ -167,15 +204,45 @@ void UIPass::createRenderPass() {
Gfx::SE_COLOR_COMPONENT_A_BIT, Gfx::SE_COLOR_COMPONENT_A_BIT,
}}, }},
}, },
}; });
textPipeline = graphics->createGraphicsPipeline(std::move(pipelineInfo));
graphics->beginShaderCompilation(ShaderCompilationInfo{ graphics->beginShaderCompilation(ShaderCompilationInfo{
.name = "UIVertex", .name = "UIVertex",
.modules = {"UIPass"}, .modules = {"UIPass"},
.entryPoints = {{"vertexMain", "UIPass"}, {"fragmentMain", "UIPass"}}, .entryPoints = {{"vertexMain", "UIPass"}, {"fragmentMain", "UIPass"}},
.rootSignature = uiPipelineLayout, .rootSignature = uiPipelineLayout,
}); });
uiPipelineLayout->create();
uiVertexShader = graphics->createVertexShader({0}); uiVertexShader = graphics->createVertexShader({0});
uiFragmentShader = graphics->createFragmentShader({1}); uiFragmentShader = graphics->createFragmentShader({1});
uiPipeline = graphics->createGraphicsPipeline(Gfx::LegacyPipelineCreateInfo{
.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,
.vertexShader = uiVertexShader,
.fragmentShader = uiFragmentShader,
.renderPass = renderPass,
.pipelineLayout = uiPipelineLayout,
.rasterizationState =
{
.cullMode = Gfx::SE_CULL_MODE_NONE,
},
.colorBlend =
{
.attachmentCount = 1,
.blendAttachments = {{
.blendEnable = true,
.srcColorBlendFactor = Gfx::SE_BLEND_FACTOR_SRC_ALPHA,
.dstColorBlendFactor = Gfx::SE_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
.srcAlphaBlendFactor = Gfx::SE_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
.dstAlphaBlendFactor = Gfx::SE_BLEND_FACTOR_ZERO,
.alphaBlendOp = Gfx::SE_BLEND_OP_ADD,
.colorWriteMask = Gfx::SE_COLOR_COMPONENT_R_BIT | Gfx::SE_COLOR_COMPONENT_G_BIT | Gfx::SE_COLOR_COMPONENT_B_BIT |
Gfx::SE_COLOR_COMPONENT_A_BIT,
}},
},
});
system->style();
system->layout(UVector2(viewport->getWidth(), viewport->getHeight()));
renderElements = system->render();
} }
+16 -17
View File
@@ -7,13 +7,6 @@
namespace Seele { namespace Seele {
DECLARE_NAME_REF(Gfx, Texture2D) DECLARE_NAME_REF(Gfx, Texture2D)
DECLARE_NAME_REF(Gfx, RenderTargetAttachment) DECLARE_NAME_REF(Gfx, RenderTargetAttachment)
struct TextRender {
std::string text;
PFontAsset font;
uint32 fontSize;
Vector4 textColor;
Vector2 position;
};
class UIPass : public RenderPass { class UIPass : public RenderPass {
public: public:
UIPass(Gfx::PGraphics graphics, UI::PSystem system); UIPass(Gfx::PGraphics graphics, UI::PSystem system);
@@ -35,21 +28,24 @@ class UIPass : public RenderPass {
struct GlyphInstanceData { struct GlyphInstanceData {
float x; float x;
float y; float y;
float z;
float width; float width;
float height; float height;
uint32 glyphIndex; uint32 glyphIndex;
}; };
struct TextData {
Vector4 textColor;
float scale;
};
struct TextResources { struct RenderElementStyle {
Gfx::PShaderBuffer instanceBuffer; float x;
Gfx::PDescriptorSet textureArraySet; float y;
TextData textData; float w;
float h;
Vector color;
float opacity = 1;
float z = 0;
uint32 textureIndex = -1ul;
uint32 pad0;
uint32 pad1;
}; };
Map<PFontAsset, Array<TextResources>> textResources;
Gfx::RenderTargetAttachment colorAttachment; Gfx::RenderTargetAttachment colorAttachment;
Gfx::RenderTargetAttachment depthAttachment; Gfx::RenderTargetAttachment depthAttachment;
@@ -71,9 +67,12 @@ class UIPass : public RenderPass {
Gfx::OPipelineLayout uiPipelineLayout; Gfx::OPipelineLayout uiPipelineLayout;
Gfx::PGraphicsPipeline uiPipeline; Gfx::PGraphicsPipeline uiPipeline;
Array<TextRender> texts; UI::PSystem system;
Array<UI::UIRender> renderElements;
Array<GlyphInstanceData> glyphs; Array<GlyphInstanceData> glyphs;
Array<RenderElementStyle> elements;
Gfx::OShaderBuffer glyphInstanceBuffer; Gfx::OShaderBuffer glyphInstanceBuffer;
Gfx::OShaderBuffer elementBuffer;
Gfx::OSampler glyphSampler; Gfx::OSampler glyphSampler;
Array<Gfx::PTexture2D> usedTextures; Array<Gfx::PTexture2D> usedTextures;
}; };
+5 -1
View File
@@ -39,7 +39,11 @@ class Buffer {
virtual ~Buffer(); virtual ~Buffer();
VkBuffer getHandle() const { return buffers[currentBuffer]->buffer; } VkBuffer getHandle() const { return buffers[currentBuffer]->buffer; }
VkDeviceAddress getDeviceAddress() const { return buffers[currentBuffer]->deviceAddress; } VkDeviceAddress getDeviceAddress() const { return buffers[currentBuffer]->deviceAddress; }
PBufferAllocation getAlloc() const { return buffers[currentBuffer]; } PBufferAllocation getAlloc() const {
if (buffers.empty())
return nullptr;
return buffers[currentBuffer];
}
uint64 getSize() const { return buffers[currentBuffer]->size; } uint64 getSize() const { return buffers[currentBuffer]->size; }
void updateContents(uint64 regionOffset, uint64 regionSize, void* ptr); void updateContents(uint64 regionOffset, uint64 regionSize, void* ptr);
void readContents(uint64 regionOffset, uint64 regionSize, void* ptr); void readContents(uint64 regionOffset, uint64 regionSize, void* ptr);
+4 -4
View File
@@ -171,7 +171,7 @@ DescriptorSet::~DescriptorSet() {}
void DescriptorSet::updateBuffer(uint32_t binding, uint32 index, Gfx::PUniformBuffer uniformBuffer) { void DescriptorSet::updateBuffer(uint32_t binding, uint32 index, Gfx::PUniformBuffer uniformBuffer) {
PUniformBuffer vulkanBuffer = uniformBuffer.cast<UniformBuffer>(); PUniformBuffer vulkanBuffer = uniformBuffer.cast<UniformBuffer>();
if (boundResources[binding][index] == vulkanBuffer->getAlloc()) { if (boundResources[binding][index] == vulkanBuffer->getAlloc() || vulkanBuffer->getAlloc() == nullptr) {
return; return;
} }
@@ -197,7 +197,7 @@ void DescriptorSet::updateBuffer(uint32_t binding, uint32 index, Gfx::PUniformBu
void DescriptorSet::updateBuffer(uint32_t binding, uint32 index, Gfx::PShaderBuffer shaderBuffer) { void DescriptorSet::updateBuffer(uint32_t binding, uint32 index, Gfx::PShaderBuffer shaderBuffer) {
PShaderBuffer vulkanBuffer = shaderBuffer.cast<ShaderBuffer>(); PShaderBuffer vulkanBuffer = shaderBuffer.cast<ShaderBuffer>();
if (boundResources[binding][index] == vulkanBuffer->getAlloc()) { if (boundResources[binding][index] == vulkanBuffer->getAlloc() || vulkanBuffer->getAlloc() == nullptr) {
return; return;
} }
@@ -222,7 +222,7 @@ void DescriptorSet::updateBuffer(uint32_t binding, uint32 index, Gfx::PShaderBuf
void DescriptorSet::updateBuffer(uint32_t binding, uint32 index, Gfx::PVertexBuffer indexBuffer) { void DescriptorSet::updateBuffer(uint32_t binding, uint32 index, Gfx::PVertexBuffer indexBuffer) {
PVertexBuffer vulkanBuffer = indexBuffer.cast<VertexBuffer>(); PVertexBuffer vulkanBuffer = indexBuffer.cast<VertexBuffer>();
if (boundResources[binding][index] == vulkanBuffer->getAlloc()) { if (boundResources[binding][index] == vulkanBuffer->getAlloc() || vulkanBuffer->getAlloc() == nullptr) {
return; return;
} }
@@ -247,7 +247,7 @@ void DescriptorSet::updateBuffer(uint32_t binding, uint32 index, Gfx::PVertexBuf
void DescriptorSet::updateBuffer(uint32_t binding, uint32 index, Gfx::PIndexBuffer indexBuffer) { void DescriptorSet::updateBuffer(uint32_t binding, uint32 index, Gfx::PIndexBuffer indexBuffer) {
PIndexBuffer vulkanBuffer = indexBuffer.cast<IndexBuffer>(); PIndexBuffer vulkanBuffer = indexBuffer.cast<IndexBuffer>();
if (boundResources[binding][index] == vulkanBuffer->getAlloc()) { if (boundResources[binding][index] == vulkanBuffer->getAlloc() || vulkanBuffer->getAlloc() == nullptr) {
return; return;
} }
+1 -1
View File
@@ -30,6 +30,6 @@ Matrix4 Viewport::getProjectionMatrix() const {
//); //);
return glm::perspective(fieldOfView, sizeX / static_cast<float>(sizeY), 0.1f, 1000.0f); return glm::perspective(fieldOfView, sizeX / static_cast<float>(sizeY), 0.1f, 1000.0f);
} else { } else {
return glm::ortho(0.0f, (float)sizeX, 0.0f, (float)sizeY); return glm::ortho(0.0f, (float)sizeX, (float)sizeY, 0.0f);
} }
} }
+8 -11
View File
@@ -4,16 +4,13 @@
using namespace Seele; using namespace Seele;
using namespace Seele::UI; using namespace Seele::UI;
Array<RenderElement> Element::render() { Element::Element(Attributes attr, Array<Element*> _children) : attr(attr) {
RenderElement result; for (auto c : _children) {
result.position = UVector2(0, 0); children.add(c);
result.size = UVector2(style.width, style.height); }
result.backgroundColor = style.backgroundColor; for (auto& child : children) {
result.fontSize = style.fontSize; child->setParent(this);
result.fontFamily = style.fontFamily; }
return {result};
} }
Element::Element(Attributes attr, Array<OElement> children) : attr(attr), children(std::move(children)) {} Element::~Element() {}
Element::~Element() {}
+125 -5
View File
@@ -6,18 +6,138 @@
namespace Seele { namespace Seele {
namespace UI { namespace UI {
struct RenderElement; struct UIRender {
std::string text;
PFontAsset font;
uint32 fontSize;
Vector textColor;
Vector backgroundColor;
Vector2 position;
Vector2 dimensions;
uint32 z;
uint32 level;
};
DECLARE_REF(Element) DECLARE_REF(Element)
class Element { class Element {
public: public:
Element(Attributes attr, Array<OElement> children); Element(Attributes attr, Array<Element*> children);
virtual ~Element(); virtual ~Element();
virtual void calcStyle(Style parentStyle) = 0; void setParent(PElement p) { parent = p; }
Array<RenderElement> render(); // calculates the final style object taking into account inherited properties
virtual void applyStyle(Style parentStyle) = 0;
void calcStyle(Style parentStyle) {
applyStyle(parentStyle);
for (auto& child : children) {
child->calcStyle(style);
}
}
// calculates the relative positions of the child elements for the applied layout style
virtual void layout(UVector2 parentSize) {
if (style.maxWidthType == DimensionType::Auto) {
maxDimensions.x = parentSize.x;
}
if (style.maxHeightType == DimensionType::Auto) {
maxDimensions.y = parentSize.y;
}
if (style.widthType == DimensionType::Pixel) {
dimensions.x = style.width;
} else if (style.widthType == DimensionType::Percent) {
dimensions.x = parentSize.x * style.width / 100.0f;
}
if (style.heightType == DimensionType::Pixel) {
dimensions.y = style.height;
} else if (style.heightType == DimensionType::Percent) {
dimensions.y = parentSize.y * style.height / 100.0f;
}
for (auto& child : children) {
child->layout(maxDimensions);
}
switch (style.innerDisplay) {
case InnerDisplayType::Flow:
flowLayout();
break;
}
}
// normal flow of the elements, inline elements go left to right, blocks get their own new lines
void flowLayout() {
// use a cursor going from left to right, top to bottom, starting at padding
Vector2 cursor = Vector2(style.paddingLeft, style.paddingTop);
uint32 lineHeight = 0;
for (auto& child : children) {
// inline elements flow left to right
if (child->style.outerDisplay == OuterDisplayType::Inline) {
// only static and relative elements actually reserve
if (child->style.position == PositionType::Static || child->style.position == PositionType::Relative) {
// create a new line in case the element doesnt fit on the current one anymore,
// but keep in current line in case we are still at the start, as a new line wouldnt help here
if (cursor.x + child->dimensions.x > dimensions.x - child->style.left && cursor.x != 0) {
cursor.x = 0;
cursor.y += lineHeight;
}
// todo: border
child->position.x = cursor.x + child->style.marginLeft;
child->position.y = cursor.y + child->style.marginTop;
cursor.x = child->position.x + child->dimensions.x;
cursor.y = child->position.y + child->dimensions.y;
// apply offsets after updating the cursor for relative elements
if (child->style.position == PositionType::Relative) {
child->position.x += child->style.left;
child->position.y += child->style.top;
}
lineHeight = std::max(lineHeight, child->style.lineHeight);
}
// block elements always get their own lines, like paragraphs
} else if (child->style.outerDisplay == OuterDisplayType::Block) {
// static and relative require space to be created for the elements
if (child->style.position == PositionType::Static || child->style.position == PositionType::Relative) {
// create a new line in case we are not already at one
if (cursor.x != 0) {
cursor.x = 0;
cursor.y += lineHeight;
}
child->position.x = cursor.x + child->style.marginLeft;
child->position.y = cursor.y + child->style.marginTop;
// new line after block
cursor.x = 0;
cursor.y = child->position.y + child->dimensions.y;
}
}
}
if (style.widthType == DimensionType::Auto) {
dimensions.x = cursor.x + style.paddingRight;
}
if (style.heightType == DimensionType::Auto) {
dimensions.y = cursor.y + style.paddingBottom;
}
}
virtual Array<UIRender> render(Vector2 anchor, uint32 level) {
Array<UIRender> result = {
UIRender{
.backgroundColor = style.backgroundColor,
.position = position + anchor,
.dimensions = dimensions,
.z = style.z,
.level = level,
},
};
for (auto& child : children) {
for (const auto& render : child->render(position + anchor, level+1)) {
result.add(render);
}
}
return result;
}
Style style;
Vector2 maxDimensions = Vector2(0);
// calculated position relative to parent
Vector2 position = Vector2(0);
// calculated dimensions in pixels after layouting
Vector2 dimensions = Vector2(0);
protected: protected:
Style style;
Attributes attr; Attributes attr;
PElement parent = nullptr;
Array<OElement> children; Array<OElement> children;
}; };
DEFINE_REF(Element) DEFINE_REF(Element)
+8 -1
View File
@@ -7,8 +7,15 @@ namespace UI {
template<StyleClass... classes> template<StyleClass... classes>
class Div : public Element { class Div : public Element {
public: public:
Div(Attributes attr, std::initializer_list<OElement> children) : Element(attr, children) { style.displayType = DisplayType::Block; } Div(Attributes attr, Array<Element*> children) : Element(attr, std::move(children)) { }
virtual ~Div() {} virtual ~Div() {}
virtual void applyStyle(Style parentStyle) override {
style = parentStyle;
style.outerDisplay = OuterDisplayType::Block;
style.widthType = DimensionType::Percent;
style.width = 100;
(classes::apply(style), ...);
}
private: private:
}; };
} // namespace UI } // namespace UI
+28 -2
View File
@@ -4,10 +4,36 @@
namespace Seele { namespace Seele {
namespace UI { namespace UI {
class Text : public Element { template <StyleClass... classes> class Text : public Element {
public: public:
Text(std::string text) : Element({}, {}), text(text) {} Text(std::string text) : Element({}, {}), text(text) {}
virtual void calcStyle(Style parentStyle) override { style = parentStyle; } virtual void applyStyle(Style parentStyle) {
style = parentStyle;
style.outerDisplay = OuterDisplayType::Inline;
(classes::apply(style), ...);
}
virtual void layout(UVector2 parentSize) override {
size_t cursor = 0;
for (uint32 i = 0; i < text.size() - 1; ++i) {
dimensions.x += style.fontFamily->getGlyphData(text[i]).advance / 64.0f;
}
dimensions.x += style.fontFamily->getGlyphData(text[text.size() - 1]).size.x;
dimensions.y = style.fontSize;
}
virtual Array<UIRender> render(Vector2 anchor, uint32 level) override {
return {
UIRender{
.text = text,
.font = style.fontFamily,
.fontSize = style.fontSize,
.position = position + anchor,
.dimensions = dimensions,
.z = style.z,
.level = level,
},
};
}
// height = fontsize * 1.12
private: private:
std::string text; std::string text;
+30 -12
View File
@@ -1,27 +1,45 @@
#pragma once #pragma once
#include "MinimalEngine.h" #include "MinimalEngine.h"
#include "Style.h" #include "Style.h"
#include "Asset/AssetRegistry.h"
namespace Seele { namespace Seele {
namespace UI {
template <typename C> template <typename C>
concept StyleClass = requires(C c, Style& s) { c.apply(s); }; concept StyleClass = requires(C c, UI::Style& s) { c.apply(s); };
template <uint32 w, DimensionType widthType> struct WidthClass { template <uint32 w, UI::DimensionType widthType> struct WidthClass {
static void apply(Style& s) { static void apply(UI::Style& s) {
s.width = w; s.width = w;
s.widthType = widthType; s.widthType = widthType;
} }
}; };
using W_Full = WidthClass<100, DimensionType::Percent>; using W_Full = WidthClass<100, UI::DimensionType::Percent>;
using W_1 = WidthClass<2, DimensionType::Pixel>; using W_1 = WidthClass<2, UI::DimensionType::Pixel>;
template <DisplayType displayType> struct DisplayClass { template <UI::OuterDisplayType outer, UI::InnerDisplayType inner> struct DisplayClass {
static void apply(Style& s) { s.displayType = displayType; } static void apply(UI::Style& s) {
s.outerDisplay = outer;
s.innerDisplay = inner;
}
}; };
using Hidden = DisplayClass<DisplayType::Hidden>; using Hidden = DisplayClass<UI::OuterDisplayType::Hidden, UI::InnerDisplayType::Flow>;
using Block = DisplayClass<DisplayType::Block>; using Block = DisplayClass<UI::OuterDisplayType::Block, UI::InnerDisplayType::Flow>;
using Flex = DisplayClass<DisplayType::Flex>; using Inline = DisplayClass<UI::OuterDisplayType::Inline, UI::InnerDisplayType::Flow>;
} // namespace UI template <size_t N> struct StringLiteral {
constexpr StringLiteral(const char (&str)[N]) { std::copy_n(str, N, value); }
char value[N];
};
template <StringLiteral lit> struct FontClass {
static void apply(UI::Style& s) { s.fontFamily = AssetRegistry::findFont("", lit.value); }
};
using Font_Arial = FontClass<"arial">;
template <Vector backgroundColor> struct BackgroundColorClass {
static void apply(UI::Style& s) { s.backgroundColor = backgroundColor; }
};
using BG_Red = BackgroundColorClass<Vector(1, 0, 0)>;
} // namespace Seele } // namespace Seele
+23 -10
View File
@@ -8,32 +8,41 @@ namespace UI {
enum class DimensionType { enum class DimensionType {
Pixel, Pixel,
Percent, // EM, PEM, etc... Percent, // EM, PEM, etc...
Auto,
}; };
enum class PositionType { enum class PositionType {
Relative,
Static, Static,
Relative,
Absolute, Absolute,
Sticky, Sticky,
}; };
enum class DisplayType { enum class OuterDisplayType {
Inline, Inline,
Hidden,
Block, Block,
Hidden,
};
enum class InnerDisplayType {
Flow,
Flex, Flex,
Grid, Grid,
}; };
struct Style { struct Style {
DimensionType widthType = DimensionType::Pixel; DimensionType widthType = DimensionType::Auto;
uint32 width = 0; float width = 0;
DimensionType heightType = DimensionType::Pixel; DimensionType maxWidthType = DimensionType::Auto;
uint32 height = 0; float maxWidth = 0;
DimensionType heightType = DimensionType::Auto;
float height = 0;
DimensionType maxHeightType = DimensionType::Auto;
float maxHeight = 0;
uint32 z = 0; uint32 z = 0;
Vector backgroundColor = Vector(1, 1, 1); Vector backgroundColor = Vector(1, 1, 1);
DisplayType displayType = DisplayType::Inline; OuterDisplayType outerDisplay = OuterDisplayType::Inline;
InnerDisplayType innerDisplay = InnerDisplayType::Flow;
PositionType position = PositionType::Relative; PositionType position = PositionType::Relative;
PFontAsset fontFamily; PFontAsset fontFamily;
uint32 lineHeight = 12; uint32 lineHeight = 48;
uint32 fontSize = 12; uint32 fontSize = 48;
uint32 fontWeight = 0; uint32 fontWeight = 0;
uint32 paddingTop = 0; uint32 paddingTop = 0;
uint32 paddingBottom = 0; uint32 paddingBottom = 0;
@@ -44,6 +53,10 @@ struct Style {
uint32 marginLeft = 0; uint32 marginLeft = 0;
uint32 marginRight = 0; uint32 marginRight = 0;
uint32 gap = 0; uint32 gap = 0;
uint32 top = 0;
uint32 bottom = 0;
uint32 left = 0;
uint32 right = 0;
}; };
} // namespace UI } // namespace UI
} // namespace Seele } // namespace Seele
+4 -17
View File
@@ -3,26 +3,13 @@
namespace Seele { namespace Seele {
namespace UI { namespace UI {
struct RenderElement {
// position relative to target viewport in pixels
UVector2 position;
// size relative to target viewport in pixels
UVector2 size;
// background color of area
Vector backgroundColor;
// text to render
std::string text;
// font size in pixels
uint32 fontSize;
// font family
PFontAsset fontFamily;
};
class System { class System {
public: public:
System(OElement rootElement) : rootElement(std::move(rootElement)) {} System(OElement rootElement) : rootElement(std::move(rootElement)) {}
~System(); ~System() {}
Array<RenderElement> render(UVector2 viewport) { void style() { rootElement->calcStyle(UI::Style()); }
} void layout(UVector2 viewport) { rootElement->layout(viewport); }
Array<UIRender> render() { return rootElement->render(Vector2(0, 0), 1); }
private: private:
OElement rootElement; OElement rootElement;