Android window resizing problem

Hello! I have a problem with window resizing on an android device (Samsung s9) resolution 2220x1080. Below is a list with my attempts to make it work:

  • SDL_DisplayMode mode;
    SCREEN_WIDTH = mode.h;
    SCREEN_HEIGHT = mode.w;
    m_Format = mode.format;
    m_Window = SDL_CreateWindow

  • SDL_RenderSetLogicalSize(m_Renderer,mode.h,mode.w);

  • SDL_SetWindowSize(m_Window,mode.w,mode.h);

  • SDL_SetRenderTarget(renderer,texture);

  • SDL_GetDesktopDisplayMode(0,&mode);

  • SDL_RenderGetScale(m_Renderer,&xsc,&ysc);

This is the result after all of the attempts. One line on the left part of the screen which is left blank.

Thank you.

I don’t know what the problem is, but, one way for the above x,y position of the rectangle containing your game to happen is to apply the offset twice.

(xoff==2*a, yoff==2*0==0)

I find curious in the screen below there’s a little square icon at top left.

1 Like

In Android, the window is always the same, so:

  1. Just open a window the size of a display
  2. Don’t change mode.w from mode.h
  • SDL_SetRenderTarget(renderer,texture);
    now you draw …
1 Like

Thank you for the fast response. I found that the problem was with the camera positioning. The camera viewport width is initialized with the size of the first level and the first level size is 1920X1080, so the other 300 pixels are left blank. Because of this on the left corner of the second picture appears a box which is on a right place.
Sizes of the renderer and the window were fine. Also I changed display mode.w and mode.h.

1 Like