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

8. Vertex array object

8. Vertex array object

94870c02836167043f37f05ae1032690?s=128

Tatsuya Yatagawa

May 13, 2021
Tweet

More Decks by Tatsuya Yatagawa

Other Decks in Technology

Transcript

  1. 8. Vertex array object Tatsuya Yatagawa

  2. 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
  3. Review: Vertex buffer object ◼ Source code for drawing with

    VBO. Computer Graphics Course @Waseda University A lot of redundant coding is needed…
  4. 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
  5. 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!
  6. Create and enable VAO ◼ Code ◼ Note ◼ Equivalent

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

    → glVertexPointer etc. is no longer necessary!
  8. 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
  9. Setting for Mac to use VAO Computer Graphics Course @Waseda

    University Specify GL version Load extension using GLAD
  10. 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