mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-09 04:38:30 +09:00
[Feat] (MG_Backend/DirectGLES): hook up glDrawBuffers
This commit is contained in:
@@ -423,6 +423,23 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
if (stateFBOObject->DrawBuffersIsDirty()) {
|
||||
static GLenum drawbufs[MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS];
|
||||
std::fill(drawbufs, drawbufs + MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS, GL_NONE);
|
||||
auto& stateDrawBuffers = stateFBOObject->GetDrawBuffers();
|
||||
GLint i = 0;
|
||||
for (; i < stateDrawBuffers.size(); ++i) {
|
||||
if (stateDrawBuffers[i] == FramebufferAttachmentType::None) {
|
||||
break;
|
||||
}
|
||||
drawbufs[i] = MG_Util::ConvertFramebufferAttachmentTypeToGLEnum(stateDrawBuffers[i]);
|
||||
}
|
||||
|
||||
MG_External::GLES::glDrawBuffers(i, drawbufs);
|
||||
|
||||
stateFBOObject->ClearDrawBuffersDirtyState();
|
||||
}
|
||||
}
|
||||
|
||||
UnorderedMap<SharedPtr<MG_State::GLState::FramebufferObject>, SharedPtr<BackendFramebufferObject>>
|
||||
|
||||
@@ -72,18 +72,18 @@ namespace MobileGL {
|
||||
void FramebufferObject::AttachTexture(FramebufferAttachmentType type, SharedPtr<ITextureObject> texture,
|
||||
int level) {
|
||||
m_attachments[static_cast<SizeT>(type)] = FramebufferAttachment(std::move(texture), level);
|
||||
m_drawBuffersDirty = true;
|
||||
// m_drawBuffersDirty = true;
|
||||
}
|
||||
|
||||
void FramebufferObject::AttachRenderbuffer(FramebufferAttachmentType type,
|
||||
std::shared_ptr<RenderbufferObjectStub> renderbuffer) {
|
||||
m_attachments[static_cast<SizeT>(type)] = FramebufferAttachment(renderbuffer);
|
||||
m_drawBuffersDirty = true;
|
||||
// m_drawBuffersDirty = true;
|
||||
}
|
||||
|
||||
void FramebufferObject::Detach(FramebufferAttachmentType type) {
|
||||
m_attachments[static_cast<SizeT>(type)] = FramebufferAttachment(false);
|
||||
m_drawBuffersDirty = true;
|
||||
// m_drawBuffersDirty = true;
|
||||
}
|
||||
|
||||
const FramebufferAttachment& FramebufferObject::GetAttachment(FramebufferAttachmentType type) const {
|
||||
@@ -143,7 +143,7 @@ namespace MobileGL {
|
||||
//
|
||||
// }
|
||||
|
||||
const auto& FramebufferObject::GetDrawBuffers() const {
|
||||
const Array<FramebufferAttachmentType, FramebufferObject::MAX_DRAW_BUFFERS>& FramebufferObject::GetDrawBuffers() const {
|
||||
return m_drawBuffers;
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,9 @@ namespace MobileGL {
|
||||
Bool CheckCompleteness() const;
|
||||
// void SetDrawBuffers(const Vector<FramebufferAttachmentType>& buffers);
|
||||
void SetDrawBuffer(Uint index, FramebufferAttachmentType buffer);
|
||||
const auto& GetDrawBuffers() const;
|
||||
bool DrawBuffersIsDirty() const { return m_drawBuffersDirty; }
|
||||
void ClearDrawBuffersDirtyState() { m_drawBuffersDirty = false; }
|
||||
const Array<FramebufferAttachmentType, MAX_DRAW_BUFFERS>& GetDrawBuffers() const;
|
||||
Uint GetExternalIndex() const;
|
||||
|
||||
private:
|
||||
@@ -113,7 +115,7 @@ namespace MobileGL {
|
||||
Array<FramebufferAttachment,
|
||||
static_cast<SizeT>(FramebufferAttachmentType::FramebufferAttachmentTypeCount)>
|
||||
m_attachments;
|
||||
Bool m_drawBuffersDirty = true;
|
||||
Bool m_drawBuffersDirty = false;
|
||||
Array<FramebufferAttachmentType, MAX_DRAW_BUFFERS> m_drawBuffers;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user