The Artima Developer Community
Sponsored Link

C# Answers Forum
OpenGL and C#

1 reply on 1 page. Most recent reply: Aug 13, 2003 1:15 AM by alex

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Alexandru Ruse

Posts: 6
Nickname: jfrosty
Registered: Jul, 2003

OpenGL and C# Posted: Jul 25, 2003 2:07 PM
Reply to this message Reply
Advertisement
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.


alex

Posts: 1
Nickname: avenger
Registered: Aug, 2003

Re: OpenGL and C# Posted: Aug 13, 2003 1:15 AM
Reply to this message Reply
It's pretty simple. This is how I'm doing those things :

while(this.Created) {
this.Render();
Application.DoEvents();
}

Flat View: This topic has 1 reply on 1 page
Topic: help me - quit option Previous Topic   Next Topic Topic: Streaming Video

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use