fullscreen

I know fullscreen is in some threads - but I didn’t find any code that works. So my question - Would someone be so kind and post here code so I can run my game fullscreen from my game ? I mean I know how to run all programs fullscreen w. editing ‘etc\config.prc’ but I can’t figure out how to run fs from game.

many thanks

Not sure entirely what you mean. There are several ways to force fullscreen with code. One way is to cheese out the Config.prc file by overridding the variable before you start up, which I think has been covered in another post somewhere, but looks basically like this:

from pandac.PandaModules import *
ConfigVariableBool('fullscreen').setValue(1)
from direct.directbase.DirectStart import *

But if you’re looking for a way to switch from windowed mode to fullscreen mode in-game, say in response to a user request, then you need to close the old window down and open a new one. Again, this depends on how deep you want to get into the windowing code, but an easy way is to call base.openMainWindow(), which automatically closes the previous window and opens a new one. The window object it creates hasn’t actually been opened yet when it returns, so you have a chance to twiddle the properties before it really does open, something like this:

base.openMainWindow()
wp = WindowProperties()
wp.setFullscreen(1)
base.win.requestProperties(wp)
base.graphicsEngine.openWindows()

David

sorry if I did’n say that clear enough :blush: but you solved it anyway :smiley:

the first code was what I needed. thanks (again)

Note that, in a finished application, you will probably want to be delivering a Config.prc along with the application anyway, to control settings like this appropriate to your application. So it may be perfectly reasonable just to leave the “fullscreen 1” setting in the Config.prc file.

David

The Windows version of Panda (1.1.0) currently has issues with setting the fullscreen property of an already-running window. Here’s a helpful function I wrote for my project, allowing in-game fullscreen toggle.

def ToggleFullscreen():
	fullscreen = not base.win.isFullscreen() #toggle
	props = base.win.getProperties()
	if (not fullscreen):
		props.setFullscreen(False)
		props.setUndecorated(False)
		props.setOrigin(100,100)
		props.setSize(800,600)
	else:
		props.setFullscreen(True)
		props.setSize(1024,768)
	base.openMainWindow(props=props, gsg=base.win.getGsg())