Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: MFC and openGL.

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2002
    Location
    Israel
    Posts
    5

    MFC and openGL.

    Until now I used openGL on a Dialog Based Application, more specifically on a Picture object from type Frame (Which is derived from CWnd), now I opened an MDI application and I try to do the same thing to the CView window but it doesn't draw. The window becomes black as I wished it will but when I draw a sphere with gluSphere function it doesn't show up. It is not a problem of redrawing the screen, I have done this drawing in the OnPaint (at the beginning I tried in OnDraw too) and I tried moving the window (which make it redraw it self), but nothing shows up, only a black window (the client area).
    Is there anything I need to do different in a CView window from a Picture object?
    If anybody has any ideas to why this is happening, I would like to hear them.
    Thank you in advance,
    Sela.

  2. #2
    Junior Member Newbie
    Join Date
    Apr 2003
    Posts
    19

    Re: MFC and openGL.

    I did somthing like this a while ago.
    I made a class CRenderWnd which extended CWnd. In my CFormView derived class's OnCreate(), I just created a new instance of the CRenderWnd -

    m_renderWnd.Create(NULL,"RenderWindow",WS_CHILD|WS _CLIPSIBLINGS|WS_CLIPCHILDREN|WS_VISIBLE,rect,this ,IDC_RENDER_WINDOW,NULL);

    I seem to remember having to put a glFinish() at the end of the CRenderWnd's OnPaint.

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2002
    Location
    Israel
    Posts
    5

    Re: MFC and openGL.

    No, didn't do no good. The screen stays black and empty. Any other ideas?

  4. #4
    Junior Member Regular Contributor
    Join Date
    Aug 2002
    Location
    philadelphia, pa, usa
    Posts
    108

    Re: MFC and openGL.

    i don't think that moving a window will cause OnPaint() or OnDraw() to be called. i could be wrong though. are you sure that your OnPaint() is being called? are you sure that your modelview and projection transformations are set up appropriately? it'd also be useful to see your OnPaint() method.

  5. #5
    Junior Member Regular Contributor
    Join Date
    Aug 2002
    Location
    philadelphia, pa, usa
    Posts
    108

    Re: MFC and openGL.

    also, are you sure you're calling SwapBuffers() when you're done rendering?

  6. #6
    Guest

    Re: MFC and openGL.

    I find using a timer to schedule OnPaint at regular intervals (50ms) useful.

    Is that any help?

  7. #7
    Junior Member Regular Contributor
    Join Date
    Aug 2002
    Location
    philadelphia, pa, usa
    Posts
    108

    Re: MFC and openGL.

    well if you stick a breakpoint in your OnPaint(), does it get hit? i'm just trying to eliminate the obvious here. you said the screen is getting cleared, but for all i know you did that right after you initialized gl and not necessarily in the OnPaint() method. can we have a look at your OnPaint() method?

    how about the other stuff i mentioned? are you calling SwapBuffers() at the end of the OnPaint()? are you certain your transformations are set up appropriately? do you have lighting enabled and set up correctly, or are you just using solid colors? it's difficult to say what's going wrong without actually looking at the code, because it could be any number of things.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •