NOTE: you may be interested in the much more flexible follow-up to this class, called Sprite3D.
Sprite 3D is now included (and maintained) as a part of Selba Ward.I remember someone once mentioning animating a card so that it spins around without using OpenGL. I think the answer was simply "scale the width". I had said it could be faked by animating the corners but I think they thought that might be too complicated.
It inspired me to create something that spins a card easily without using OpenGL but still looks 3D (enough).
I bring you...
Spinning CardHere's a video of a really basic example of it in action (source code for example is on github):
The example code uses two SpinningCards - one for the front and one for the back - and switches which one to draw depending on the current angle. It animates the angle linearly from 0 to 360 degrees and animates the scale depending on the angle (to make it float forwards).
In this example, the card starts the spinning animation whenever the Space Bar is pressed. The "stuttering" is because of the key pressed quickly.
The class takes a sprite and mimics it by creating a vertex array and taking the sprite's position, origin, scale, rotation, colour, and its texture, which it takes a pointer to.
The card, by the way, can also be spun vertically.
If you can think of something that this class is missing, let me know. It's a simple class with a specific task in mind, though, so it probably shouldn't start including an ability to bend the card or anything
As always, feel free to let me know if my code could be improved and how.