better timing

This commit is contained in:
Jorijn van der Graaf 2025-11-25 21:25:04 +01:00
commit 59b6e2779f
4 changed files with 41 additions and 12 deletions

View file

@ -6,7 +6,7 @@ using namespace Crafter;
int main() {
WindowWayland window(1280, 720, "Hello Input!");
UiElementBufferBuffer* element = new UiElementBufferBuffer(
RenderingElement element(
2, //bufferWidth: the width of this elements pixel buffer
1, //bufferHeight: the height of this elements pixel buffer
FractionalToMapped(0.5), //anchorX: relative position where this elements x anchor (top-left) is placed to its parent x anchor
@ -19,9 +19,8 @@ int main() {
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->UpdatePosition(window);
window.elements.push_back(&element);
element.UpdatePosition(window);
Animation<std::tuple<std::int_fast32_t>> anim({
{std::chrono::seconds(0), FractionalToMapped(-0.5)},
@ -32,14 +31,14 @@ int main() {
EventListener<FrameTime> updateListener(&window.onUpdate, [&](FrameTime time){
std::tuple<std::int_fast32_t> value = anim.Play(time.now);
element->transform.anchorX = std::get<0>(value);
element->UpdatePosition(window);
element.anchorX = std::get<0>(value);
element.UpdatePosition(window);
if(anim.currentFrame == anim.keyframes.size()-1) {
anim.Start(time.now);
}
});
element->buffer = {{255, 0, 0 ,255}, {0, 255, 0 ,255}};
element.buffer = {{255, 0, 0 ,255}, {0, 255, 0 ,255}};
window.StartUpdate();
window.StartSync();
}

View file

@ -7,7 +7,7 @@
"dependencies": [
{
"path":"../../project.json",
"configuration":"lib-wayland"
"configuration":"lib-wayland-timing"
}
]
}