Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SDL_primitive_gfx question
#8
v1c, it only copies the buffer if you've specified SDL_DOUBLEBUF (or whatever the constant is.. Tongue )

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 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.
Reply


Messages In This Thread
SDL_primitive_gfx question - by invchrist - 02-21-2005, 03:57 AM
SDL_primitive_gfx question - by Z!re - 02-21-2005, 04:02 AM
SDL_primitive_gfx question - by invchrist - 02-21-2005, 04:11 AM
SDL_primitive_gfx question - by Z!re - 02-21-2005, 04:41 AM
SDL_primitive_gfx question - by invchrist - 02-21-2005, 05:08 AM
SDL_primitive_gfx question - by v3cz0r - 02-21-2005, 10:51 AM
SDL_primitive_gfx question - by Z!re - 02-21-2005, 06:08 PM
SDL_primitive_gfx question - by BastetFurry - 02-21-2005, 04:41 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)