02-21-2005, 06:08 PM
v1c, it only copies the buffer if you've specified SDL_DOUBLEBUF (or whatever the constant is.. )
Otherwise it just performs a vsynched updaterect on the entire screen.
It the wait/detect of the vsynch that sucks up CPU.
Apparently they had a problem with sdl_flip missing frames on extreme end computers using high hertz rates on the monitor.
So they made the algo/function that finds the vsync more accurate, but also more CPU intensive, meaning on slower computers it will make your program slowdown, and a simple delay can fix it.
Although a delay is a bad idea, a better idea is:
That will give you 50constant FPS, it cannot go higher... although it can go lower
That way, even if drawing and updating takes 10milliseconds it will only delay for 10 more before updating again.
As opposed to the sleep method where it will always wait for 20ms, meaning, if you have a 10ms draw/update, and a 20ms sleep, you get a 30ms delay.. meaning lower framerate, which is a bad idea as it will be different from computer to computer.
Otherwise it just performs a vsynched updaterect on the entire screen.
It the wait/detect of the vsynch that sucks up CPU.
Apparently they had a problem with sdl_flip missing frames on extreme end computers using high hertz rates on the monitor.
So they made the algo/function that finds the vsync more accurate, but also more CPU intensive, meaning on slower computers it will make your program slowdown, and a simple delay can fix it.
Although a delay is a bad idea, a better idea is:
Code:
Dim k as ubyte ptr
numT = SDL_GetTicks + 20
Do
k = SDL_GetKeyState(0)
If numT <= SDL_GetTicks Then
numT = SDL_GetTicks + 20
'draw stuff/update stuff
SDL_Flip video
End If
Loop until key[SDLK_ESCAPE]
That way, even if drawing and updating takes 10milliseconds it will only delay for 10 more before updating again.
As opposed to the sleep method where it will always wait for 20ms, meaning, if you have a 10ms draw/update, and a 20ms sleep, you get a 30ms delay.. meaning lower framerate, which is a bad idea as it will be different from computer to computer.