Details
Description
In Qt3D, if we attach a QGLMaterial to a QGLSceneNode like this
m_material = new QGLMaterial;
m_node->setMaterial(m_material);
m_node->setEffect(QGL::LitDecalTexture2D);
and then update the texture like this
QGLTexture2D *texture = new QGLTexture2D; texture->setImage(image); m_material->setTexture(texture); update(); // paintGL() calls m_node->draw(...)
then the texture is updated on the displayed 3D object.
We can do the same using QtQuick3D by creating an Item3D in QML
Cube { effect: Effect { } }
and then providing the cube's QDeclarativeItem3D to C++ code, which creates a QGLMaterial and updates the texture:
void SomeClass::setItem(QDeclarativeItem3D *item) { m_item = item; m_material = new QGLMaterial; m_item->effect()->setMaterial(m_material); } void SomeClass::updateTexture() { QGLTexture2D *texture = new QGLTexture2D; texture->setImage(image); m_material->setTexture(texture); m_item->update(); }
However, in this case the texture shown on the item is not updated.
This is demonstrated in the two attached applications, widget.tar.gz and quick.tar.gz.