void PlanPositionIndicator::render(QGLShaderProgram* shaderProgram)
{
if(!initialized)
{
GLuint vertexId = shaderProgram->attributeLocation("vertex");
GLuint colorId = shaderProgram->attributeLocation("color");
glGenVertexArrays(1, &VAO_ID);
glBindVertexArray(VAO_ID);
glBindBuffer(GL_ARRAY_BUFFER, VBO_ID[0]);
glVertexAttribPointer(vertexId, 2, GL_FLOAT, GL_FALSE, sizeof(vertices), 0);
glBufferData(GL_ARRAY_BUFFER, sizeof(QVector2D)*vertices.size(), vertices.constData(), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, VBO_ID[1]);
glVertexAttribPointer(colorId, 1, GL_FLOAT, GL_FALSE, sizeof(vertices), 0);
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*vertices.size(), colors, GL_STATIC_DRAW);
initialized = 1;
}
glBindBuffer(GL_ARRAY_BUFFER, VAO_ID);
// shaderProgram->setAttributeArray("vertex", vertices.constData());
int vertexLocation = shaderProgram->attributeLocation("vertex");
//shaderProgram->setAttributeArray("color", GL_FLOAT,colors,1);
shaderProgram->enableAttributeArray(vertexLocation);
// glVertexAttribPointer(vertexLocation, 3, GL_FLOAT, GL_FALSE, sizeof(vertices), NULL);
int colorLocation = shaderProgram->attributeLocation("color");
shaderProgram->enableAttributeArray(colorLocation);
// glVertexAttribPointer(colorLocation, 3, GL_FLOAT, GL_FALSE, sizeof(colors), (const char*)(sizeof(float)*3));
// glEnable (GL_BLEND);
// glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDrawArrays(GL_TRIANGLES, 0, numVerts);
}