[SDL] refresh issue, "skipping"

Edward Byard e_byard at yahoo.co.uk
Wed May 14 12:34:50 PDT 2008


Hi Ed

It sounds like your app is losing focus. Check if you're getting SDL_ACTIVEEVENT events in the queue, and if so,
re-draw your screen.

I had the same situation today, and just putting a function to check for these events (also window resizes events)
and re-draw if necessary solved it. Quick and dirty but it does the job.

bool myAPI::checkAppFocus(void)
{
    return (SDL_PollEvent(&myAPI->systemEvent)) && (myAPI->systemEvent.type == SDL_ACTIVEEVENT);
}


Hope this is of some help.

Regards
Ed (another one!!)


----- Original Message ----
From: Ed Vessel <vessel at cns.nyu.edu>
To: sdl at lists.libsdl.org
Sent: Wednesday, 14 May, 2008 8:08:15 PM
Subject: [SDL] refresh issue, "skipping"

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                vessel at cns.nyu.edu
Center for Neural Science
4 Washington Place, Suite 809             http://www.cns.nyu.edu/~vessel
New York, NY 10003
(212) 998-3908

_______________________________________________
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



      __________________________________________________________
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20080514/76ba21a6/attachment.htm>


More information about the SDL mailing list