#pragma once #include "GLExtensions.h" #include "ShaderTypes.h" #include "TemporalHistoryBuffers.h" #include #include #include #include #include class OpenGLRenderer { public: struct LayerProgram { struct TextureBinding { std::string samplerName; std::filesystem::path sourcePath; GLuint texture = 0; }; struct TextBinding { std::string parameterId; std::string samplerName; std::string fontId; GLuint texture = 0; std::string renderedText; unsigned renderedWidth = 0; unsigned renderedHeight = 0; }; std::string layerId; std::string shaderId; GLuint shaderTextureBase = 0; GLuint program = 0; GLuint vertexShader = 0; GLuint fragmentShader = 0; std::vector textureBindings; std::vector textBindings; }; bool FastTransferAvailable() const { return mFastTransferExtensionAvailable; } void SetFastTransferAvailable(bool available) { mFastTransferExtensionAvailable = available; } GLuint CaptureTexture() const { return mCaptureTexture; } GLuint DecodedTexture() const { return mDecodedTexture; } GLuint LayerTempTexture() const { return mLayerTempTexture; } GLuint CompositeTexture() const { return mFBOTexture; } GLuint OutputTexture() const { return mOutputTexture; } GLuint UnpinnedTextureBuffer() const { return mUnpinnedTextureBuffer; } GLuint DecodeFramebuffer() const { return mDecodeFrameBuf; } GLuint LayerTempFramebuffer() const { return mLayerTempFrameBuf; } GLuint CompositeFramebuffer() const { return mIdFrameBuf; } GLuint OutputFramebuffer() const { return mOutputFrameBuf; } GLuint FullscreenVertexArray() const { return mFullscreenVAO; } GLuint GlobalParamsUBO() const { return mGlobalParamsUBO; } GLuint DecodeProgram() const { return mDecodeProgram; } GLsizeiptr GlobalParamsUBOSize() const { return mGlobalParamsUBOSize; } void SetGlobalParamsUBOSize(GLsizeiptr size) { mGlobalParamsUBOSize = size; } void ReplaceLayerPrograms(std::vector& newPrograms) { mLayerPrograms.swap(newPrograms); } std::vector& LayerPrograms() { return mLayerPrograms; } const std::vector& LayerPrograms() const { return mLayerPrograms; } TemporalHistoryBuffers& TemporalHistory() { return mTemporalHistory; } const TemporalHistoryBuffers& TemporalHistory() const { return mTemporalHistory; } void SetDecodeShaderProgram(GLuint program, GLuint vertexShader, GLuint fragmentShader); bool InitializeResources(unsigned inputFrameWidth, unsigned inputFrameHeight, unsigned outputFrameWidth, unsigned outputFrameHeight, std::string& error); void ResizeView(int width, int height); void PresentToWindow(HDC hdc, unsigned outputFrameWidth, unsigned outputFrameHeight); void DestroyResources(); void DestroySingleLayerProgram(LayerProgram& layerProgram); void DestroyLayerPrograms(); void DestroyDecodeShaderProgram(); private: bool mFastTransferExtensionAvailable = false; GLuint mCaptureTexture = 0; GLuint mDecodedTexture = 0; GLuint mLayerTempTexture = 0; GLuint mFBOTexture = 0; GLuint mOutputTexture = 0; GLuint mUnpinnedTextureBuffer = 0; GLuint mDecodeFrameBuf = 0; GLuint mLayerTempFrameBuf = 0; GLuint mIdFrameBuf = 0; GLuint mOutputFrameBuf = 0; GLuint mIdColorBuf = 0; GLuint mIdDepthBuf = 0; GLuint mFullscreenVAO = 0; GLuint mGlobalParamsUBO = 0; GLuint mDecodeProgram = 0; GLuint mDecodeVertexShader = 0; GLuint mDecodeFragmentShader = 0; GLsizeiptr mGlobalParamsUBOSize = 0; int mViewWidth = 0; int mViewHeight = 0; std::vector mLayerPrograms; TemporalHistoryBuffers mTemporalHistory; };