Android: SDL_CreateWindow always aligns the game to the left of the device screen

Hi there,

I have SDL HG for android, a very recent build.
I noticed that:

SDL_CreateWindow(GAME_TITLE, SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL |
SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN);

If the screen set with “SCREEN_WIDTH” and “SCREEN_HEIGHT” is smaller than
the device screen, SDL_CreateWindow always puts the game screen aligned to
the left. It should be aligned to the middle. This is a problem since most
games aim from 4/3 format to 16/9 while most device screens are in that
format but since the android bar is always on the remaining resolution
aspect ratio is sometimes wider and thus the game has to be letterboxed a
little.

Hoe can I patch it? Or fix this?

Thanks
Giorgos

If the screen set with “SCREEN_WIDTH” and “SCREEN_HEIGHT” is smaller than
the device screen, SDL_CreateWindow always puts the game screen aligned to
the left. It should be aligned to the middle. This is a problem since most
games aim from 4/3 format to 16/9 while most device screens are in that
format but since the android bar is always on the remaining resolution
aspect ratio is sometimes wider and thus the game has to be letterboxed a
little.

Hoe can I patch it? Or fix this

SDL_WINDOWPOS_CENTERED is for… windows.

You are using a fullscreen display, so it does not apply, you can anyway
achieve what you need rendering to a surface (with SDL_SetRenderTarget for
instance) and then blitting your surface to the desired position/aspect
ratio.–
Bye,
Gabry