Hi folks -
I must apologize in advance, for I really don’t know a lot about SDL, and I am
probably asking a question which has been rehashed many times on this list.
However, I’ve done a fair amount of searching on the web, and have tried a
number of fixes, but am still having problems.
I am using SDL + Open GL in an experimental scientific programming environment
where I need to be able to very precisely control what is being shown on a
screen. I’m using SDL to program a visual display for a psychophysics
experiment.
Computer info:
Dell Optiplex GX260 Intel Pentium 4 CPU 2.66GHz
running MS Windows 2000 SP4 *****
1G RAM
ATI Fire GL T2 display adapter
Philips monitor @ 75Hz, 1280x1024
“Full” hardware acceleration
Config: “Open GL Games”
“Wait for vertical retrace” checked
"enable 8bit double buffer" checked
I’ve got most things working well, but I am having problems with my moving
stimulus … I get quite regular “skips” or “hiccups” in my display, where
the movement is temporarily halted. Which means that I am getting a dropped
frame occasionally.
My hunch is that the problem has to do with the timing of my redraw loop and
buffer swap (using SDL_GL_SwapBuffers()) not matching up with the vertical
retrace. I do not, however, really see any “tearing” as far as I can tell.
Yesterday I downloaded the most recent version of SDL and added
SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 1 ) to my script before setting the
video mode
screen = SDL_SetVideoMode( XMAX, YMAX, BPP, SDL_OPENGL|SDL_FULLSCREEN );
However, this didn’t improve the situation.
I’m seeing a dropped frame (a “hiccup” in my continuously moving stimulus)
once every 22 to 33 seconds or so … though for a while yesterday it was
happening only once every 60 seconds. Perhaps system processes are hogging
CPU and causing this to happen. Is there a way to increase SDL’s priority so
that all background processes are stopped while my program is running?
I’ve seen a few other suggestions here and there that I could use
SDL_GetTicks() and SDL_Delay() to measure how long my drawing loop is taking,
and to slow it down to better match the refresh rate. However, this seems
like it could also fail quite often, as it would be virtually impossible for
me to completely timelock my loop to the refresh rate, and any small
discrepancy would eventually accrue and lead to a dropped frame.
Am I missing something? Is there another way to address this problem? Any
help would be appreciated.
thanks,
Ed–
Ed Vessel
New York University @Ed_Vessel
Center for Neural Science
4 Washington Place, Suite 809 http://www.cns.nyu.edu/~vessel
New York, NY 10003
(212) 998-3908