libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
10.14k stars 1.85k forks source link

Camera API needs rotation #11476

Open Green-Sky opened 6 days ago

Green-Sky commented 6 days ago

We currently only make Position (back/front) available, but eg. on Android, cameras are rotated, usually multiples of 90°. Without this, it would be up to the user to first rotate the camera by eye before it is usable.

expikr commented 4 days ago

Could express in terms of bitflags:

Then an enum for the eight possible camera orientations:

typedef enum SDL_CameraRotation
{
    SDL_CAMERA_ROTATION_NORMAL = 0,         // none
    SDL_CAMERA_ROTATION_MIRRORED = 1,       // flipX
    SDL_CAMERA_ROTATION_180_MIRRORED = 2,   // flipY
    SDL_CAMERA_ROTATION_180 = 3,            // flipX and flipY
    SDL_CAMERA_ROTATION_RIGHT_MIRRORED = 4, // swapXY
    SDL_CAMERA_ROTATION_RIGHT = 5,          // flipX then swapXY
    SDL_CAMERA_ROTATION_LEFT = 6,           // flipY then swapXY
    SDL_CAMERA_ROTATION_LEFT_MIRRORED = 7,  // flipX and flipY, then swapXY
} SDL_CameraRotation;
icculus commented 4 days ago

Just to be clear, are we talking about the phone being rotated (I'm holding it in landscape so I except the camera to provide landscape footage), or are we talking about some weird camera that is rotated separately from the phone?

Because we can already report the rotation state of the phone itself (...I think...?), so I'm not sure the camera API should manage this separately.

Green-Sky commented 4 days ago

I was talking about the camera rotation relative to the phone origin.

But yea, we would have to report this relative to something, either a fixed origin or current screen rotation.