Fix macOS mesh on subscenes with clipping masks

This commit is contained in:
manongjohn 2023-10-19 15:44:47 -04:00
parent 6d5f58ce0d
commit f6960a8ceb
2 changed files with 6 additions and 3 deletions

View file

@ -192,15 +192,18 @@ DrawableTextureDataP texture_utils::getTextureData(const TXsheet *xsh,
xsh->getPlacement(xsh->getStageObjectTree()->getCurrentCameraId(), frame); xsh->getPlacement(xsh->getStageObjectTree()->getCurrentCameraId(), frame);
bbox = (cameraAff.inv() * bbox).enlarge(1.0); bbox = (cameraAff.inv() * bbox).enlarge(1.0);
// Render the xsheet on the specified bbox // Render the xsheet on the specified bbox
bool masked = TStencilControl::instance()->isMaskEnabled();
#ifdef MACOSX #ifdef MACOSX
// Must move masks aside when building texture
if (masked) TStencilControl::instance()->stashMask();
xsh->getScene()->renderFrame(tex, frame, xsh, bbox, TAffine()); xsh->getScene()->renderFrame(tex, frame, xsh, bbox, TAffine());
if (masked) TStencilControl::instance()->restoreMask();
#else #else
// The call below will change context (I know, it's a shame :( ) // The call below will change context (I know, it's a shame :( )
TGlContext currentContext = tglGetCurrentContext(); TGlContext currentContext = tglGetCurrentContext();
{ {
tglDoneCurrent(currentContext); tglDoneCurrent(currentContext);
bool masked = TStencilControl::instance()->isMaskEnabled();
// Must move masks aside when building texture // Must move masks aside when building texture
if (masked) TStencilControl::instance()->stashMask(); if (masked) TStencilControl::instance()->stashMask();
xsh->getScene()->renderFrame(tex, frame, xsh, bbox, TAffine()); xsh->getScene()->renderFrame(tex, frame, xsh, bbox, TAffine());

View file

@ -812,7 +812,7 @@ void ToonzScene::renderFrame(const TRaster32P &ras, int row, const TXsheet *xsh,
#ifdef MACOSX #ifdef MACOSX
std::unique_ptr<QOpenGLFramebufferObject> fb( std::unique_ptr<QOpenGLFramebufferObject> fb(
new QOpenGLFramebufferObject(ras->getLx(), ras->getLy())); new QOpenGLFramebufferObject(ras->getLx(), ras->getLy()));
fb->setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
fb->bind(); fb->bind();
assert(glGetError() == GL_NO_ERROR); assert(glGetError() == GL_NO_ERROR);