2

in a project I want to render a lot of shapes with different colors. I created the color of the shape with a QGLMaterial and add the shape to the QGLBuilder with this commands:

//Build SceneNode
m_lpBuilder->newSection();
...
m_lpBuilder->currentNode()->setMaterialIndex(idxMaterial); //idx in range of 0 to 1000
m_lpBuilder->currentNode()->setEffect(QGL::LitMaterial);

when I only have a few colors (QGLMaterial) the scene is rendered very fast but with a large kind of colors it is very slow.

is there a way to improve this?

4

1 回答 1

2

我真的建议你直接使用 OpenGL。每项操作的成本将更加明显。

在这里,Qt 很可能会在每次使用不同的材质渲染时更改 Uniform 并调用 DrawArrays,而正确的方法是使颜色成为顶点属性并将所有几何图形放入同一个 VAO。也许用 Qt 可以实现,但我不知道如何。

于 2015-01-11T20:58:45.680 回答