We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › framerate question
Page Index Toggle Pages: 1
framerate question (Read 563 times)
framerate question
Apr 28th, 2006, 12:11pm
 
Hi,

This is probably a real 'newbie' question (slightly different from a previous q of mine).  If I know my screen's refresh rate (see code below for deriving this), and I set my framerate within setup to be some whole number derivitive of my refresh rate (say my fresh rate is 60hz, I could set my framerate to 20 or 30 etc), will processing and my graphics card syncronise together to output images to the screen directly in time with each other?  Or are there other factors at play that may make some images appear slightly longer on screen than others? (thanks mark_h for your prev answer, it helped us understand the problem more clearly).

We're developing a new online test for glaucoma- we look to see if people have problems detecting motion at various places in their visual field (people focus on a dot in the centre of the screen and we show them motion in exact locations on screen).  In our test, it is REALLY IMPORTANT that we have good control over the timings of our motion (a collection of dots moving in semi-random directions).  

I'd just like to add that Processing is EXCELLENT.  It is exciting for us that we can develop a clinical test using this program (our research could help A LOT of people!). Your help would be REALLY appreciated! Thanks.

Code to determine monitors refresh rate (& colour depth):

   GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
   GraphicsDevice[] gs = ge.getScreenDevices();
   
   for (int i=0; i<gs.length; i++) {
       DisplayMode dm = gs[i].getDisplayMode();
   
       // Get refresh rate in Hz
       int refreshRate = dm.getRefreshRate();
       if (refreshRate == DisplayMode.REFRESH_RATE_UNKNOWN) {
           // Unknown rate
       }
   
       // Get number of colors
       int bitDepth = dm.getBitDepth();
       if (bitDepth == DisplayMode.BIT_DEPTH_MULTI) {
           // Multiple bit depths are supported in this display mode
       } else {
           int numColors = (int)Math.pow(2, bitDepth);
       }
   }
Re: framerate question
Reply #1 - Apr 28th, 2006, 3:33pm
 
interesting.. i've certainly not looked into making the framerate run this accurately, so i'm not sure what you'll run into. i would recommend using the P3D or OPENGL libraries, however, as they seem to have less frame trouble than the default JAVA2D renderer.

you may find that you need to hack the run() method in PApplet to give you better results based on being able to grab the refresh rate, i'm not certain. the way the threading/refresh works is that the framerate() setting determines how often the applet asks for a repaint, but because of java's event handling, it's only a request, we can't necessarily guarantee that it'll happen (on windows you get pretty good results, mac and linux are mostly good). if you work at a lower level, like using the GraphicsDevice stuff that's specific to java 1.4, you might be able to get more control, particularly when not running as an applet (see how present mode works, where it takes over the screen).

also, in order to use those GraphicsDevice functions, you may need to sign your applet, if it will be running off the web.
Re: framerate question
Reply #2 - May 2nd, 2006, 2:10pm
 
Thanks Fry.  I'll let people know how our project goes, and how we will solve the above problem (still working on it!).  Cheers, Andy.
Page Index Toggle Pages: 1