1 / 13

Outline

Outline. Display Lists Vertex Arrays Vertex Buffer Objects. Display List. Group of OpenGL commands that have been compiled for later execution  Vertex and pixel data are evaluated and copied into the display list memory

hashim
Download Presentation

Outline

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Outline • Display Lists • Vertex Arrays • Vertex Buffer Objects

  2. Display List • Group of OpenGL commands that have been compiled for later execution •  Vertex and pixel data are evaluated and copied into the display list memory • You can reuse it repeatedly without re-evaluating and re-transmitting data • It reduces CPU cycles to perform the actual data transfer • Expensive computations (transformation, lighting …) are processed only once while display list is created Static or Dynammic ?

  3. Vertex Array • Drawing a cube consists of: • Drawing 6 Quads – Faces • Each face needs 4glVertex*() calls • 24glVertex*() calss in total • What about glColor* (24) and glNormals*(24) ? • We can notice that vertices are shared among faces

  4. Vertex Array • Using vertex array reduces the number of function calls • It also reduces the redundant usage of shared vertices arrays are transferred to the video adapter every frame drawing

  5. Vertex Array - Initialization • OpenGL provides functions to activate and deactivate 6 different types of arrays glEnableClientState() , glDisableClientState() • There are 6 functions to specify the exact positions of arrays • glVertexPointer():  specify pointer to vertex coords array • glNormalPointer():  specify pointer to normal array • glColorPointer():  specify pointer to RGB color array • glTexCoordPointer():  specify pointer to texture cords array

  6. Vertex Array - Initialization glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) • size: specifies the number of coordinates per vertex. Default is 4. • type: GL_SHORT, GL_INT, GL_FLOAT, or GL_DOUBLE are accepted • stride:specifies the byte offset between consecutive vertices • pointer: specifies a pointer to the first coordinate of the first vertex in the array.

  7. Vertex Buffer Object (VBO) • Enhances the performance of OpenGL • providing the benefits of vertex array and display list while avoiding their downsides • Allows vertex array data to be stored in graphics memory • Vertex buffer objects can be modified after its creation

  8. Creating VBO • Creating a VBO requires 3 steps: • Generate a new buffer object with glGenBuffersARB(). • Bind the buffer object withglBindBufferARB(). • Copy vertex data to the buffer object with glBufferDataARB().

  9. glGenBuffersARB() • Requires 2 parameters: •  the first one is the number of buffer objects to create •  the second parameter is the address of a GLuint variable or array to store a single ID or multiple IDs glGenBuffersARB(GLsizei n, GLuint* ids)

  10. glBindBufferARB() •  Hooks the buffer object with the corresponding ID glBindBufferARB(GLenumtarget, GLuint id) • Target is a hint to tell VBO whether this buffer object will store vertex array data or index array data • GL_ARRAY_BUFFER_ARB (vertex array) • Vertex coordinates • Texture coordinates • Normals • and more • GL_ELEMENT_ARRAY_BUFFER_ARB (index array)

  11. glBufferDataARB() glBufferDataARB(GLenum target, GLsizei size, const void* data, GLenum usage) • target: GL_ARRAY_BUFFER_ARB/ GL_ELEMENT_ARRAY_BUFFER_ARB • size: number of bytes of data to transfer • data: pointer to the source data • Usage: provide how the buffer object is going to be used • GL_STATIC_DRAW_ARB • GL_DYNAMIC_DRAW_ARB

  12. Creating a single VBO

  13. Drawing VBO Switch VBO off

More Related