bool WebGLFramebuffer::ValidateForRead(const char* funcName, const webgl::FormatUsageInfo** const out_format, uint32_t* const out_width, uint32_t* const out_height) { if (!CheckAndInitializeAttachments()) { mContext->ErrorInvalidFramebufferOperation("%s: Incomplete framebuffer.", funcName); return false; } if (mReadBufferMode == LOCAL_GL_NONE) { mContext->ErrorInvalidOperation("%s: Read buffer mode must not be" " NONE.", funcName); return false; } const auto attachPoint = GetAttachPoint(mReadBufferMode); if (!attachPoint || !attachPoint->IsDefined()) { mContext->ErrorInvalidOperation("%s: The attachment specified for reading is" " null.", funcName); return false; } *out_format = attachPoint->Format(); attachPoint->Size(out_width, out_height); return true; }
bool WebGLFramebuffer::ValidateForRead(const char* info, TexInternalFormat* const out_format) { if (mReadBufferMode == LOCAL_GL_NONE) { mContext->ErrorInvalidOperation("%s: Read buffer mode must not be" " NONE.", info); return false; } const auto& attachPoint = GetAttachPoint(mReadBufferMode); if (!CheckAndInitializeAttachments()) { mContext->ErrorInvalidFramebufferOperation("readPixels: incomplete framebuffer"); return false; } GLenum readPlaneBits = LOCAL_GL_COLOR_BUFFER_BIT; if (!HasCompletePlanes(readPlaneBits)) { mContext->ErrorInvalidOperation("readPixels: Read source attachment doesn't have the" " correct color/depth/stencil type."); return false; } if (!attachPoint.IsDefined()) { mContext->ErrorInvalidOperation("readPixels: "); return false; } *out_format = attachPoint.EffectiveInternalFormat(); return true; }