Share
Embed
Transcript
10 slides
-
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 -
Review: Vertex buffer object ◼ Source code for drawing with
VBO. Computer Graphics Course @Waseda University A lot of redundant coding is needed… -
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 -
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! -
Create and enable VAO ◼ Code ◼ Note ◼ Equivalent
to those for textures and VBOs. Computer Graphics Course @Waseda University -
Drawing using VAO ◼ Code Computer Graphics Course @Waseda University
→ glVertexPointer etc. is no longer necessary! -
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 -
Setting for Mac to use VAO Computer Graphics Course @Waseda
University Specify GL version Load extension using GLAD -
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