Added 'transform' support
This commit is contained in:
@@ -5,5 +5,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Hello from RmlUi</h1>
|
<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>
|
</body>
|
||||||
</rml>
|
</rml>
|
||||||
|
|||||||
@@ -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):*
|
*Rendering features (from the RmlUi render interfface documentation https://mikke89.github.io/RmlUiDoc/pages/cpp_manual/interfaces/render.html#feature-table):*
|
||||||
- [x] Basic rendering
|
- [x] Basic rendering
|
||||||
- [ ] Clip Mask
|
- [ ] Clip Mask
|
||||||
- [ ] Transforms
|
- [x] Transforms
|
||||||
- [ ] Layers
|
- [ ] Layers
|
||||||
- [ ] Render textures
|
- [ ] Render textures
|
||||||
- [ ] Mask images
|
- [ ] Mask images
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ void RaylibRenderInterface::RenderGeometry(Rml::CompiledGeometryHandle handle,
|
|||||||
rlPushMatrix();
|
rlPushMatrix();
|
||||||
rlTranslatef(translation.x, translation.y, 0.0f);
|
rlTranslatef(translation.x, translation.y, 0.0f);
|
||||||
|
|
||||||
|
if (has_transform) {
|
||||||
|
rlMultMatrixf(current_transform.data());
|
||||||
|
}
|
||||||
|
|
||||||
rlBegin(RL_TRIANGLES);
|
rlBegin(RL_TRIANGLES);
|
||||||
for (size_t i = 0; i + 2 < geo->indices.size(); i += 3) {
|
for (size_t i = 0; i + 2 < geo->indices.size(); i += 3) {
|
||||||
for (int j = 0; j < 3; ++j) {
|
for (int j = 0; j < 3; ++j) {
|
||||||
@@ -113,4 +117,13 @@ void RaylibRenderInterface::SetScissorRegion(Rml::Rectanglei region) {
|
|||||||
void RaylibRenderInterface::ApplyScissor() {
|
void RaylibRenderInterface::ApplyScissor() {
|
||||||
BeginScissorMode(scissor_region.Left(), scissor_region.Top(),
|
BeginScissorMode(scissor_region.Left(), scissor_region.Top(),
|
||||||
scissor_region.Width(), scissor_region.Height());
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -30,9 +30,14 @@ public:
|
|||||||
void EnableScissorRegion(bool enable) override;
|
void EnableScissorRegion(bool enable) override;
|
||||||
void SetScissorRegion(Rml::Rectanglei region) override;
|
void SetScissorRegion(Rml::Rectanglei region) override;
|
||||||
|
|
||||||
|
void SetTransform(const Rml::Matrix4f *transform) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ApplyScissor();
|
void ApplyScissor();
|
||||||
|
|
||||||
bool scissor_enabled = false;
|
bool scissor_enabled = false;
|
||||||
Rml::Rectanglei scissor_region;
|
Rml::Rectanglei scissor_region;
|
||||||
};
|
|
||||||
|
bool has_transform = false;
|
||||||
|
Rml::Matrix4f current_transform;
|
||||||
|
};
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CloseWindow();
|
CloseWindow();
|
||||||
|
Rml::Debugger::Shutdown();
|
||||||
|
Rml::Shutdown();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user