C++ Qt3D纹理参数

C++ Qt3D纹理参数,c++,qt3d,C++,Qt3d,我正在使用Qt3D(5.11),当我试图设置一个QParameter值以供自定义片段着色器使用时,我遇到了断言。下面是代码中似乎不起作用的部分: auto entity = new Qt3DRender::QEntity( mRootEntity ); auto material = new Qt3DRender::QMaterial( entity ); // Set up the custom geometry and material for the entity, which work

我正在使用Qt3D(5.11),当我试图设置一个
QParameter
值以供自定义片段着色器使用时,我遇到了断言。下面是代码中似乎不起作用的部分:

auto entity = new Qt3DRender::QEntity( mRootEntity );
auto material = new Qt3DRender::QMaterial( entity );

// Set up the custom geometry and material for the entity, which works
// fine in tests as long as the fragment shader does not use texture mapping

auto image = new Qt3DRender::QTextureImage( entity );
image->setSource( QString( "qrc:/image.png" ) );

auto texture = new Qt3DRender::QTexture2D( entity );
texture->addTextureImage( image );

material->addParameter( new QParameter( "imageTexture", texture, entity ) );
我只包含了这个问题所需的一些代码:

这是设置简单纹理参数的有效方法吗?如果没有,设置一个简单的图像会缺少什么

请注意,
qrc:/image.png
是一个256x256图像,我在本项目的其他地方使用过它,没有任何问题

代码编译得很好,但当我运行它时,我得到一个带有以下消息的断言:
assert:texture,在文件texture\textureimage.cpp的第94行


我在Windows 10上使用带Qt 5.11的VS2017。

我偶然发现了这个问题。将
QTextureImage
作为
实体的子对象将导致断言。完全不使用父对象(有效地将其设置为
nullptr
)或将其设置为
texture
可以解决此问题

以下是一些工作代码:

auto texture = new Qt3DRender::QTexture2D( entity );
auto image = new Qt3DRender::QTextureImage( texture );
image->setSource( QString( "qrc:/image.png" ) );
texture->addTextureImage( image );

material->addParameter( new QParameter( "imageTexture", texture, entity ) );
这可能是个bug?如果有人知道为什么不能将
QTextureImage
安全地作为
实体的父对象,请添加注释