Hero image

Cubes via OpenGL

What the code does

This simple demo will introduce you to 3D rendering with OpenGL. OpenGL is a powerful way in which to create stimuli and is at the heart of much of PTB, all be it behind the scenes. This demo renders an array of 3D cubes, each with a different position and rotation angle. It lights these cubes with a single light source. The scene is rendered with anti-aliasing via multi-sampling to give us nice smooth edges to the rendered objects on screen. It also further demonstrates the order of operations for transforms to be applied in OpenGL.

Visualisation

The code

Instagram image Instagram image Instagram image Instagram image Instagram image Instagram image