Vertices are created at initialization once and then only used. All render functions inside paint do the following:
void PlanPositionIndicator::render(QGLShaderProgram* shaderProgram)
{
// qDebug() << vertices.size();
shaderProgram->setAttributeArray("vertex", vertices.constData());
shaderProgram->enableAttributeArray("vertex");
shaderProgram->setAttributeArray("color", GL_FLOAT,colors,1);
// shaderProgram->setAttributeArray("color", GL_FLOAT,colors.data(),1);
shaderProgram->enableAttributeArray("color");
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDrawArrays(GL_TRIANGLES, 0, vertices.size());
}
void PlanPositionIndicator::render(QGLShaderProgram* shaderProgram)
{
// qDebug() << vertices.size();
shaderProgram->setAttributeArray("vertex", vertices.constData());
shaderProgram->enableAttributeArray("vertex");
shaderProgram->setAttributeArray("color", GL_FLOAT,colors,1);
// shaderProgram->setAttributeArray("color", GL_FLOAT,colors.data(),1);
shaderProgram->enableAttributeArray("color");
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDrawArrays(GL_TRIANGLES, 0, vertices.size());
}
To copy to clipboard, switch view to plain text mode
Bookmarks