Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the modern OpenGL equivalent to glBegin/glEnd

I'm building a graphics API for OpenGL, which is based off the basic call-to-draw graphics style. Basically, instead of storing the data into the GPU, and call it using it's handle, give the info to draw what it should be drawing each update. I know it's slow, but it's simple and it's for non-performance critical applications. Anyway, is there any modern equivalent to glBegin/glEnd? It doesn't have to a call for every vertex, but a way where I can send the data each update, without storing the vertices in the gpu?

like image 567
user2896590 Avatar asked Jan 13 '23 01:01

user2896590


1 Answers

You pretty much answered your own question.

is there any modern equivalent to glBegin/glEnd? It doesn't have to a call for every vertex, but a way where I can send the data each update, without storing the vertices in the gpu?

Basically no, the modern way is to use VAOs with VBOs (and IBOs).

If you're going to change the data within the VBO, then remember that you can change the mode parameter in glBufferData.

  • GL_STREAM_DRAW - The data store contents will be modified once and used at most a few times.

  • GL_STATIC_DRAW - The data store contents will be modified once and used many times.

  • GL_DYNAMIC_DRAW - The data store contents will be modified repeatedly and used many times.

Then instead of using GL_STATIC_DRAW, then use GL_DYNAMIC_DRAW this will increase the FPS a lot compared to when using GL_STATIC_DRAW, though this depends on the amount of data, and how frequent you change it. But try to limit it as much as you can, like don't update the data within the buffers if you don't actually need to.

You can read more about the different buffers on the OpenGL Wiki.

like image 130
vallentin Avatar answered Jan 18 '23 23:01

vallentin