Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to choose between GL_STREAM_DRAW or GL_DYNAMIC_DRAW?

Tags:

opengl-es

vbo

I am using OpenGL ES 2.0, but I think it is also relevant to non-ES: how to know what "usage" to choose when creating a VBO?

This particular VBO will be used for 1 to 4 times before completely updated, and I am not sure if I must pick GL_STREAM_DRAW or GL_DYNAMIC_DRAW.

like image 761
lvella Avatar asked Nov 26 '11 21:11

lvella


People also ask

When to use GL_ DYNAMIC_ DRAW?

GL_DYNAMIC_DRAW is used if you are going to change buffer partially, for example with glBufferSubData() .

What is Gl_static_draw?

GL_STATIC_DRAW. The data store contents will be modified once and used many times as the source for GL drawing commands. GL_DYNAMIC_DRAW. The data store contents will be modified repeatedly and used many times as the source for GL drawing commands.

What is glBufferData?

Description. glBufferData creates a new data store for the buffer object currently bound to target . Any pre-existing data store is deleted. The new data store is created with the specified size in bytes and usage . If data is not NULL , the data store is initialized with data from this pointer.


1 Answers

Well, according to the OpenGL API you should use DYNAMIC_DRAW.

STREAM
You should use STREAM_DRAW when the data store contents will be modified once and used at most a few times.

STATIC
Use STATIC_DRAW when the data store contents will be modified once and used many times.

DYNAMIC
Use DYNAMIC_DRAW when the data store contents will be modified repeatedly and used many times.

Make sure to update the VBO with glBufferSubData()

like image 173
murk003 Avatar answered Sep 17 '22 11:09

murk003