It is currently Sun May 28, 2017 8:57 pm

All times are UTC - 5 hours




 Page 1 of 1 [ 2 posts ] 
Author Message
 Post subject: Shader VMK 19 - Vertex Arrays
PostPosted: Thu Jan 10, 2013 8:01 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
In this vmk we explore vertex arrays which are part of the OpenGL v1.1 spec. By the end of the video you will learn how to store data in arrays and pass them all down to OpenGL in one call.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 19 - Vertex Arrays
PostPosted: Sat Jan 26, 2013 7:29 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
I forgot to go into details in the vmk on the differences in the buffer usage hint you can specify when creating your vertex arrays. Have a read through the OpenGL spec for details but to summarize:

Buffer Usage Hints

The usage parameter allows OpenGL to choose different strategies for storing the buffer depending on how your application intends to use the data. Each call to the glBufferData function provides a usage hint as the last parameter, and passing GL_STATIC_DRAW tells OpenGL that the contents of both buffers are never expected to change. This gives OpenGL more opportunities to optimize how and where the data is stored.

Other use cases:

  • GL_STATIC_DRAW should be used for vertex data that is specified once and never changes. Your application should create the vertex buffer during initialization and use them until they are no longer needed.
  • GL_DYNAMIC_DRAW should be used when data stored in the buffer may change during the rendering loop. Your application should still initialize these buffers during initialization, and update the data as needed by calling the glBufferSubData function.
  • GL_STREAM_DRAW is used when your application needs to create transient geometry that is rendered a small number of times and then discarded. This is most useful when your application must dynamically calculate new vertex data every frame and you perform the calculations inside the shader. Typically, if your application is using stream drawing, you want to create two different buffers; while OpenGL is drawing using the contents of one buffer, your application is filling the other.

If different attributes inside your vertex format require different usage patterns, split the vertex data into multiple structures, and allocate a separate vertex buffer object for each collection of attributes that share common usage characteristics. For example store position and color data in separate buffers. Vertex positions could be stored using GL_STATIC_DRAW and and the color buffer using the GL_DYNAMIC_DRAW hint. Then during run time you can modify the color on the fly and OpenGL will allocate that buffer so that your application maintains reasonable performance.

NOTE: In the example shown in the vmk, I don't actual change any data stored in the vertex array during run time so that is why I use GL_STATIC_DRAW.


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron