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

Using the camera with rotation?

Open smokefilledrooms opened this issue 6 years ago • 4 comments

Hi there,

So, I've been trying to use the camera (in 2d) rotated and I cannot for the life of me get the panning and zooming to work correctly while rotated. The camera zooms in toward somewhere in the lower left instead of the center of the screen. The camera doesn't pan parallel and perpendicular to its edges when using simple operations like cam.x++ and cam.y++, I used some basic trig to compensate for the latter, which worked, but only at one zoom level (8x out, specifically).

I'd chalk this up to my dubious math and programming skills, but the camera test program doesn't seem to compensate at all for the rotation which makes me think something else may be going on here? I'm not sure how to build the tests to make sure (on linux), though. I managed to generate a bunch of cmake files/directories and a feature_tests.bin but nothing that seems to run or can be make install'd

I'd greatly appreciate any pointers or instructions how to build the tests, thanks.

ETA: I figured out a work around for my use case, tips would still be appreciated though.

smokefilledrooms avatar Mar 15 '18 00:03 smokefilledrooms

Yeah we were talking about this issue in the past , still not solved https://github.com/grimfang4/sdl-gpu/issues/26 , see at the buttom of the page other issue related

dhiahassen avatar Mar 15 '18 11:03 dhiahassen

@fedkanaut my workarround was to apply trasformation matrices manually , what was yours ?

dhiahassen avatar Mar 21 '18 08:03 dhiahassen

I couldn’t get that to play nice for whatever reason (probably me). I didn’t actually really need runtime camera rotation so I just baked it into the polygons I was working with and called it a day (my use case is weird).

smokefilledrooms avatar Mar 21 '18 17:03 smokefilledrooms

I know this issue is a bit old, but if you still have the original code I would appreciate if you could try this patch and confirm it works for your use case: https://github.com/grimfang4/sdl-gpu/pull/206

albertvaka avatar Oct 04 '20 11:10 albertvaka