View Full Version : MFC and openGL.
06-04-2003, 08:32 AM
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,
06-04-2003, 10:11 AM
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 -
I seem to remember having to put a glFinish() at the end of the CRenderWnd's OnPaint.
06-04-2003, 11:08 AM
No, didn't do no good. The screen stays black and empty. Any other ideas?
06-04-2003, 01:58 PM
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.
06-04-2003, 02:07 PM
also, are you sure you're calling SwapBuffers() when you're done rendering?
I find using a timer to schedule OnPaint at regular intervals (50ms) useful.
Is that any help?
06-04-2003, 06:59 PM
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.