Added 'transform' support

This commit is contained in:
2026-08-30 18:45:07 -05:00
parent 531ad69bcc
commit b75eebfd49
5 changed files with 25 additions and 3 deletions

View File

@@ -5,5 +5,7 @@
</head>
<body>
<h1>Hello from RmlUi</h1>
<div style="position:absolute; top: 0; left: 0; width: 200px; height: 100px; background-color: rgba(255, 0, 0, 128); transform: rotate(15deg) translate(50px,0) scale(0.8)">
</div>
</body>
</rml>

View File

@@ -8,7 +8,7 @@ I originally began creating this for a Game Jam project where I got the basic re
*Rendering features (from the RmlUi render interfface documentation https://mikke89.github.io/RmlUiDoc/pages/cpp_manual/interfaces/render.html#feature-table):*
- [x] Basic rendering
- [ ] Clip Mask
- [ ] Transforms
- [x] Transforms
- [ ] Layers
- [ ] Render textures
- [ ] Mask images

View File

@@ -39,6 +39,10 @@ void RaylibRenderInterface::RenderGeometry(Rml::CompiledGeometryHandle handle,
rlPushMatrix();
rlTranslatef(translation.x, translation.y, 0.0f);
if (has_transform) {
rlMultMatrixf(current_transform.data());
}
rlBegin(RL_TRIANGLES);
for (size_t i = 0; i + 2 < geo->indices.size(); i += 3) {
for (int j = 0; j < 3; ++j) {
@@ -114,3 +118,12 @@ void RaylibRenderInterface::ApplyScissor() {
BeginScissorMode(scissor_region.Left(), scissor_region.Top(),
scissor_region.Width(), scissor_region.Height());
}
void RaylibRenderInterface::SetTransform(const Rml::Matrix4f *transform) {
if (transform) {
has_transform = true;
current_transform = *transform;
} else {
has_transform = false;
}
}

View File

@@ -30,9 +30,14 @@ public:
void EnableScissorRegion(bool enable) override;
void SetScissorRegion(Rml::Rectanglei region) override;
void SetTransform(const Rml::Matrix4f *transform) override;
private:
void ApplyScissor();
bool scissor_enabled = false;
Rml::Rectanglei scissor_region;
bool has_transform = false;
Rml::Matrix4f current_transform;
};

View File

@@ -50,6 +50,8 @@ int main() {
}
CloseWindow();
Rml::Debugger::Shutdown();
Rml::Shutdown();
return 0;
}