
Question about Run()
Posted Friday, 1 February, 2008 - 11:08 by kungfoo inI stepped right into this framework and wanted to draw a few triangles at first.
Two snips coming up:
// (A) win.Run(60,0) // (B) win.Run(60,30)
Method (A) gives my Windows task manager (yikes Windows... but #develop just works here) a total load of about 5%.
Method (B) always yields around 55% CPU usage. Is there something I'm missing? (A) just renders as many frames as possible, and updates the world at 60s^-1.
I figured the other method would be using less CPU time. Maybe the overhead results from Thread.Sleeps?
Any ideas on this? Bug or feature?


Comments
This could happen if VSync
This could happen if VSync is on. Here is what is happening:
In the first case, your CPU will sleep e.g. 85 times per second, waiting for the swap to finish. In the second case, it would only sleep 30 times per second, hence the higher CPU usage.
OpenTK itself doesn't sleep at all, because there were some problems with timing. Once I fix these, we'll see reduced CPU usage in all cases.
Re: Question about Run()
Was this ever fixed? There still does not appear to be any sleep function used and CPU usage is out of control. Is there anything that can be done to limit frame-rates without using 100% CPU (or a whole core)?
Re: Question about Run()
You should enable vsync or call System.Threading.Thread.Sleep(n), where n >= 1, right after SwapBuffers().
Re: Question about Run()
I achieved the best results setting n to the exact time until the next render is required to maintain the target fps. Still seeing very high CPU usage though so I was wondering if there were any other tricks (already using adaptive vsync).