FPS code for use with VWAIT FLIP FALSE
Blitz3D Forums/Blitz3D Beginners Area/FPS code for use with VWAIT FLIP FALSE
| ||
Can someone point me to some code to show me a FPS counter when using VWAIT FLIP FALSE ? |
| ||
the code remains the same, althought your rate will be limited to the vsync rate, of course. Simply add this somewhere in your mainloop: old_t=t t=millisecs() frametime#=t-old_t fps#=1000.0/frametime You may calculate the average fps over 30 or so frames. |
| ||
Dont know if this helps, it was adapted from a limit idea i found ages ago in the codearcs and rewritten to add fps details etc. its what i use when im not using the render tweening. It basically mesures cycles per second (which if no tween is used, is FPS) It also limits the framecount to a set value so a fast machine will not go higher than the maximum FPS. Try loading this code up with some time consuming maths and you will see the FPS (as long as its less than 30) change accordingly otherwise it will remain stable at 30ish init_FPSlimit(30) repeat ;get program cycles per second fps=limitfps() text 10,10,str(fps) vwait() flip() until keyhit(1) Here are the functions you need Global g_FRate,G_fpsbase ,G_framecount Global G_ftime1,G_ftime2,G_ftime3,G_ftime4 Function init_FPSLimit(f) g_FRate=(1000/f) G_ftime1 = MilliSecs() End Function Function LimitFPS() G_ftime2 = MilliSecs() G_ftime3 = G_ftime2 - G_ftime1 G_ftime4 = g_FRate - G_ftime3 Delay G_ftime4 G_ftime1 = MilliSecs() ;count frames in 1 sec and return it (or you can read it by using FPScount at any time G_framecount=G_framecount+1 If MilliSecs()>G_fpsbase+1000 G_fpsbase=MilliSecs():FPScount=G_framecount:G_framecount=0 Return FPScount End Function |
| ||
cool - will give them a go I seem to have framerate stability issues - sometimes framerate is fine, others things seem to slow down a periodically. I've got an Athlon 2800 XP and am running internet browser in background, and a paint package. Are there any implications when using VWAIT FLIP FALSE when running in a window ? |
| ||
flip false isnt a good thing if you have 2d over 3d. Why are you using flip false? Im not 100%sure what the implications are in a window. for all my stuff i tend to use vwait:flip seems 2 work ok :) |
| ||
Strange - FPS is shown to constantly switch between 62.5 & 58.5 |
| ||
I haven't got ANY 3D in at all - its all 2D. I'm just using Blitz3D cos thats the package I bought. Question - when running a Blitz3D application fullscreen, is everyone's CPU utilisation at 100% like mine is ? |
| ||
with flip false it will run "as fast as it gets" on all machines. You need to pause the game to give reseouces back to the OS. Typically you would vsync the game. Since the machine waits for the next sync, you would already give it as much back as the game doesn't utilize with the current framerate. You can try both: while keydown(1)=0 vwait flip 0 wend and while keydown(1)=0 flip 0 wend or you could even try: while keydown(1)=0 delay 200 vwait flip 0 wend but of course, a framerate of 4 fps is kind of low. you should see the diffrence now. (Someone correct me if I'm wrong :) although I thought I know this stuff ) |
| ||
For 2D, I use "vwait:flip false" in conjuction with a timer set to the desired FPS rate. If the FPS doesn't divide into the monitor's refresh rate exactly then things aren't 100% smooth but it's as good as it gets. As for an FPS counter, I find it's much better if you only update the counter display once a second. This stops the counter constantly flashing between different values, making it hard to read. Here's some template code showing both things: |
| ||
thanks |