From e4584401ad865afb5a0fec8b7cab67794490a10d Mon Sep 17 00:00:00 2001 From: fschildt Date: Mon, 24 Nov 2025 19:55:42 +0100 Subject: rendering: refactor z-based sorting/drawing --- src/renderer/Renderer.hpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'src/renderer/Renderer.hpp') diff --git a/src/renderer/Renderer.hpp b/src/renderer/Renderer.hpp index 47837ee..da57e29 100644 --- a/src/renderer/Renderer.hpp +++ b/src/renderer/Renderer.hpp @@ -29,7 +29,7 @@ enum REntityType : int32_t { struct REntity_AlphaBitmap { REntityType type; AlphaBitmap& bitmap; - V3F32 pos; + V2F32 pos; Color color; }; @@ -49,7 +49,7 @@ struct REntity_Text { REntityType type; std::u32string& text; Font& font; - V3F32 pos; + V2F32 pos; Color color; }; @@ -62,9 +62,9 @@ union REntity { REntity_Text text; }; -struct RSortEntry { - float z; - size_t entity_index; +struct RZBuffEntry { + uint32_t z; + uint32_t entity_index; }; @@ -82,15 +82,14 @@ public: void SetScreenSize(int32_t w, int32_t h); void SetCameraSize(float w, float h); - void PushAlphaBitmap(AlphaBitmap& bitmap, V3F32 pos, Color color); - void PushRectangle(Rectangle rect, Color color, float z); - void PushCircle(Circle circle, Color color, float z); - void PushText(std::u32string& text, Font& font, V3F32 pos, Color color); + void PushAlphaBitmap(AlphaBitmap& bitmap, V2F32 pos, Color color, uint32_t z); + void PushRectangle(Rectangle rect, Color color, uint32_t z); + void PushCircle(Circle circle, Color color, uint32_t z); + void PushText(std::u32string& text, Font& font, V2F32 pos, Color color, uint32_t z); /* helper functions */ - int32_t WorldXToScreenX(float x); int32_t WorldYToScreenY(float y); int32_t WorldWidthToScreenWidth(float w); @@ -109,11 +108,9 @@ public: Color m_clear_color {}; std::vector m_render_entities; - std::vector m_sort_entries; + std::vector m_z_buff; std::unique_ptr m_backend; - - friend class RSoftwareBackend; }; -- cgit v1.2.3