From b46a0d9369fbaa1938f0968ab216bc2d564a9c37 Mon Sep 17 00:00:00 2001 From: fschildt Date: Mon, 21 Jul 2025 16:07:28 +0200 Subject: first commit --- src/renderer/RenderGroup.hpp | 83 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 src/renderer/RenderGroup.hpp (limited to 'src/renderer/RenderGroup.hpp') diff --git a/src/renderer/RenderGroup.hpp b/src/renderer/RenderGroup.hpp new file mode 100644 index 0000000..4904220 --- /dev/null +++ b/src/renderer/RenderGroup.hpp @@ -0,0 +1,83 @@ +#pragma once + +#include +#include +#include +#include + +enum REntityType : int32_t { + REntityType_Rectangle, + REntityType_Bitmap, +}; + +struct REntity_Rectangle { + REntityType type; + V3F32 pos; + V2F32 dim; + V3F32 color; +}; + +struct REntity_Bitmap { + REntityType type; + V3F32 pos; + int32_t width; + int32_t height; + void *data; +}; + +union REntity { + REntityType type; + REntity_Rectangle rect; + REntity_Bitmap bitmap; +}; + +struct RSortEntry { + RSortEntry(float z, size_t entity_index); + float z; + size_t entity_index; +}; + + +class RenderGroup { +public: + RenderGroup(); + void Clear(V3F32 color); + void Reset(); + + void SetCameraSize(float width, float height); + V2F32 ViewPosToScreenPos(V2F32 view_pos); + V2F32 ViewSizeToScreenSize(V2F32 view_size); + ImVec2 ViewPosToScreenPosImGui(V2F32 view_pos); + ImVec2 ViewSizeToScreenSizeImGui(V2F32 view_size); + float GetScale(); + + +public: + void PushRectangle(V3F32 pos, V2F32 dim, V3F32 color); + void PushBitmap(V3F32 pos, int width, int height, void *bitmap); + + +private: + void Sort(); + + +public: + int32_t m_ScreenWidth; + int32_t m_ScreenHeight; + + +private: + friend class GlRenderer; + + + float m_CameraWidth; + float m_CameraHeight; + + + V3F32 m_ClearColor; + + std::vector m_REntities; + std::vector m_RSortEntries; +}; + + -- cgit v1.2.3