By setting a null vbo and draw 4 vertices (1 particle), you're basically telling the api "draw 4 vertices of nothing" (aka iterate the vertex shader 4 times with no vertex data) but the vertex shader can fetch data from a different location (the ubo) with the help of gl_vertexid to determine the index in the ubo and the vertex position to generate.
I hope I can explain this well enough, so please bear with me and let me know if this doesn't makes sense.
Now regardless of VBO or UBO use, does that mean I need to "double up" on my XY positions since the
vertex shader is run 4 times per quad i.g:
//Example contents of my buffer for 2 quads
const int FLOATS_PER_QUAD = 8; // 4 vertex * 2 (x, y positions)
int maxParticles = 2;
GLfloat *vertex = new GLfloat[maxParticles * FLOATS_PER_QUAD];
//Quad 1 at position 50x50
vertex[0] = 50.0f; //X pos
vertex[1] = 50.0f; //Y pos
vertex[2] = 50.0f;
vertex[3] = 50.0f;
vertex[4] = 50.0f;
vertex[5] = 50.0f;
vertex[6] = 50.0f;
vertex[7] = 50.0f;
//Quad 2 at position 25x40
vertex[8] = 25.0f; //X pos
vertex[9] = 40.0f; //Y pos
vertex[10] = 25.0f;
vertex[11] = 40.0f;
vertex[12] = 25.0f;
vertex[13] = 40.0f;
vertex[14] = 25.0f;
vertex[15] = 40.0f;
I hope the above is not the case, because that seems silly to have repeat the same data over and over.
When really this should be enough:
//The contents of my buffer for 2 quads
const int POSITION_COMP_COUNT = 2; // For XY position
int maxParticles = 2;
GLfloat *vertex = new GLfloat[maxParticles * POSITION_COMP_COUNT];
//Quad 1 at position 50x50
vertex[0] = 50.0f; //X pos
vertex[1] = 50.0f; //Y pos
//Quad 2 at position 25x40
vertex[3] = 25.0f; //X pos
vertex[4] = 40.0f; //Y pos
But I am unsure. How do you tell a shader "do not continue onto the next positions set, until you have ran 4 times"?
Is this solved with the use of a UBO (I ask cause I have never used one)?
I know there is glVertexAttribDivisor for VBOs, which will say only consider the attribute X times for a instance.
But with that being said I beleive this will only work with DrawInstanced calls, which is what we are trying to avoid.