[Feat] (MG_State/RenderbufferObject): Better RenderbufferObject.

This commit is contained in:
BZLZHH
2025-12-14 11:17:09 +08:00
parent 100d5bca99
commit 3063374834
2 changed files with 59 additions and 13 deletions
@@ -1,17 +1,11 @@
#include "RenderbufferObject.h"
#include <MG_Util/Metrics/TextureMetrics.h>
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
} // namespace MobileGL
@@ -1,8 +1,10 @@
#pragma once
#include <Includes.h>
#include <MG_Util/Math/VectorTypes.h>
#include <MG_State/GLState/TextureState/TextureEnum.h>
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