Reputation: 831
Do i need to have separate draw call for each object i would like to render and then swap buffers?
As i understand i have one VBO rendered, then another VBO is bidden and is drawn, and after all that i am swapping buffers to present the back buffer.
for Example //Then Render
float vertices[] = {
-0.5f, -0.5f, 0.0f,
0.5f, -0.5f, 0.0f,
0.0f, 0.5f, 0.0f
};
//Create Vertex Buffer
GLint VBO = 0;
glGenBuffers(1, &VBO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glUseProgram(ShaderProgram);
glDrawArrays(GL_TRIANGLES, 0, 3);
Here i draw a single triangle, how would one go about drawing a second triangle with different shader program
Upvotes: 0
Views: 1778
Reputation: 72
To draw different objects, you need different VBOs and that means a different draw call for every different object. If you want to draw a particular object more than once, you can use instancing or bind and draw the same VBO more than once. You can create one gigantic VBO for all objects but since you are a beginner, stick to one VBO per object for now.
Upvotes: 1