Sign in to follow this  
Mastadex

SDL - changing video mode while in game.

Recommended Posts

I ususally set the video mode before the game starts. newScr = SDL_SetVideoMode(1024, 768, 32, SDL_SWSURFACE | SDL_FULLSCREEN); If i wanted to change the resolution in game, or put Full screen on/off, how would i do that?

Share this post


Link to post
Share on other sites
Even if i do this:

Screen = SDL_SetVideoMode(1024, 768, 32, SDL_SWSURFACE);
SDL_FreeSurface(Screen);
Screen = SDL_SetVideoMode(1024, 768, 32, SDL_SWSURFACE | SDL_FULLSCREEN);

Or is this just bad technique?

Share this post


Link to post
Share on other sites
ukdeveloper is right, but only in context of using that function the AP posted.

Mastadex, all you have to do is pass the SDL_RESIZABLE flag, and then you can call SDL_SetVideoMode as much as you want changing between the modes, as long as you continue to pass in that SDL_RESIZABLE flag. In your last post, you definitly *do not* want to free your main surface, SDL handles all of that, so that code should be:

Screen = SDL_SetVideoMode(1024, 768, 32, SDL_SWSURFACE | SDL_RESIZABLE);
...
if(toggleFS)
Screen = SDL_SetVideoMode(1024, 768, 32, SDL_SWSURFACE | SDL_FULLSCREEN | SDL_RESIZABLE);


And last but not least, a quote from the docs for something more solid.[wink]
Quote:
SDL_RESIZABLE - Create a resizable window. When the window is resized by the user a SDL_VIDEORESIZE event is generated and SDL_SetVideoMode can be called again with the new size.


I have a few posts about this, but take a look at this one for issues that can happen, if you *resize* your display. If all you are doing is chaning between fullscreen and windowed, you shouldn't have those problems. Goodluck!

Share this post


Link to post
Share on other sites
yea like the document states that it will create a resizable window, i dont want my users to resize the window, just toggle fullscreen on and off. if they can make the windows biggern the 1024x768, that will screw up my game, it doesnt handle that sort of input.

Share this post


Link to post
Share on other sites
Quote:
Original post by Drew_Benton
ukdeveloper is right, but only in context of using that function the AP posted.

Mastadex, all you have to do is pass the SDL_RESIZABLE flag, and then you can call SDL_SetVideoMode as much as you want changing between the modes, as long as you continue to pass in that SDL_RESIZABLE flag. In your last post, you definitly *do not* want to free your main surface, SDL handles all of that, so that code should be:

Screen = SDL_SetVideoMode(1024, 768, 32, SDL_SWSURFACE | SDL_RESIZABLE);
...
if(toggleFS)
Screen = SDL_SetVideoMode(1024, 768, 32, SDL_SWSURFACE | SDL_FULLSCREEN | SDL_RESIZABLE);


And last but not least, a quote from the docs for something more solid.[wink]
Quote:
SDL_RESIZABLE - Create a resizable window. When the window is resized by the user a SDL_VIDEORESIZE event is generated and SDL_SetVideoMode can be called again with the new size.


I have a few posts about this, but take a look at this one for issues that can happen, if you *resize* your display. If all you are doing is chaning between fullscreen and windowed, you shouldn't have those problems. Goodluck!


your conclusion is a little incorrect.

SDL_RESIZEABLE does not allow you to recall SDL_SetVideoMode, you can do that independantly of SDL_RESIZEABLE flag. the quote meant to say something like "to follow up on this event, re-call SDL_SetVideoMode". it shouldnt imply that SDL_RESIZEABLE is needed to do this.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this