Windows Menu & OpenGL

Started by
12 comments, last by JakeM 16 years, 1 month ago
Hi AhmedSabry1975,

Short of posting all you code here, you could try and find various examples of Opengl with mfc that work and compare them to your app (i.e use them as a reference).

e.g.

(1)http://support.microsoft.com/kb/127071 for rendering in CWnd derived views.
Maybe this is one you have seen already?

(2)http://www.gamedev.net/reference/articles/article1358.asp titled "Creating 3D Tools with MFC" using View/Doc.

Advertisement
I did see the links that you sent, and even more I had seen many other links on the web, and all of them do the same code
I think this is related to the order of execution between the windows erase background procedures and the my render function
I don’t know exactly
But I did tries of the same code in different machine that have WinXP installed on it
And I got surprised coze I found some pc's that don’t have the problem and the menu shadow didn't appeared at all, and other pc's have the same issue as my PC.
I got the feeling that this is related to the OpenGL drivers that came with different graphics cards.
It sounds to me as like it is a problem with clip rects. OpenGL usually draws to the device contex of your full window. MFC on the other hand tends to just redraw bits that need to be redrawed. So in your OnPaint or OnDraw function, think OnDraw is more traditional with MFC? the clip rectangle being sent is probably just for where the menu was before on some calls. I would ensure that you redraw the entire screen with OpenGL at these times. Probably the easiest way to do this is to call the Invalide function after your menu has been clicked? Or at least somewhere you probably need an Invalide(FALSE), TRUE means erase doesn't it? Oh in addition, you don't really want MFC to erase your backgrounds for you, so I would override the OnErase member of your CView Derived class and ensure that it doesn't call the base class. That way openGL does all the erasing and drawing and it won't be fighting with MFC. As someone else pointed out, you also need to make sure you have binded OpenGL with your device context, which i assume you have done if your able to see any OpenGL graphics at all. Note also that even if you are using SDI app rather than MDI app, it still uses document/view architecture, only you are restricted to single document. You should still do all your rendering in your view and all your storing of data in your document object.

Good luck, Dan
OpenGL windows must be created with the clip flags:

BOOL CGLView::PreCreateWindow(CREATESTRUCT& cs) { cs.style |= WS_CLIPSIBLINGS | WS_CLIPCHILDREN; return CView::PreCreateWindow(cs);}

This topic is closed to new replies.

Advertisement