cleaned up renderer
This commit is contained in:
parent
afe23851f0
commit
d661c88ee2
58 changed files with 3030 additions and 4722 deletions
|
|
@ -4,16 +4,17 @@ import std;
|
|||
using namespace Crafter;
|
||||
|
||||
int main() {
|
||||
WindowWayland window(1280, 720, "Hello Input!");
|
||||
Device::Initialize();
|
||||
Window window(1280, 720, "Hello Drawing!");
|
||||
|
||||
RenderingElement<true, true, false> element(
|
||||
RenderingElement2D<true, true, false> element(
|
||||
{
|
||||
FractionalToMapped<std::int32_t>(0.5), //anchorX: relative position where this elements x anchor (top-left) is placed to its parent x anchor
|
||||
FractionalToMapped<std::int32_t>(0.5), //anchorY: relative position where this elements y anchor (top-left) is placed to its parent y anchor
|
||||
FractionalToMapped<std::int32_t>(0.5), //relativeSizeX: the relative x size this element should be scaled to compared to its parent
|
||||
FractionalToMapped<std::int32_t>(0.5), //relativeSizeY: the relative y size this element should be scaled to compared to its parent
|
||||
FractionalToMapped<std::int32_t>(0.5), //anchorOffsetX: the amount this element's anchor should be offset from the top left corner (0.5 to in the middle)
|
||||
FractionalToMapped<std::int32_t>(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.5, //anchorX: relative position where this elements x anchor (top-left) is placed to its parent x anchor
|
||||
0.5, //anchorY: relative position where this elements y anchor (top-left) is placed to its parent y anchor
|
||||
0.5, //relativeSizeX: the relative x size this element should be scaled to compared to its parent
|
||||
0.5, //relativeSizeY: the relative y size this element should be scaled to compared to its parent
|
||||
0.5, //anchorOffsetX: the amount this element's anchor should be offset from the top left corner (0.5 to in the middle)
|
||||
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
|
||||
},
|
||||
OpaqueType::FullyOpaque,
|
||||
|
|
@ -23,20 +24,14 @@ int main() {
|
|||
|
||||
MouseElement mouse(window);
|
||||
element.children.push_back(&mouse);
|
||||
window.elements.push_back(&element);
|
||||
window.renderer.elements.push_back(&element);
|
||||
|
||||
element.scalingBuffer = {{255, 0, 0 ,255}, {0, 255, 0 ,255}};
|
||||
element.UpdatePosition(window);
|
||||
element.UpdatePosition(window.renderer);
|
||||
|
||||
EventListener<MousePoint> clickListener(&mouse.onMouseLeftClick, [&mouse, &window](MousePoint point) {
|
||||
// Print the coordinates where the user clicked relative to the element's top left corner.
|
||||
std::println("Clicked on Mapped X:{} Y:{}!\nClicked on Fraction X:{} Y:{}!\nClicked on Screen X:{} Y:{}!\n",
|
||||
//Mapped space
|
||||
point.x, point.y,
|
||||
// Fraction space
|
||||
MappedToFractionalBoundless(point.x), MappedToFractionalBoundless(point.y),
|
||||
// Screen space
|
||||
MappedToAbsoluteBoundless(point.x, MappedToAbsoluteBoundless(mouse.mouseScaled.width, window.width)), MappedToAbsoluteBoundless(point.y, MappedToAbsoluteBoundless(mouse.mouseScaled.width, window.height))
|
||||
EventListener<void> clickListener(&mouse.onMouseLeftClick, [&window]() {
|
||||
std::println("Clicked on X:{} Y:{}!",
|
||||
window.currentMousePos.x, window.currentMousePos.y
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue