sdl-gpu icon indicating copy to clipboard operation
sdl-gpu copied to clipboard

How to rotate rectangles?

Open AxorusMT opened this issue 2 years ago • 5 comments

I am new to sdl_gpu and I know I can draw rectangles using GPU_RectangleFilled2

How would I go about rotating this? Thank you in advanced

AxorusMT avatar Aug 29 '22 15:08 AxorusMT

You can use GPU_Rotate to rotate the matrix, then all proceeding rendering would be rotated. You can rotate the matrix back when you're done

Personally I'd use GPU_PolygonFilled to draw a rectangular polygon, and rotate the vertices in code

avahe-kellenberger avatar Aug 29 '22 15:08 avahe-kellenberger

Thank you very much!

AxorusMT avatar Aug 29 '22 15:08 AxorusMT

So GPU_Rotate works, but is there any way to control the speed of the rotation?

AxorusMT avatar Aug 29 '22 17:08 AxorusMT

If you want to rotate over time to sort of "spin", you'd just have to rotate using higher values to rotate "faster". This also depends on how quickly you're calling the function.

avahe-kellenberger avatar Aug 29 '22 17:08 avahe-kellenberger

OK so I've been trying to use rotation for some time now and i can't really get it to work that well. Could you please send some example code? Thank you very much in advanced

AxorusMT avatar Aug 29 '22 17:08 AxorusMT