[SDL] New Hardware Acceleration/Double buffering
jcatki at jonatkins.org
Thu Oct 14 04:27:22 PDT 2004
VSync is only supported in a few drivers and usually only in fullscreen,
plus you can't really tell SDL to turn it on or off, and sometimes you
have to set some unknown environment variable before calling
SDL_SetVideoMode. In any case, it's not a reliable solution since you
have no good control over it.
A more or less reliable way of doing it, is to calculate the frames/sec
and either use a timer, or an SDL_Delay (along with a time that will get
you close to your desired next frame time). Or just skip rendering in
your event loop until the time for the next frame arrives, replacing the
redraw with a small SDL_Delay(10) if you want to be cpu friendly.
since FPS limiting has been discussed here before, I also suggest
searching the archives...
Alan Wolfe wrote:
> you can turn on vsync, that limits the framerate to the verticle refresh
> rate of your monitor, which in turn makes the images look alot nicer because
> it gets rid of tearing.
> there are other ways too im sure someone else will speak up about (:
> ----- Original Message -----
> From: "Walter Crowley" <waltc at fleetwoodgaming.com>
> To: "A list for developers using the SDL library. (includes SDL-announce)"
> <sdl at libsdl.org>
> Sent: Wednesday, October 13, 2004 3:52 PM
> Subject: Re: [SDL] New Hardware Acceleration/Double buffering
>>Thank You. That was the clue I needed. I looked again at the doc and
>>realized that you cannot Blit to a locked surface. I changed that up
>>and it worked. Now I am getting fast speeds (125-1000fps), and this is
>>way too fast for the monitor. Do you or anyone else know an efficient
>>way to lock the rate in at a specific speed, say 50fps?
>>On Wed, 2004-10-13 at 16:04, Jonathan Atkins wrote:
>>>you only need to lock a surface when you are accessing the
>>>array directly. Don't lock it otherwise or you may cause a performance
>>>Also, if you are locking it to do some pixel access, try to lock it only
>>>and do all the work before unlocking and flipping the buffer.
>>>Walter Crowley wrote:
>>>>I am new to the idea of using Hardware Buffers. I am using Linux
>>>>with a Transmeta 1gig cpu. The Video is ATI Radeon 9001 Mobile with
>>>>I have a simple program that displays some png graphics and moves them
>>>>around. It works fine withe Video Mode settings set to SDL_SWSURFACE
>>>>and SDL_FULLSCREEN. Using the DGA driver I can get a frame rate of
>>>>about 54 frames per second. I got this by doing
>>>>fps=frames*1000/(end_time-start_time) where frames is a counter that
>>>>increments while the animation is going.
>>>>The Radeon driver seems to have a lot of overhead and slows things
>>>>I wanted to push the speed more so I tried to use the setting
>>>>SDL_HWSURFACE with SDL_DOUBLEBUF and SDL_FULLSCREEN. I believe that
>>>>have to lock the surface every time you want to use it so nothing else
>>>>'steals' it from the program. I did this and unlocked it. SDL
>>>>initialized and the information I got back said that HW was there
>>>>SDL_GetVideo). The only thing is that nothing is displayed on the
>>>>I am not sure what I need to do different when dealing with SW and HW
>>>>If anyone has a simple example, or direct me to a solution that would
>>>>SDL mailing list
>>>>SDL at libsdl.org
>>>SDL mailing list
>>>SDL at libsdl.org
>>SDL mailing list
>>SDL at libsdl.org
> SDL mailing list
> SDL at libsdl.org
More information about the SDL