DEV Community

conjurer
conjurer

Posted on • Edited on

4

Rotating cube | C++

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!

Image of Checkly

4 Playwright Locators Explained: Which One Should You Use?

- locator('.cta'): Fast but brittle
- getByText('Click me'): User-facing, but can miss broken accessibility
- getByRole('button', { name: 'Click me' }): Most robust, best for a11y
- getByTestId('cta-button'): Stable, but ignores UX

Watch video

Top comments (0)

Image of Checkly

Incident Management 101: What Devs Need to Know in 2025

  • Detect issues before your users do
  • Use synthetic checks for proactive coverage
  • Automate root cause workflows
  • Communicate incidents clearly to your team
  • Learn how to triage, escalate, and resolve faster

Watch session

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay