Sunday, February 9, 2020

opengl - How does a general Renderer::drawRect(0, 0, 100, 100) handle VBO's?


Lots of game engines and GUI systems have a general Renderer class with functions like:


renderer.drawRect(0, 0, 100, 100);
renderer.drawText(204, 452, "Hello, world!");

I understand how this could easily be done in old immediate-mode OpenGL 2.1, but now that VBO's are the norm, could someone explain how these renderers work internally? They surely aren't creating and deleting a VBO quad everytime drawRect() is called, right?



Keeping one VBO and updating the vertex data is out of the question, as it would be cool to set a different shader, texture or colour in between the drawRect() calls.


Is instancing a (0, 0, 1, 1) rect and then scaling up the way to go?


Any pointers?




No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...