PDA

View Full Version : display mode change, getting framerate


dcnieho
05-20-2011, 09:45 PM
Dear All,

I want to force a display mode change and exit out when errors occur, however I am having some trouble with querying the framerate the program runs at (viz.window.getFrameRate() always returns 0). Is the below a good way to do it?


# setup display mode
viz.setDisplayMode(resolution[0], resolution[1], 32, refreshRate)
viz.setMultiSample(multiSample)

viz.go(mode)
viz.window.setFullscreen()

# check displayMode set succesfully
if viz.window.getFullscreenRectangle()[2] != resolution[0] or \
viz.window.getFullscreenRectangle()[3] != resolution[1] or \
viz.window.getFrameRate() != refreshRate:
print '\nRequested display mode: '+str(resolution[0])+'x'+str(resolution[1])+'@'+str(refreshRate)+', got: '+str(viz.window.getFullscreenRectangle()[2])+'x'+str(viz.window.getFullscreenRectangle()[3])+'@'+str(viz.window.getFrameRate())
viz.quit()
sys.exit(-1)



In a related note, if I put in some ridiculous displaymode settings, Vizard always nicely gives me '** ERROR: Failed to set requested display mode', highlighted in red. Is there any way for me to get my own error messages highlighted in red (the print in the above code could use it)?

Thank you very much!

Best,
Dee

dcnieho
05-20-2011, 10:24 PM
In a related note, if I put in some ridiculous displaymode settings, Vizard always nicely gives me '** ERROR: Failed to set requested display mode', highlighted in red. Is there any way for me to get my own error messages highlighted in red (the print in the above code could use it)?


To answer this part of my question, I just came across viz.logError(), nice!

Best,
Dee

farshizzo
05-23-2011, 08:59 AM
The following code shows how to retrieve the refresh rate of the monitor:refresh_rate = viz.getOption('viz.monitor.refresh_rate',type=int)

dcnieho
05-23-2011, 07:32 PM
Ah thanks, that works!

I did try viz.getOption('viz.display.frequency',type=int) before, but that doesn't work as it simply reports the frequency you asked for (however ridiculous), not the current refresh rate... viz.getOption('viz.monitor.refresh_rate',type=int) does exactly what I hoped for.