Jump to content
  • Advertisement
Sign in to follow this  
TinyTertle

How do I change screen resolutions at runtime using SDL2?

This topic is 859 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Obviously many games support changing the screen resolution during runtime via some sort of option menu. I'm also aware that many of these games access the screen resolutions your graphics card is compatible with and displays them in said option menu. How might I implement such a system in a game of my own (using SDL2)? If it is of any relevance, my language of choice is C++.

 

-Example image taken from Terraria (one of my all time favorites)

Edited by TinyTertle

Share this post


Link to post
Share on other sites
Advertisement

You can get a list of valid screen resolutions using SDL_GetDisplayMode. Then you can change the current screen resolution using SDL_SetWindowDisplayMode. Please note that this only works in fullscreen mode (SDL_SetWindowFullscreen). To change the size of a window use SDL_SetWindowSize. Whether or not you have to recreate your renderer I am not sure, but as SDL2 uses OpenGL I'd say probably not. You will have to react to the change of the viewport though.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!