diff options
Diffstat (limited to 'src/quick3d/imports/scene3d/scene3dsgmaterialshader.cpp')
-rw-r--r-- | src/quick3d/imports/scene3d/scene3dsgmaterialshader.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/quick3d/imports/scene3d/scene3dsgmaterialshader.cpp b/src/quick3d/imports/scene3d/scene3dsgmaterialshader.cpp index 3fab345e1..d25c6a7f7 100644 --- a/src/quick3d/imports/scene3d/scene3dsgmaterialshader.cpp +++ b/src/quick3d/imports/scene3d/scene3dsgmaterialshader.cpp @@ -154,21 +154,23 @@ void Scene3DSGMaterialShader::updateState(const RenderState &state, QSGMaterial QSGTexture *t = tx->texture(); - bool npotSupported = const_cast<QOpenGLContext *>(state.context()) - ->functions()->hasOpenGLFeature(QOpenGLFunctions::NPOTTextureRepeat); - if (!npotSupported) { - QSize size = t->textureSize(); - const bool isNpot = !isPowerOfTwo(size.width()) || !isPowerOfTwo(size.height()); - if (isNpot) { - t->setHorizontalWrapMode(QSGTexture::ClampToEdge); - t->setVerticalWrapMode(QSGTexture::ClampToEdge); + if (t != nullptr) { + bool npotSupported = const_cast<QOpenGLContext *>(state.context()) + ->functions()->hasOpenGLFeature(QOpenGLFunctions::NPOTTextureRepeat); + if (!npotSupported) { + QSize size = t->textureSize(); + const bool isNpot = !isPowerOfTwo(size.width()) || !isPowerOfTwo(size.height()); + if (isNpot) { + t->setHorizontalWrapMode(QSGTexture::ClampToEdge); + t->setVerticalWrapMode(QSGTexture::ClampToEdge); + } } - } - if (oldTx == 0 || oldTx->texture()->textureId() != t->textureId()) - t->bind(); - else - t->updateBindOptions(); + if (oldTx == 0 || oldTx->texture()->textureId() != t->textureId()) + t->bind(); + else + t->updateBindOptions(); + } if (state.isMatrixDirty()) program()->setUniformValue(m_matrixId, state.combinedMatrix()); |