Is it possible to change resolution at run-time?

Is it possible (at run-time) allow user to:
-Change game’s resolution
-Choice window mode or fullscreen
-Define contrast
-Change sound’s volume

How can I do this? I just want a general explanation. I should use Python, right?

I doubt you could do it at runtime, but you should be able to modify an ini file at rntime, then when the user hits “apply” restart the game (I think you’ll have to launch it through a bat or something that can do ommand line) and have it load settings from the ini file. I don’t know much about this, but I believe there have been several conversations about this earlier.

I think captain oblivion is correct, look at commercial games, you always have to restart it.
Look for the thread castle scene W.I.P I think he uses a contrast shader.

Interesting topic. I want to learn about this when i got some free time.

If we could change resolution and the other things, the games would be more professional. I want to learn about this too

what i done so far before is change my car texture by restarting the game (since it is not possible when the game is running). But i fail to save the camera orientation and load it back when the game start.

I think it is not worth the trouble to make at that time. Good Luck centi

I think an ini file it’s a good solution, but then the question is: ¿How can I configure the game from an ini file and change its properties(game properties)? All comments are welcome

Not sure , but can’t you access those options using python?

That’s what I want to know. I have to read more about Python, I guess.

There’s no way to change the screen resolution in Python currently.

Thanks MastaEgg, I will have to find other way to make it.

You could make several different compiles with different resolutions and reffer to those when writing the ini file.

Thanks TheDave, it’s a good idea.
Having different compiles the space used on disk could be too big.

There ARE command line arguments for the blenderplayer. I spent a bit of time looking for them and couldn’t find them specifically, but if somebody does some digging I’m sure they can find them.

Basically command line arguments let you change some of blender player’s settings, including resolution. Usually they’re denoted by flags, so when launching your executable you’d include the flags after the executable, like:

mygame.exe -x 800 -y 600

But that’s just a guess as to what they are, you’ll have to figure it out.

You’d change these flags with some sort of launcher app. Lots of games have them, and it’d probably just be a simple visual-basic or something else program that takes in settings and then adjusts the flags.

Hope that helps, let us know if you find the arguments!


Okay, there’s a lot of information about this, and I don’t have the time to explain it all right now. Basically, you can achieve professional looking resolution change results, but you have to be willing to put a professional level of effort into it. That said, there are some basics worth mentioning.

The command line flags that The Sambassador mentioned are as follows:

usage:   blenderplayer248a [-w [-p l t w h]] [-g gamengineoptions] [-s stereomode] filename.blend
  -h: Prints this command summary
  -w: display in a window
  -p: specify window position
       l = window left coordinate
       t = window top coordinate
       w = window width
       h = window height
  -f: start game in full screen mode
       fw = full screen mode pixel width
       fh = full screen mode pixel height
       fb = full screen mode bits per pixel
       ff = full screen mode frequency
  -s: start player in stereo
       stereomode: hwpageflip       (Quad buffered shutter glasses)
                   syncdoubling     (Above Below)
                   sidebyside       (Left Right)
                   anaglyph         (Red-Blue glasses)
                   vinterlace       (Vertical interlace for autostereo display)
                             depending on the type of stereo you want
  -i: parent windows ID 
  -d: turn debugging on
  -g: game engine options:
       Name            Default      Description
       fixedtime          0         Do the same timestep each frame "Enable all frames"
       nomipmap           0         Disable mipmaps
       show_framerate     0         Show the frame rate
       show_properties    0         Show debug properties
       show_profile       0         Show profiling information
       blender_material   0         Enable material settings

example: blenderplayer248a -p 10 10 320 200 -g noaudio c:\loadtest.blend
example: blenderplayer248a -g show_framerate = 0 c:\loadtest.blend

So to launch a file in fullscreen mode, 1024x768, 32-bit depth, 60 Hz refresh you would do this from the terminal:

blenderplayer -f 1024 768 32 60 gamefile.blend

Here are two notes about command line flags -

  • Some flags will not work if there is no .blend file given. If you are using the flags on a compiled runtime, then there is no .blend file name to give, so just make one up like this
mygame.exe -f 1650 1080 32 60 fake.blend
  • The “game engine options” flags have not been working for me on Linux for the past couple of versions. I don’t know their status on Windows.

In order to switch resolutions in the middle of a game, you would need to first save the current state of the game to a temporary save file (using a Python script), then use Python to run a command line string (using a system() or exec() method or something… I can’t remember which is best at the moment). So it is a bit complicated, but it is possible.

Awesome info Blendezo! Where’d it come from?

That printout of flags, you mean? You just run “blenderplayer -h” from the command line.

Excellent guys, I am very grateful for this. This is the best forum. BGE rules.
I will try that, thanks.[/LEFT]

Yay, blendenzo saves the day again. :slight_smile:
Good stuff, really.