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?

501 - not implemented
  • 2,638
  • 4
  • 39
  • 74

1 Answers1

2

I really recommend you use OpenGL directly. It will be much more obvious how much each operation costs you.

Here it's likely that Qt changes a Uniform and calls DrawArrays each time it renders with a different material, while the correct way to do this is to make the color a vertex attribute and put all your geometry into the same VAO. Perhaps it's possible to achieve with Qt, but I don't know how.

Yakov Galka
  • 70,775
  • 16
  • 139
  • 220