本文整理汇总了C++中WebGLAttachment::setInitialized方法的典型用法代码示例。如果您正苦于以下问题:C++ WebGLAttachment::setInitialized方法的具体用法?C++ WebGLAttachment::setInitialized怎么用?C++ WebGLAttachment::setInitialized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebGLAttachment
的用法示例。
在下文中一共展示了WebGLAttachment::setInitialized方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initializeAttachments
bool WebGLFramebuffer::initializeAttachments(GraphicsContext3D* g3d, const char** reason)
{
ASSERT(object());
GC3Dbitfield mask = 0;
for (AttachmentMap::iterator it = m_attachments.begin(); it != m_attachments.end(); ++it) {
GC3Denum attachmentType = it->key;
WebGLAttachment* attachment = it->value.get();
if (!attachment->isInitialized())
mask |= GraphicsContext3D::getClearBitsByAttachmentType(attachmentType);
}
if (!mask)
return true;
// We only clear un-initialized renderbuffers when they are ready to be
// read, i.e., when the framebuffer is complete.
if (g3d->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {
*reason = "framebuffer not complete";
return false;
}
bool initColor = mask & GraphicsContext3D::COLOR_BUFFER_BIT;
bool initDepth = mask & GraphicsContext3D::DEPTH_BUFFER_BIT;
bool initStencil = mask & GraphicsContext3D::STENCIL_BUFFER_BIT;
GC3Dfloat colorClearValue[] = {0, 0, 0, 0}, depthClearValue = 0;
GC3Dint stencilClearValue = 0;
GC3Dboolean colorMask[] = {0, 0, 0, 0}, depthMask = 0;
GC3Duint stencilMask = 0xffffffff;
GC3Dboolean isScissorEnabled = 0;
GC3Dboolean isDitherEnabled = 0;
if (initColor) {
g3d->getFloatv(GraphicsContext3D::COLOR_CLEAR_VALUE, colorClearValue);
g3d->getBooleanv(GraphicsContext3D::COLOR_WRITEMASK, colorMask);
g3d->clearColor(0, 0, 0, 0);
g3d->colorMask(true, true, true, true);
}
if (initDepth) {
g3d->getFloatv(GraphicsContext3D::DEPTH_CLEAR_VALUE, &depthClearValue);
g3d->getBooleanv(GraphicsContext3D::DEPTH_WRITEMASK, &depthMask);
g3d->clearDepth(1.0f);
g3d->depthMask(true);
}
if (initStencil) {
g3d->getIntegerv(GraphicsContext3D::STENCIL_CLEAR_VALUE, &stencilClearValue);
g3d->getIntegerv(GraphicsContext3D::STENCIL_WRITEMASK, reinterpret_cast<GC3Dint*>(&stencilMask));
g3d->clearStencil(0);
g3d->stencilMask(0xffffffff);
}
isScissorEnabled = g3d->isEnabled(GraphicsContext3D::SCISSOR_TEST);
g3d->disable(GraphicsContext3D::SCISSOR_TEST);
isDitherEnabled = g3d->isEnabled(GraphicsContext3D::DITHER);
g3d->disable(GraphicsContext3D::DITHER);
g3d->clear(mask);
if (initColor) {
g3d->clearColor(colorClearValue[0], colorClearValue[1], colorClearValue[2], colorClearValue[3]);
g3d->colorMask(colorMask[0], colorMask[1], colorMask[2], colorMask[3]);
}
if (initDepth) {
g3d->clearDepth(depthClearValue);
g3d->depthMask(depthMask);
}
if (initStencil) {
g3d->clearStencil(stencilClearValue);
g3d->stencilMask(stencilMask);
}
if (isScissorEnabled)
g3d->enable(GraphicsContext3D::SCISSOR_TEST);
else
g3d->disable(GraphicsContext3D::SCISSOR_TEST);
if (isDitherEnabled)
g3d->enable(GraphicsContext3D::DITHER);
else
g3d->disable(GraphicsContext3D::DITHER);
for (AttachmentMap::iterator it = m_attachments.begin(); it != m_attachments.end(); ++it) {
GC3Denum attachmentType = it->key;
WebGLAttachment* attachment = it->value.get();
GC3Dbitfield bits = GraphicsContext3D::getClearBitsByAttachmentType(attachmentType);
if (bits & mask)
attachment->setInitialized();
}
return true;
}