#pragma once #include #include #include #include #include #include class RSoftwareBackend; class Renderer; extern Renderer g_renderer; enum REntityType : int32_t { REntityType_Rectangle, REntityType_MonoBitmap, }; struct REntity_Rectangle { REntityType type; float x0; float y0; float x1; float y1; float z; Color color; }; struct REntity_MonoBitmap { REntityType type; float x; float y; int32_t w; int32_t h; float z; void *data; }; union REntity { REntityType type; REntity_Rectangle rect; REntity_MonoBitmap bitmap; }; struct RSortEntry { float z; size_t entity_index; }; class Renderer { public: void Init(SDL_Window* window); /* core functions */ void Draw(); void Reset(); void Clear(Color color); void PushRectangle(RectF32 rect, float z, Color color); void PushMonoBitmap(V3F32 pos, int w, int h, void* bitmap); /* helper functions */ void SetScreenSize(int32_t w, int32_t h); void SetCameraSize(float w, float h); int32_t WorldXToScreenX(float x); int32_t WorldYToScreenY(float y); int32_t WorldWidthToScreenWidth(float w); int32_t WorldHeightToScreenHeight(float h); /* temporary helper functions (from old RGroup api) */ float GetScale(); V2F32 ViewPosToScreenPos(V2F32 view_pos); V2F32 ViewSizeToScreenSize(V2F32 view_size); ImVec2 ViewPosToScreenPosImGui(V2F32 view_pos); ImVec2 ViewSizeToScreenSizeImGui(V2F32 view_size); // Todo: make this private public: int32_t m_screen_w; int32_t m_screen_h; float m_camera_w; float m_camera_h; Color m_clear_color {}; std::vector m_render_entities; std::vector m_sort_entries; std::unique_ptr m_backend; friend class RSoftwareBackend; };