From 629841e2ce67e20725e32db9563740fc6fab7f70 Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Sun, 21 Dec 2025 20:25:59 +0100 Subject: [PATCH] rot clip fix --- examples/HelloRotation/main.cpp | 37 +++++++++++++++++++++++++++++ examples/HelloRotation/project.json | 15 ++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 examples/HelloRotation/main.cpp create mode 100644 examples/HelloRotation/project.json diff --git a/examples/HelloRotation/main.cpp b/examples/HelloRotation/main.cpp new file mode 100644 index 0000000..4279614 --- /dev/null +++ b/examples/HelloRotation/main.cpp @@ -0,0 +1,37 @@ +import Crafter.Event; +import Crafter.Graphics; +import std; +using namespace Crafter; + +int main() { + WindowWayland window(200, 200, "Hello Input!"); + + RenderingElementScalingRotating2D element( + OpaqueType::SemiOpaque, //opaque, wether the element is opague or semi-transparant + 1, //bufferWidth: the width of this elements pixel buffer + 1, //bufferHeight: the height of this elements pixel buffer + FractionalToMappedBoundlessU(0.125), + FractionalToMapped(0.5), //anchorX: relative position where this elements x anchor (top-left) is placed to its parent x anchor + FractionalToMapped(0.5), //anchorY: relative position where this elements y anchor (top-left) is placed to its parent y anchor + FractionalToMapped(0.5), //relativeSizeX: the relative x size this element should be scaled to compared to its parent + FractionalToMapped(0.5), //relativeSizeY: the relative y size this element should be scaled to compared to its parent + FractionalToMapped(0.5), //anchorOffsetX: the amount this element's anchor should be offset from the top left corner (0.5 to in the middle) + FractionalToMapped(0.5), //anchorOffsetY: the amount this element's anchor should be offset from the top left corner (0.5 to place it in the middle) + 0, //z: this elements Z position + false //ignoreScaling: wether this element ignores the scaling of the window, if true its size will be scaled according to the window scale + ); + + window.elements.push_back(&element); + element.buffer = {{255, 0, 0 ,255}}; + element.UpdatePosition(window); + + EventListener updateListener(&window.onUpdate, [&](FrameTime time){ + element.rotation += 50000000000000000; + std::cout << element.rotation << std::endl; + element.UpdatePosition(window); + window.LogTiming(); + }); + + window.StartUpdate(); + window.StartSync(); +} diff --git a/examples/HelloRotation/project.json b/examples/HelloRotation/project.json new file mode 100644 index 0000000..3762cb1 --- /dev/null +++ b/examples/HelloRotation/project.json @@ -0,0 +1,15 @@ +{ + "name": "crafter-graphics", + "configurations": [ + { + "name": "executable", + "implementations": ["main"], + "dependencies": [ + { + "path":"../../project.json", + "configuration":"lib-wayland-timing" + } + ] + } + ] +}