Rotating cube | C++

conjurerconjurer
1 min read

A quick and cool code!
SDL2 is a library designed to provide low level access to audio, graphics hardware etc.
Supports C++, lessgoo!

Setup - screen.h

Initialised the event handler, window and render pointers, and basic data members.

Requirements

Show pixels on screen
Clear the screen
Check if quit activity detected by user

Solution

A vector that stores all points to be rendered on screen. Looped to render them. Cleared the vector to clear the screen.
Quit if user wants to exit.

The Cube

Some structs and functions for 3d geometry

On the screen | int main()

Initialised the cube with vertices and edges, and a centroid for easy translations

Brought each point to the origin, rotated it along the axes, translated it back.

Show time!

Thanks to The Builder for sharing the amazing tutorial!

0
Subscribe to my newsletter

Read articles from conjurer directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

conjurer
conjurer