Upgrade to Pro — share decks privately, control downloads, hide ads and more …

8. Vertex array object

8. Vertex array object

Tatsuya Yatagawa

May 13, 2021
Tweet

More Decks by Tatsuya Yatagawa

Other Decks in Technology

Transcript

  1. Review: Vertex buffer object Computer Graphics Course @Waseda University ◼

    Preparation ◼ Prepare array of vertex (typically by class/struct). ◼ Allocate vertex/index buffer* on GPU. ◼ Bind (= enable) vertex/index buffers. ◼ Transfer data from CPU to GPU. *index buffer = store vertex indices to define triangles ◼ Drawing ◼ Bind (= enable) vertex buffer. ◼ Specify data types in vertex buffer. ◼ Draw triangles using index buffer. ◼ Cleanup
  2. Review: Vertex buffer object ◼ Source code for drawing with

    VBO. Computer Graphics Course @Waseda University A lot of redundant coding is needed…
  3. Vertex array object ◼ Vertex array object (a.k.a. VAO) ◼

    Introduced in OpenGL 3.0 (published in 2008) ◼ It can internally manage VBOs, IBOs, and other settings for buffers. ◼ Just by enabling/disabling VAO, all the settings are also enabled/disabled. Computer Graphics Course @Waseda University
  4. Workflow to use VAO ◼ Preparation ◼ Create and enable

    VAO. ◼ Setup for VBO, IBO and others. ◼ Disable VAO. ◼ Drawing ◼ Enable VAO ◼ Draw primitives using index buffer. ◼ Disable VAO Computer Graphics Course @Waseda University → Drawing gets significantly simpler only by slightly more preparation!
  5. Create and enable VAO ◼ Code ◼ Note ◼ Equivalent

    to those for textures and VBOs. Computer Graphics Course @Waseda University
  6. Drawing using VAO ◼ Code Computer Graphics Course @Waseda University

    → glVertexPointer etc. is no longer necessary!
  7. When using VAO ◼ VAO is supported by OpenGL 3.0

    or newer ◼ Current Windows PC supports that ☺ ◼ MacOS generally uses OpenGL 2.1 and it needs a rather complicated workaround  Computer Graphics Course @Waseda University
  8. Setting for Mac to use VAO Computer Graphics Course @Waseda

    University Specify GL version Load extension using GLAD
  9. Now, VAO is available…? ◼ In Windows, previous code with

    VBO/IBO can be combined with VAO ◼ glVertexPointer is a function in OpenGL 2.x (it’s deprecated in latest OpenGL). ◼ Deprecated functions are supported by “compatibility profile” of OpenGL (which can be used in Windows, but not in Mac). ◼ For Mac, all the source code must be rewritten to follow OpenGL 3.x specification. ◼ Mac only supports “core profile” which does not have backward compatibility. ◼ OpenGL 3.x core profile requires shader-based drawing. ◼ So, you must use shader programs! (see next section “9. Shader language”) Computer Graphics Course @Waseda University