Results 1 to 6 of 6

Thread: OpenGL/MFC: Losing dialog controls?

  1. #1
    Member Contributor
    Join Date
    Jul 2002
    Location
    Southampton, PA, USA
    Posts
    61

    OpenGL/MFC: Losing dialog controls?

    Hi,

    I am attempting to render an OpenGL scene into an object in a dialog box. However, as you may well know, by default this only renders the scene once, making animation impossible.

    The workaround that was suggested to me first was Invalidate(FALSE) along with returning a TRUE value in the OnEraseBkgnd() handler. While this method does animate my 3D scene correctly, it causes my dialog controls (currently just a few buttons) to not be rendered on resize or restore.

    There are several other methods that I've read about to do what I need...some use counters, others seem to rely on ShowWindow(SW_SHOW).

    What method would you suggest, and how can I implement it? How exactly would I use a counter in an event-based system?

    Thanks!

  2. #2
    Senior Member Regular Contributor
    Join Date
    Sep 2002
    Location
    Nanjing,China
    Posts
    116

    Re: OpenGL/MFC: Losing dialog controls?

    I don't know much about MFC.But basically,once you can use getDC() to get the hdc of that dialog handle.then use wglMakeCurrent to register this hdc (maybe you need to do some other registration stuff,check out the red book and nehe tutorial for more detail , and start a thread include a loop like while(true) to draw gl scene ,you might include swapbuffer something.



    [This message has been edited by RunningRabbit (edited 06-25-2003).]

  3. #3
    Member Contributor
    Join Date
    Jul 2002
    Location
    Southampton, PA, USA
    Posts
    61

    Re: OpenGL/MFC: Losing dialog controls?

    Wouldn't that prevent any other messages from getting through, though?

  4. #4
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Posts
    340

    Re: OpenGL/MFC: Losing dialog controls?

    You could use a timer...

  5. #5
    Member Contributor
    Join Date
    Jul 2002
    Location
    Southampton, PA, USA
    Posts
    61

    Re: OpenGL/MFC: Losing dialog controls?

    Ok, I used SetTimer(1,1,NULL) and in OnTimer I call Invalidate(FALSE).

    It seems to be working. Are there any negative effects of using this method that anyone can think of (other than a theoretical limit on max FPS; ~30fps should be fine for my application).

  6. #6
    Senior Member Regular Contributor
    Join Date
    Sep 2002
    Location
    Nanjing,China
    Posts
    116

    Re: OpenGL/MFC: Losing dialog controls?

    Invalidate(NULL) pull down the performance a lot.

    In MFC ,every application has OnIdle() method which is called in the winmain message loop.
    CWinApp::OnIdle(). Overload this method and repaint the GLscene in this method



    [This message has been edited by RunningRabbit (edited 06-27-2003).]

Similar Threads

  1. Replies: 0
    Last Post: 08-24-2017, 06:23 AM
  2. OpenGL rendering error on losing focus
    By manikandtan.ck in forum OpenGL: Windows
    Replies: 0
    Last Post: 01-07-2013, 04:47 AM
  3. Replies: 1
    Last Post: 10-11-2005, 07:39 PM
  4. Window Controls In OpenGL?
    By Sephiroth in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 03-25-2003, 01:07 PM
  5. OpenGL losing context
    By nic in forum OpenGL: macOS
    Replies: 0
    Last Post: 07-17-2002, 02:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean