GC3Denum WebGLFramebuffer::checkStatus() const { unsigned int count = 0; GC3Dsizei width = 0, height = 0; if (isDepthAttached()) { if (!isAttachmentComplete(m_depthAttachment.get(), GraphicsContext3D::DEPTH_ATTACHMENT)) return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT; width = getImageWidth(m_depthAttachment.get()); height = getImageHeight(m_depthAttachment.get()); count++; } if (isStencilAttached()) { if (!isAttachmentComplete(m_stencilAttachment.get(), GraphicsContext3D::STENCIL_ATTACHMENT)) return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT; if (!count) { width = getImageWidth(m_stencilAttachment.get()); height = getImageHeight(m_stencilAttachment.get()); } else { if (width != getImageWidth(m_stencilAttachment.get()) || height != getImageHeight(m_stencilAttachment.get())) return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_DIMENSIONS; } count++; } if (isDepthStencilAttached()) { if (!isAttachmentComplete(m_depthStencilAttachment.get(), GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT)) return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT; if (!isValidRenderbuffer(m_depthStencilAttachment.get())) return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED; if (!count) { width = getImageWidth(m_depthStencilAttachment.get()); height = getImageHeight(m_depthStencilAttachment.get()); } else { if (width != getImageWidth(m_depthStencilAttachment.get()) || height != getImageHeight(m_depthStencilAttachment.get())) return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_DIMENSIONS; } count++; } // WebGL specific: no conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments. if (count > 1) return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED; if (isColorAttached()) { // FIXME: if color buffer is texture, is ALPHA, LUMINANCE or LUMINANCE_ALPHA valid? if (!getColorBufferFormat()) return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT; if (!count) { if (!getColorBufferWidth() || !getColorBufferHeight()) return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT; } else { if (width != getColorBufferWidth() || height != getColorBufferHeight()) return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_DIMENSIONS; } } else { if (!count) return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; } return GraphicsContext3D::FRAMEBUFFER_COMPLETE; }
bool WebGLFramebuffer::isIncomplete(bool checkInternalFormat) const { unsigned int count = 0; if (isDepthAttached()) { if (checkInternalFormat && getInternalFormat(m_depthAttachment.get()) != GraphicsContext3D::DEPTH_COMPONENT16) return true; count++; } if (isStencilAttached()) { if (checkInternalFormat && getInternalFormat(m_stencilAttachment.get()) != GraphicsContext3D::STENCIL_INDEX8) return true; count++; } if (isDepthStencilAttached()) { if (checkInternalFormat && getInternalFormat(m_depthStencilAttachment.get()) != GraphicsContext3D::DEPTH_STENCIL) return true; if (!isValid(m_depthStencilAttachment.get())) return true; count++; } if (count > 1) return true; return false; }