Switching resolutions on Seven

Hello, I’ve a problem in my application. I give to the user the list of available screen resolutions, and she can choice among them.

I copy here a simple program that simulates this: it retrieves the available resolutions and simulates a user that switches among them.

import direct.directbase.DirectStart
from panda3d.core import WindowProperties

di = base.pipe.getDisplayInformation()
sizes = []
for index in range( di.getTotalDisplayModes() ):
  sizes += [ ( di.getDisplayModeWidth( index ), di.getDisplayModeHeight( index ) ) ]

def setScreen( index ):
  global sizes
  s = sizes[ index ]
  wp = WindowProperties()
  wp.setFullscreen( True )
  wp.setSize( s[ 0 ], s[ 1 ] )
  base.win.requestProperties( wp )
  if index < len( sizes ) - 1:
    taskMgr.doMethodLater( 2.5, setScreen, 'Set screen', extraArgs = [ index + 1 ] )

setScreen( 0 )
run()

On Ubuntu it works. But, on Seven (same machine), some resolutions don’t work and produces problems (I can’t see my application anymore). This is the output on Seven:

DirectStart: Starting the game.
Known pipe types:
  wglGraphicsPipe
(all display modules loaded.)
:display:windisplay(error): resize ChangeDisplaySettings failed (error code: -2) for specified res (1152 x 864 x 32), 60Hz
:display:windisplay(error): resize ChangeDisplaySettings failed (error code: -2) for specified res (1280 x 720 x 32), 60Hz
:display:windisplay(error): resize ChangeDisplaySettings failed (error code: -2) for specified res (1280 x 768 x 32), 60Hz
:display:windisplay(error): resize ChangeDisplaySettings failed (error code: -2) for specified res (1280 x 800 x 32), 60Hz
:display:windisplay(error): resize ChangeDisplaySettings failed (error code: -2) for specified res (1280 x 960 x 32), 60Hz
:display:windisplay(error): resize ChangeDisplaySettings failed (error code: -2) for specified res (720 x 480 x 32), 59Hz
:display:windisplay(error): resize ChangeDisplaySettings failed (error code: -2) for specified res (720 x 480 x 32), 59Hz
:display:windisplay(error): resize ChangeDisplaySettings failed (error code: -2) for specified res (720 x 576 x 32), 59Hz
:display:windisplay(error): resize ChangeDisplaySettings failed (error code: -2) for specified res (720 x 576 x 32), 59Hz
:display:windisplay(error): resize ChangeDisplaySettings failed (error code: -2) for specified res (800 x 600 x 32), 59Hz
:display:windisplay(error): resize ChangeDisplaySettings failed (error code: -2) for specified res (800 x 600 x 32), 59Hz
:display:windisplay(error): resize ChangeDisplaySettings failed (error code: -2) for specified res (1024 x 768 x 32), 59Hz
:display:windisplay(error): resize ChangeDisplaySettings failed (error code: -2) for specified res (1024 x 768 x 32), 59Hz
:display:windisplay(error): resize ChangeDisplaySettings failed (error code: -2) for specified res (1152 x 864 x 32), 59Hz
:display:windisplay(error): resize ChangeDisplaySettings failed (error code: -2) for specified res (1280 x 720 x 32), 59Hz
:display:windisplay(error): resize ChangeDisplaySettings failed (error code: -2) for specified res (1280 x 768 x 32), 59Hz
:display:windisplay(error): resize ChangeDisplaySettings failed (error code: -2) for specified res (1280 x 800 x 32), 59Hz
:display:windisplay(error): resize ChangeDisplaySettings failed (error code: -2) for specified res (1280 x 960 x 32), 59Hz
:display:windisplay(error): resize ChangeDisplaySettings failed (error code: -2) for specified res (1280 x 1024 x 32), 59Hz
:display:windisplay(error): resize ChangeDisplaySettings failed (error code: -2) for specified res (1280 x 1024 x 32), 59Hz

Is code for resolution switching correct? Are these errors deriving from the code above? If the code is correct, how can I remove from the list the problematic resolutions and give to the user only “secure” choices? Very thanks!

Hmm, that does sound like a bug in Panda. When you request an invalid resolution, it’s not supposed to make the application go away.

Another thing you can do is check a couple of frames later for win.getRejectedProperties(); this is supposed to contain the set of property requests that could be honored. If all is working, it should contain your failed request, so you should be able to determine if it failed. You can use win.clearRejectedProperties() to reset this list. Still, I worry that this might fail right now, due to the same bug that’s causing it to stop rendering (it sounds like Panda is not properly detecting the failure that Windows is reporting).

I’ll investigate the underlying failures.

David

Maybe I explained badly (sorry, my English is terrifying). The application continues, but for example you see only the desktop (magnified), or you see only a “part” of the application’s window. If you return to a correct resolution, you see the application properly.

Yes, it works! So, I can store the actual resolution before switching, and if there are any problems I can return to a correct situation, informing the user about the issue. Very thanks!