// // Created by Swung 0x48 on 2025/5/6. // #ifndef MOBILEGL_RHI_H #define MOBILEGL_RHI_H #include "../../Includes.h" namespace MG_RHI::GLES { enum class State { None, DrawArrays, DrawElements }; class RHI { public: void TransitionTo(State toState); static inline RHI& GetInstance() { static RHI s_rhi; return s_rhi; } static void CheckError(); void SyncAllTexturesToGLES(TextureState* textureState); void SyncAllBuffersToGLES(BufferState* bufferState); private: State currentState_ = State::None; std::unordered_map textureMap_; std::unordered_map> textureLevelUploaded_; std::unordered_map bufferMap_; std::array lastBoundTextures { 0 }; std::unordered_map vaoMap_; std::unordered_map programMap_; std::unordered_map framebufferMap_; GLuint lastBoundVAO = 0; GLuint lastBoundProgram = 0; GLuint lastBoundFBO = 0; }; } #define MGL_TRY(operation) MG_Util::Debug::LogD("GLES call: %s", #operation); operation MG_RHI::GLES::RHI::CheckError(); #endif //MOBILEGL_RHI_H