Rotating cube | C++

conjurer - Sep 2 - - Dev Community

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.

functions

The Cube

Some structs and functions for 3d geometry

cube parts

On the screen | int main()

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

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

Show time!

Rendered

Thanks to The Builder for sharing the amazing tutorial!

. . . . . . . . .
Terabox Video Player