I am programming a game in SDL2 and I am looking for advice on how to handle interactivity of UI components when the screen resolution and logical resolutions are different. Up to now I have been developing the game with common logical and screen solutions, I am working at 2560x1440 and all my UI components (buttons, scroll bars) are defined relative to the screen resolution. If I decide to use SDL_RenderSetLogicalSize to downscale the rendering to say 1920x1080 how should I handle the UI?

If I do nothing, the UI is now off the window screen, I can alternatively set the position of UI components relative to the logical resolution to bring my buttons back within the screen window but then the interactivity is broken - for example the mouse over for a UI box is now checking for a collision at the "logical position" which is different from the screen position.

One thought I had was to keep the UI component positions relative to the screen resolution but at rendering time adjust the drawing of all UI components by the ratio between the logical and screen resolution to make them appear within the window.

My game eventually will have a lot of UI components so before I start putting effort into coding I want to get a sense of what my options are - or if I am going about this the wrong way.



You must log in to answer this question.

Browse other questions tagged .