mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 14:18:31 +09:00
[Fix] (MG_State/Framebuffer): Correct GL_FRAMEBUFFER target handling and resource management.
This commit is contained in:
@@ -47,7 +47,6 @@ GLenum FramebufferState::Bind(GLenum target, GLuint framebuffer) {
|
|||||||
if (framebuffer != 0 && !ValidateHandle(framebuffer))
|
if (framebuffer != 0 && !ValidateHandle(framebuffer))
|
||||||
return GL_INVALID_OPERATION;
|
return GL_INVALID_OPERATION;
|
||||||
if (target == GL_FRAMEBUFFER) {
|
if (target == GL_FRAMEBUFFER) {
|
||||||
currentBindings_[GL_FRAMEBUFFER] = framebuffer;
|
|
||||||
currentBindings_[GL_READ_FRAMEBUFFER] = framebuffer;
|
currentBindings_[GL_READ_FRAMEBUFFER] = framebuffer;
|
||||||
currentBindings_[GL_DRAW_FRAMEBUFFER] = framebuffer;
|
currentBindings_[GL_DRAW_FRAMEBUFFER] = framebuffer;
|
||||||
} else {
|
} else {
|
||||||
@@ -61,7 +60,23 @@ GLenum FramebufferState::AttachTexture2D(GLenum target, GLenum attachment,
|
|||||||
if (MG_Constants::Framebuffer::VALID_ATTACHMENTS.find(attachment) == MG_Constants::Framebuffer::VALID_ATTACHMENTS.end() ||
|
if (MG_Constants::Framebuffer::VALID_ATTACHMENTS.find(attachment) == MG_Constants::Framebuffer::VALID_ATTACHMENTS.end() ||
|
||||||
MG_Constants::Texture::VALID_TARGETS.find(textarget) == MG_Constants::Texture::VALID_TARGETS.end())
|
MG_Constants::Texture::VALID_TARGETS.find(textarget) == MG_Constants::Texture::VALID_TARGETS.end())
|
||||||
return GL_INVALID_ENUM;
|
return GL_INVALID_ENUM;
|
||||||
// if (target == GL_FRAMEBUFFER) target = GL_DRAW_FRAMEBUFFER;
|
if (target == GL_FRAMEBUFFER) {
|
||||||
|
if (currentBindings_[GL_READ_FRAMEBUFFER] == currentBindings_[GL_DRAW_FRAMEBUFFER]) {
|
||||||
|
target = GL_DRAW_FRAMEBUFFER;
|
||||||
|
} else {
|
||||||
|
if (currentBindings_[GL_READ_FRAMEBUFFER] != 0) {
|
||||||
|
GLenum err = AttachTexture2D(GL_READ_FRAMEBUFFER, attachment, textarget, texture, level);
|
||||||
|
if (err != GL_NO_ERROR)
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
if (currentBindings_[GL_DRAW_FRAMEBUFFER] != 0) {
|
||||||
|
GLenum err = AttachTexture2D(GL_DRAW_FRAMEBUFFER, attachment, textarget, texture, level);
|
||||||
|
if (err != GL_NO_ERROR)
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
return GL_NO_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
FramebufferObject* fbo = GetCurrentFBO(target);
|
FramebufferObject* fbo = GetCurrentFBO(target);
|
||||||
if (!fbo) return GL_INVALID_OPERATION;
|
if (!fbo) return GL_INVALID_OPERATION;
|
||||||
if (texture != 0 && !MG_State_T::textureState->IsTexture(texture))
|
if (texture != 0 && !MG_State_T::textureState->IsTexture(texture))
|
||||||
@@ -86,7 +101,7 @@ GLenum FramebufferState::AttachTexture2D(GLenum target, GLenum attachment,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GLenum FramebufferState::ValidateCompleteness(GLenum target) {
|
GLenum FramebufferState::ValidateCompleteness(GLenum target) {
|
||||||
// if (target == GL_FRAMEBUFFER) target = GL_DRAW_FRAMEBUFFER;
|
if (target == GL_FRAMEBUFFER) target = GL_DRAW_FRAMEBUFFER;
|
||||||
FramebufferObject* fbo = GetCurrentFBO(target);
|
FramebufferObject* fbo = GetCurrentFBO(target);
|
||||||
if (!fbo) return GL_INVALID_OPERATION;
|
if (!fbo) return GL_INVALID_OPERATION;
|
||||||
return fbo->status;
|
return fbo->status;
|
||||||
|
|||||||
Reference in New Issue
Block a user