rhino's picture

proper gameloop with glControl, how?

I've looked at the glControl sample in the release zip, and it displays a rotating cube.

However, it does not split the rendering and the logic code. Instead it draw the render as fast as it can in the idle cycles, and in the same function updates a rotate variable.

On my computer this results in a jerkely rotating cube.

In the 15 minute intro into opentk, it is said that one can override an onUpdatFrame method and an onRenderFrame method.
This seems more logical as you can now split the update and the render logic (as it should).

However I don't see how this should work with the glControl sample. Can anyone give me a pointer?


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Mincus's picture

Overriding the OnUpdate/OnRender is part of GameWindow, not GLControl.
All the control over when to render/update is placed on you with the GLControl. The easiest way to do "render as fast as possible" is to render whenever the form is idle, as The Fiddler describes here: http://www.opentk.com/node/1601#comment-8541.
Updating could then be done either by using a StopWatch to call the render code every so many ms in the Idle code you just wrote or using a Timer control.

rhino's picture

ok thanks!