[Feat] (MG_State/Framebuffer, MG_Impl/Framebuffer): implement glDrawBuffers in the state machine

This commit is contained in:
2025-11-14 15:41:25 +08:00
parent 1f831d79a9
commit 0d3236c3cc
3 changed files with 103 additions and 10 deletions
@@ -63,8 +63,10 @@ namespace MobileGL {
}
// FramebufferObject
FramebufferObject::FramebufferObject(Uint externalIndex) : m_externalIndex(externalIndex) {
FramebufferObject::FramebufferObject(Uint externalIndex) :
m_externalIndex(externalIndex) {
m_attachments.fill(FramebufferAttachment(false));
m_drawBuffers.fill(FramebufferAttachmentType::None);
}
void FramebufferObject::AttachTexture(FramebufferAttachmentType type, SharedPtr<ITextureObject> texture,
@@ -126,12 +128,22 @@ namespace MobileGL {
return true;
}
void FramebufferObject::SetDrawBuffers(const std::vector<FramebufferAttachmentType>& buffers) {
m_drawBuffers = buffers;
void FramebufferObject::SetDrawBuffer(Uint index, FramebufferAttachmentType buffer) {
if (m_drawBuffers[index] == buffer)
return;
m_drawBuffersDirty = true;
m_drawBuffers[index] = buffer;
}
const Vector<FramebufferAttachmentType>& FramebufferObject::GetDrawBuffers() const {
// void FramebufferObject::SetDrawBuffers(const Vector<FramebufferAttachmentType>& buffers) {
// m_drawBuffers = buffers;
// m_drawBuffersDirty = true;
// }
// void SetDrawBuffer(Uint index, FramebufferAttachmentType buffer) {
//
// }
const auto& FramebufferObject::GetDrawBuffers() const {
return m_drawBuffers;
}
@@ -12,6 +12,16 @@ namespace MobileGL {
};
enum class FramebufferAttachmentType {
None,
FrontLeft,
FrontRight,
BackLeft,
BackRight,
Depth,
Stencil,
Color0,
Color1,
Color2,
@@ -44,8 +54,7 @@ namespace MobileGL {
Color29,
Color30,
Color31,
Depth,
Stencil,
FramebufferAttachmentTypeCount,
Unknown = -1
};
@@ -81,6 +90,7 @@ namespace MobileGL {
class FramebufferObject {
public:
using TargetEnum = FramebufferTarget;
static constexpr uint MAX_DRAW_BUFFERS = 8;
FramebufferObject(Uint externalIndex);
@@ -93,8 +103,9 @@ namespace MobileGL {
static_cast<SizeT>(FramebufferAttachmentType::FramebufferAttachmentTypeCount)>&
GetAllAttachments() const;
Bool CheckCompleteness() const;
void SetDrawBuffers(const std::vector<FramebufferAttachmentType>& buffers);
const Vector<FramebufferAttachmentType>& GetDrawBuffers() const;
// void SetDrawBuffers(const Vector<FramebufferAttachmentType>& buffers);
void SetDrawBuffer(Uint index, FramebufferAttachmentType buffer);
const auto& GetDrawBuffers() const;
Uint GetExternalIndex() const;
private:
@@ -103,7 +114,7 @@ namespace MobileGL {
static_cast<SizeT>(FramebufferAttachmentType::FramebufferAttachmentTypeCount)>
m_attachments;
Bool m_drawBuffersDirty = true;
Vector<FramebufferAttachmentType> m_drawBuffers;
Array<FramebufferAttachmentType, MAX_DRAW_BUFFERS> m_drawBuffers;
};
} // namespace GLState