Is this a good idea using glBufferSubData()?

Hey!

Im wondering if it’s a good idea to modify a buffer like this with glBufferSubData, or is it better maybe using uniforms?

Right now i update the rectVBO with the rectMODS array everytime a press the left mouse button.

My goal is to render quads from some kind of game, maybe and RTS.

So there might be quite a lot of quads including many units, map/terrain objects etc…

	CJE_Rectangle rect1 = 
	{
	       -150.0f,    0.0f,   0.0f,	0.0f, 1.0f, 0.0f, 1.0f,
	       -150.0f,  150.0f,   0.0f,	0.0f, 1.0f, 0.0f, 1.0f,
	       - 50.0f,  150.0f,   0.0f,	0.0f, 1.0f, 0.0f, 1.0f,
	       - 50.0f,    0.0f,   0.0f,	0.0f, 1.0f, 0.0f, 1.0f
	};

	CJE_Rectangle rect2 = 
	{
		 50.0f,     0.0f,   0.0f,	1.0f, 0.0f, 0.0f, 1.0f,
		 50.0f,   450.0f,   0.0f,	1.0f, 0.0f, 0.0f, 1.0f,
		800.0f,   450.0f,   0.0f,	1.0f, 0.0f, 0.0f, 1.0f,
		800.0f,     0.0f,   0.0f,	1.0f, 0.0f, 0.0f, 1.0f
	};


	CJE_Rectangle rectVertices[] = 
	{
		rect1,
		rect2
	}

    // HERE IM CREATING VBO's and VAO's
    //....
    //...
    //...

	float rectMODS[8] = 
	{
		-150.0f,    0.0f,
		-150.0f,  150.0f,
		- 50.0f,  150.0f,
		- 50.0f,    0.0f,
	};


	while(!glfwWindowShouldClose(window) && running) 
	{
		checkInput(window);

		glClearColor(0.0f, 0.2f, 0.3f, 1.0f);
		glClear(GL_COLOR_BUFFER_BIT);

		if(keyPressed[LEFT_MOUSE_BUTTON])
		{
			glBindBuffer(GL_ARRAY_BUFFER, rectVBO);
			for(int i = 0; i < sizeof(float) * 8; i++)
			{
				rectMODS[i] += 1.0f;
			}
			for(int i = 0; i < 4; i++)
			{
				glBufferSubData(GL_ARRAY_BUFFER, (sizeof(float) * 7 * i), sizeof(float) * 2,  &rectMODS[i * 2]);
			}
		}

If you want to update the vertex data, you’d be better off putting the positions in a separate VBO to the texture coordinates, updating the positions, then either replacing the entire buffer with glBufferData or storing the new data in a separate region of the buffer (buffer object streaming).

Overwriting data which was used by recently-issued commands risks a pipeline stall, where the update has to wait until any pending commands which used the data have completed. glBufferData replaces the entire data store, so it can just “orphan” the previous data store (keep it around until any pending commands have finished using it while making it invisible to the application).

Also:

I’m fairly sure that the sizeof(float) shouldn’t be in there.