How to rotate a rect in SDL2?

I plan on making a game, and I want to create some background animations for said game. One of these animations is a rotating rectangle. I've looked all over, and I cannot find any form of math or logic that allows me to rotate a rectangle (SDL_Rect to be specific, but you might have already known that).

I can't figure out the math for myself, I really don't have any working code for this, so I can't show anything.

Essentially I'm looking for some type of logic that I can apply the rectangle's coordinates so that whenever the main game loop loops, it will rotate the rectangle some amount of degrees.


You can't rotate an SDL_Rect . If you look at its definition, it's made of coordinates for the top-left corner, the width and the height. There's no way to represent a rectangle with sides that aren't parallel to the coordinate system's axes.

SDL_RenderCopyEx supports drawing rotated textures, though.

链接地址: http://www.djcxy.com/p/95154.html

上一篇: 在Ubuntu上编译ARM的openCV

下一篇: 如何在SDL2中旋转矩形?