#pragma once #include "../runtime/RuntimeLayerModel.h" #include "RuntimeShaderPrepareWorker.h" #include "RuntimeShaderRenderer.h" #include #include #include #include #include class RuntimeRenderScene { public: RuntimeRenderScene() = default; RuntimeRenderScene(const RuntimeRenderScene&) = delete; RuntimeRenderScene& operator=(const RuntimeRenderScene&) = delete; ~RuntimeRenderScene(); bool StartPrepareWorker(std::unique_ptr sharedWindow, std::string& error); bool CommitRenderLayers(const std::vector& layers, std::string& error); bool HasLayers(); void RenderFrame(uint64_t frameIndex, unsigned width, unsigned height); void ShutdownGl(); private: struct LayerProgram { std::string layerId; std::string shaderId; std::string sourceFingerprint; std::string pendingFingerprint; std::unique_ptr renderer; }; void ConsumePreparedPrograms(); bool EnsureLayerTargets(unsigned width, unsigned height); void DestroyLayerTargets(); LayerProgram* FindLayer(const std::string& layerId); const LayerProgram* FindLayer(const std::string& layerId) const; static std::string Fingerprint(const RuntimeShaderArtifact& artifact); RuntimeShaderPrepareWorker mPrepareWorker; std::vector mLayers; std::vector mLayerOrder; GLuint mLayerFramebuffers[2] = {}; GLuint mLayerTextures[2] = {}; unsigned mLayerTargetWidth = 0; unsigned mLayerTargetHeight = 0; };