need help on opengl and MFC!

i have an MFC exe (SDI) and several dialogs within this SDI. Based on the inputs from this dialog, i will draw graphics onto SDI window. Problem is, i was coding say drawing a rectangle in my View.cpp under ONPAINT(), so when i tried to set the criteria in this function:

then i draw…glbegin


but erm i get assertion error. the main point is, I do not want the window to have an image when i start running the program but rather after user open program and open dialog and then click say “OK” on dialog then thw view will show something…so i not sure whether i did the correct thing by coding my drawing in the view or should i code in my dialogs.cpp then point to SDI to view? need advice please and i am a beginner to this programming stuff…

Hi !

I don’t have a clue what you are trying to do, but if I did get some of it correct, then you should put som ekind of state variable in your view, set it to false in the CView constructor and when the user close the dialog set the state variable to true and send InvalidateRect() message to the view.

In the paint code you just put an if to handle the drawing…

if( state == true)
render opengl…

But as I said, I am not sure what you are trying to do, so I might be swimming far out in the ocean of pixels here…


yah something like that, that means after user runs the SDI program, access a dialog within and input the rect dimemsions and click “OK” then only will my rect appear in the SDI view. Can u elaborate what is the InvalidateRect() message? thanx

Hi !

The InvalidateRect( NULL) method tells Windows to repaint the window as soon as possible, so if you have changed anything so your OpenGL contents needs to be updated, Windows will make sure you get a WM_PAINT message as soon as possible.