#pragma once #include #include #include #include #include #include #include #include #include #include #include #include "camera.hh" #include "gameobject.hh" #include "navmesh.hh" namespace psxsplash { class Renderer final { public: Renderer(const Renderer&) = delete; Renderer& operator=(const Renderer&) = delete; // FIXME: I have no idea how to precompute the required sizes of these. It would be best to allocate them based on // the scene static constexpr size_t ORDERING_TABLE_SIZE = 2048 * 3; static constexpr size_t BUMP_ALLOCATOR_SIZE = 8096 * 24; static void Init(psyqo::GPU& gpuInstance); void SetCamera(Camera& camera); void Render(eastl::vector& objects); void RenderNavmeshPreview(psxsplash::Navmesh navmesh, bool isOnMesh); void VramUpload(const uint16_t* imageData, int16_t posX, int16_t posY, int16_t width, int16_t height); static Renderer& GetInstance() { psyqo::Kernel::assert(instance != nullptr, "Access to renderer was tried without prior initialization"); return *instance; } private: static Renderer* instance; Renderer(psyqo::GPU& gpuInstance) : m_gpu(gpuInstance) {} ~Renderer() {} Camera* m_currentCamera; psyqo::GPU& m_gpu; psyqo::Trig<> m_trig; psyqo::OrderingTable m_ots[2]; psyqo::Fragments::SimpleFragment m_clear[2]; psyqo::BumpAllocator m_ballocs[2]; psyqo::Color m_clearcolor = {.r = 0, .g = 0, .b = 0}; void recursiveSubdivideAndRender(Tri& tri, eastl::array& projected, int zIndex, int maxIterations); }; } // namespace psxsplash