[SDL] SDL in RTLinux?
Dirk Gerrits
dirkg at chello.nl
Sun Feb 10 13:48:00 PST 2002
> > Hello,
> >
> > I am interested in developing a real-time graphics
> > application that will update the contents
> > of the framebuffer every 10 msec.
> > It is absolutely mandatory that this refresh rate is
> > kept steady with absolutely no frames dropped.
> >
> > I was thinking of using SDL under RTLinux.
> > Has anyone tried this?
> > Is there any other solution to guaranteeing a fixed
> > framebuffer refresh rate in SDL?
> >
> > Any pointers would be greatly appreciated.
> >
> > Nicolas P. Cottaris
Is it mandatory that the frame buffer is updated every 10 msec (100 times
per second) or that the data that should be displayed is updated every 10
msec? If it's the latter, than the actual display frame rate does not
matter, you can simple use a fixed frame rate scheme. (This is a good
reference on that:
http://www.flipcode.com/cgi-bin/msg.cgi?showThread=Tip-MainLoopTimeSteps&for
um=totd&id=-1 )
If you actually have to update the frame buffer every 10 msec than it is a
bit more complicated. Assuming that the screen update is not locked to the
vertical sync rate of your monitor (or your monitor refreshes quickly
enough) then you can follow a scheme such as this:
Uint32 stopTime;
/* call this before the first call to DoFrame */
void Initialize()
{
stopTime = SDL_GetTicks() + 10;
}
/* call this every frame */
void DoFrame()
{
/* do display stuff here */
/* wait for 10 msec to elapse */
while (SDL_GetTicks() < stopTime) {};
/* update the screen */
SDL_Flip(screen); or SDL_UpdateRect(screen, 0, 0, 0, 0); or
SDL_GL_SwapBuffers();
stopTime = SDL_GetTicks() + 10;
}
This should guarantee a 10 msec interval between each update. But only if
the rendering takes less than 10 msec of course.
Dirk Gerrits
More information about the SDL
mailing list