Slide 1

Slide 1 text

8. Vertex array object Tatsuya Yatagawa

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

Review: Vertex buffer object ◼ Source code for drawing with VBO. Computer Graphics Course @Waseda University A lot of redundant coding is needed…

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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!

Slide 6

Slide 6 text

Create and enable VAO ◼ Code ◼ Note ◼ Equivalent to those for textures and VBOs. Computer Graphics Course @Waseda University

Slide 7

Slide 7 text

Drawing using VAO ◼ Code Computer Graphics Course @Waseda University → glVertexPointer etc. is no longer necessary!

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

Setting for Mac to use VAO Computer Graphics Course @Waseda University Specify GL version Load extension using GLAD

Slide 10

Slide 10 text

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