Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Speed consistency
#1
Alright, I'm using the SDL library, and I have two problems that are related to the program's speed.

The first one, is that when in windowed mode, despite the fact that my program has no set FPS (which I'll get to in the next problem), it runs perfectly fine. But when set to FullScreen mode, it runs well, except for instances on the screen when AlphaBlending is called. This causes the screen to move veeery slowly until the Alpha Blending is gone.

The second one, is that the game doesn't have any set FPS at all, so could someone please explain to me how I could set an FPS variable, and have the program react to it?

Thanks.
Reply
#2
You start out with a delay, and increase the delay if the program is running too fast, or decrease it slightly until the program is running at the desired speed. You check the FPS each main game loop, and make the delay react to how many FPS you want.
It's the difference between asking someone how much flour goes into pancakes, and handing them a sorry mix of oozing green goo and asking them to fix it." - Deleter

-Founder & President of the No More Religion Threads movement-
Reply
#3
This does not need adjustment (except for delay variable) and adapts itself to small differences in the frame drawing times.

Code:
const  delay! =1/60   'for 60 fps
t!=timer+delay!
'frames loop
do
'draw your graphics    
  
do :loop until timer>t!:t!=timer+delay!
'end of frames loop
loop

Be warned: SCREENSYNC may interfere with it
Antoni
Reply
#4
Alright, thanks. I haven't gotten it tested on other machines yet, but altering the variable causes it to run at the speed that it was set at, at least as far as I can tell.

But now, the FullScreen mode is all that causes problems.

EDIT: Not... anymore!! HAHAHAHAHAHHAHAHAAAAH!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)