I've been playing with the CsGL library for a few days, and I have this little "problem". It's not related to CsGL, actually, but with Windows Forms. The thing is, when you're writing a 3D app, you want to update the screen as fast as possible. In C and the Win32 API, it was pretty simple: you replaced GetMessage() with PeekMessage(), and when there was no message to process (i.e. you were idle), you rendered the scene:
while(true) {
if(PeekMessage(&msg, hWnd, 0, 0, PM_REMOVE) {
if(msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
} else {
// no message, we can render
drawScene();
}
}
Now, my problem is that I can't do that in .NET. There's no such thing as a message loop. I thought there might be some Idle callback (delegate, whatever) on my Form, so I can plug drawScene() to it, but there wasn't. I found one on the Application object (!), but even after I added an EventHandler to it, it didn't work (the GL view would update only if I moved the mouse really fast in the client area). Besides, Application.Idle is too "global" for my taste. Rigth now, I'm doing it with timers: each 10 ms, I trigger a redraw. But this isn't efficient, and it locks me down to a fixed framerate. And what if the system is too slow? All those unprocessed WM_TIMER messages that would queue up... If anyone has a better idea, I'd appreciate it.