Transformation in OpenGL: Translation, Rotation and Scaling

Zerihun M.
4 min readAug 16, 2024

Welcome back to our OpenGL journey! So far, we’ve learned how to draw shapes and handle input with the keyboard and mouse. Now, let’s take things to the next level by learning how to move, rotate, and resize those shapes. In this post, we’ll explore something called “transformation matrices.” Don’t worry — it’s easier than it sounds!

OpenGL Transformation

What is a Transformation Matrix?

Imagine you’re playing with a toy car. Sometimes you might want to move the car to a different spot, spin it around, or make it bigger or smaller. In OpenGL, transformation matrices are like the instructions that tell your shapes how to move, rotate, or change size.

A matrix is just a fancy math term for a grid of numbers. In OpenGL, we use these grids to keep track of how our shapes should be transformed (or changed). Let’s break down the three main types of transformations: translation, rotation, and scaling.

Translation: Moving Shapes Around

Translation is a fancy word for moving something from one place to another. In OpenGL, if you want to move a shape to a different spot on the screen, you use a translation matrix.

Let’s say you have a square, and you want to move it to the right. You would use a…

--

--

Zerihun M.

OpenGL expert sharing insights and tutorials on basic and advanced graphics programming and development techniques.