diff --git a/MobileGL/MG_State/GLState/RenderbufferState/RenderbufferObject.cpp b/MobileGL/MG_State/GLState/RenderbufferState/RenderbufferObject.cpp index f97263e6..8bffa718 100644 --- a/MobileGL/MG_State/GLState/RenderbufferState/RenderbufferObject.cpp +++ b/MobileGL/MG_State/GLState/RenderbufferState/RenderbufferObject.cpp @@ -1,17 +1,11 @@ #include "RenderbufferObject.h" +#include namespace MobileGL { namespace MG_State { namespace GLState { RenderbufferObject::RenderbufferObject(Uint externalIndex) : m_externalIndex(externalIndex) {} - void RenderbufferObject::Storage(Int internalFormat, Int width, Int height) { - m_internalFormat = internalFormat; - m_width = width; - m_height = height; - m_allocated = true; - } - Int RenderbufferObject::GetWidth() const { return m_width; } @@ -20,13 +14,52 @@ namespace MobileGL { return m_height; } - Int RenderbufferObject::GetInternalFormat() const { + TextureInternalFormat RenderbufferObject::GetInternalFormat() const { return m_internalFormat; } Bool RenderbufferObject::IsAllocated() const { return m_allocated; } + + Int RenderbufferObject::GetRedSize() const { + return m_componentSizes.Red; + } + + Int RenderbufferObject::GetGreenSize() const { + return m_componentSizes.Green; + } + + Int RenderbufferObject::GetBlueSize() const { + return m_componentSizes.Blue; + } + + Int RenderbufferObject::GetAlphaSize() const { + return m_componentSizes.Alpha; + } + + Int RenderbufferObject::GetDepthSize() const { + return m_componentSizes.Depth; + } + + Int RenderbufferObject::GetStencilSize() const { + return m_componentSizes.Stencil; + } + + const ComponentSizes& RenderbufferObject::GetComponentSizes() const { + return m_componentSizes; + } + + void RenderbufferObject::SetInternalFormat(TextureInternalFormat format) { + m_internalFormat = format; + m_componentSizes = MG_Util::GetComponentSizesForInternalFormat(format); + } + + void RenderbufferObject::AllocateStorage(IntVec2 size) { + m_width = size.x(); + m_height = size.y(); + m_allocated = true; + } } // namespace GLState } // namespace MG_State -} // namespace MobileGL \ No newline at end of file +} // namespace MobileGL diff --git a/MobileGL/MG_State/GLState/RenderbufferState/RenderbufferObject.h b/MobileGL/MG_State/GLState/RenderbufferState/RenderbufferObject.h index 0c49ab44..c82f53cc 100644 --- a/MobileGL/MG_State/GLState/RenderbufferState/RenderbufferObject.h +++ b/MobileGL/MG_State/GLState/RenderbufferState/RenderbufferObject.h @@ -1,8 +1,10 @@ #pragma once #include +#include +#include namespace MobileGL { - enum class RenderbufferTarget { // fucky stuff in GL spec + enum class RenderbufferTarget { Renderbuffer, RenderbufferTargetCount, Unknown = -1 @@ -16,18 +18,29 @@ namespace MobileGL { RenderbufferObject(Uint externalIndex); - void Storage(Int internalFormat, Int width, Int height); + void SetInternalFormat(TextureInternalFormat format); + void AllocateStorage(IntVec2 size); Int GetWidth() const; Int GetHeight() const; - Int GetInternalFormat() const; + TextureInternalFormat GetInternalFormat() const; Bool IsAllocated() const; + const ComponentSizes& GetComponentSizes() const; + Int GetRedSize() const; + Int GetGreenSize() const; + Int GetBlueSize() const; + Int GetAlphaSize() const; + Int GetDepthSize() const; + Int GetStencilSize() const; + Int GetSamples() const; private: Uint m_externalIndex = 0; - Int m_internalFormat = 0; + TextureInternalFormat m_internalFormat; Int m_width = 0; Int m_height = 0; + Int m_samples = 0; // TODO: multisampling support Bool m_allocated = false; + ComponentSizes m_componentSizes; }; } // namespace GLState } // namespace MG_State