Skip to content
Part IA Michaelmas Term

Geometry Objects: VAO and VBO

Vertex Array Object (VAO)

A VAO encapsulates all vertex attribute state:

  • Which VBOs are bound to which attributes
  • Attribute formats (data type, stride, offset)
  • Enable/disable states for each attribute

A VAO is a configuration object—it does not store data itself, but describes how to interpret VBO data.

Vertex Buffer Object (VBO)

A VBO stores vertex data on GPU memory:

Data TypeTypical Format
Positions3 floats per vertex (x, y, z)
Normals3 floats per vertex (nx, ny, nz)
Texture coordinates2 floats per vertex (u, v)
Colours3-4 floats per vertex (r, g, b, a)

Element Buffer Object (EBO)

Also called an Index Buffer. Stores indices for indexed drawing:

  • Defines which vertices form each triangle
  • Allows vertex reuse (memory efficient)
  • Reduces data duplication for shared vertices

VAO containing references to VBO and EBO

Example: Cube Data

A cube has 8 vertices but 6 faces with 12 triangles:

Positions (3 floats/vertex): [x, y, z, x, y, z, ...]
Normals (3 floats/vertex): [nx, ny, nz, nx, ny, nz, ...]
Indices (3 ints/triangle): [0, 1, 2, 3, 4, 5, ...]

Without an EBO: 36 vertices × 3 floats = 108 floats With an EBO: 8 vertices × 3 floats = 24 floats + 36 indices

Setting Up VAO and VBO

Creating a VAO

GLuint vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);

Creating a VBO

GLuint vbo;
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(positions), positions, GL_STATIC_DRAW);

Configuring Vertex Attributes

glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
glEnableVertexAttribArray(0);

Parameters:

  • Index: Attribute location in shader
  • Size: Components per vertex (1-4)
  • Type: Data type (GL_FLOAT, etc.)
  • Normalised: Whether to normalise
  • Stride: Bytes between successive attributes
  • Pointer: Offset to first component

Shader Storage Buffer Object (SSBO)

An SSBO is a GPU memory buffer that shaders can read and write:

  • Much larger data capacity (up to 85% of GPU memory)
  • Supports dynamic arrays and complex data structures
  • Used for GPGPU, particle simulations, advanced lighting

SSBO buffer access showing read/write paths

SSBO vs Uniform Buffer

PropertyUniform BufferSSBO
Size limit~64 KBUp to GPU memory
AccessRead-onlyRead/write
Use caseSmall constantsLarge dynamic data

Summary

  • VAO stores vertex attribute configuration
  • VBO stores vertex data on GPU
  • EBO enables indexed drawing for efficiency
  • SSBO provides large, writable GPU buffers for advanced techniques

Past Paper Questions

2024 Paper 3 Question 4: Explain the purpose of a VAO. What information does it store?

2023 Paper 3 Question 4: What is the difference between a VBO and an EBO?

2022 Paper 3 Question 4: Why is using an EBO more memory-efficient than drawing without one?