glDrawElements(GL_TRIANGLES, vertices.size(), GL_FLOAT, vertices.constData());
glDrawElements(GL_TRIANGLES, vertices.size(), GL_FLOAT, vertices.constData());
To copy to clipboard, switch view to plain text mode
but does not render anything on the screen.
shaderProgram->setAttributeBuffer(vertexLocation, GL_FLOAT , 0, 3, 0);
shaderProgram->setAttributeBuffer(colorLocation , GL_FLOAT , 0, 1, 0);
shaderProgram->setAttributeBuffer(vertexLocation, GL_FLOAT , 0, 3, 0);
shaderProgram->setAttributeBuffer(colorLocation , GL_FLOAT , 0, 1, 0);
To copy to clipboard, switch view to plain text mode
if(!initialized)
{
GLuint vertexId = shaderProgram->attributeLocation("vertex");
GLuint colorId = shaderProgram->attributeLocation("color");
glGenBuffers(2, VBO_ID);
glGenVertexArrays(1, &VAO_ID);
glBindVertexArray(VAO_ID);
glBindBuffer(GL_ARRAY_BUFFER, VBO_ID[0]);
glBufferData(GL_ARRAY_BUFFER, sizeof(QVector3D)*vertices.size(), vertices.constData(), GL_STATIC_DRAW);
glVertexAttribPointer(vertexId, 3, GL_FLOAT, GL_FALSE, 0, 0);// param - 1 ->0
glEnableVertexAttribArray(vertexId);
glBindBuffer(GL_ARRAY_BUFFER, VBO_ID[1]);
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*vertices.size(), colors, GL_DYNAMIC_DRAW);
glVertexAttribPointer(colorId, 1, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(colorId);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
glBindVertexArray(VAO_ID);
int vertexLocation = shaderProgram->attributeLocation("vertex");
int colorLocation = shaderProgram->attributeLocation("color");
shaderProgram->enableAttributeArray(vertexLocation);
shaderProgram->enableAttributeArray(colorLocation);
shaderProgram->setAttributeBuffer(vertexLocation, GL_FLOAT , 0, 3, 0);
shaderProgram->setAttributeBuffer(colorLocation , GL_FLOAT , 0, 1, 0);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDrawArrays(GL_TRIANGLES, 0, numVerts);
if(!initialized)
{
GLuint vertexId = shaderProgram->attributeLocation("vertex");
GLuint colorId = shaderProgram->attributeLocation("color");
glGenBuffers(2, VBO_ID);
glGenVertexArrays(1, &VAO_ID);
glBindVertexArray(VAO_ID);
glBindBuffer(GL_ARRAY_BUFFER, VBO_ID[0]);
glBufferData(GL_ARRAY_BUFFER, sizeof(QVector3D)*vertices.size(), vertices.constData(), GL_STATIC_DRAW);
glVertexAttribPointer(vertexId, 3, GL_FLOAT, GL_FALSE, 0, 0);// param - 1 ->0
glEnableVertexAttribArray(vertexId);
glBindBuffer(GL_ARRAY_BUFFER, VBO_ID[1]);
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*vertices.size(), colors, GL_DYNAMIC_DRAW);
glVertexAttribPointer(colorId, 1, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(colorId);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
glBindVertexArray(VAO_ID);
int vertexLocation = shaderProgram->attributeLocation("vertex");
int colorLocation = shaderProgram->attributeLocation("color");
shaderProgram->enableAttributeArray(vertexLocation);
shaderProgram->enableAttributeArray(colorLocation);
shaderProgram->setAttributeBuffer(vertexLocation, GL_FLOAT , 0, 3, 0);
shaderProgram->setAttributeBuffer(colorLocation , GL_FLOAT , 0, 1, 0);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDrawArrays(GL_TRIANGLES, 0, numVerts);
To copy to clipboard, switch view to plain text mode
Bookmarks