I have been attempting to get a double VBO system going. To my understanding it is nothing really special just create 2 VBOs and then fill them up right? So that is what I have done, but I have no performance gain or performance decrease according to my DT times.
It does not matter how many buffers I use (keeping one VBO or having 2 at the ready) my DT times are roughly the same.
Both with single and double VBOs it sits around .0024 seconds.
Surely, I would think that my DT time would be better with a double VBO assuming I did it right or worse if it was done wrong. But them being the same? It has to be wrong, right?
Here is the code I got, let me know if more info I needed. I am rendering 100000 32x32 quads
public void render()
{
//Clear the current buffer
vertexBuffer[buffer].clear();
//Set up a new random for the positions
int x = 0; int y = 0;
Random random = new Random();
//X and Ys for the Quad; The Z is set to 1.0f; Remember 100000 quads
for(int i = 0; i < MAX_QUADS; i++)
{
x = random.nextInt(800);
y = random.nextInt(600);
draw(x, y, 32.0f, 32.0f);
}
//Flip the current buffer
vertexBuffer[buffer].flip();
//Use the shader program
glUseProgram(shaderProgramHandle);
//Bind the current buffer and send it off to queue up in the GPU
glBindBuffer(GL_ARRAY_BUFFER, vertexBufferHandle);
glBufferData(GL_ARRAY_BUFFER, vertexBuffer[buffer], GL_STREAM_DRAW);
//Get the Uniform for the MVP shader
glUniformMatrix4(matrixBufferHandle, false, mvpBuffer);
//Enable the VAO and its attributes
glBindVertexArray(vertexArrayHandle);
GL11.glDrawElements(GL_TRIANGLES, indexDrawCount, GL11.GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
buffer = 1 - buffer;
}
//Put in here just in case
private void createBuffers()
{
//Create the Vertex Buffers
vertexBuffer = new FloatBuffer[2];
vertexBuffer[0] = BufferUtils.createFloatBuffer(MAX_VERTEX_COUNT);
vertexBuffer[1] = BufferUtils.createFloatBuffer(MAX_VERTEX_COUNT);
//Index Buffer used
indexBuffer = BufferUtils.createIntBuffer(MAX_INDEX_COUNT);
}
Other things to mention I’m using one VAO, one Vertex Buffer Handle, and a Index buffer handle like so
//Init the VAO for the buffers, the Vertex Buffers will be Identical
private void initializeVAO()
{
//Bind the VAO
glBindVertexArray(vertexArrayHandle);
//Bind the Vertex Buffer and indicate where the Vertex are
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vertexBufferHandle);
glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0);
//Bind the Index Buffer
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBufferHandle);
glBindVertexArray(0);
}