PDA

View Full Version : need help on opengl and MFC!



coda
10-04-2003, 09:20 PM
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:
if(m_dialog.DoModal()==IDOK){

then i draw...glbegin
..
...
..
..
glend}

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...

mikael_aronsson
10-04-2003, 11:26 PM
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...

Mikael

coda
10-05-2003, 12:46 AM
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

mikael_aronsson
10-05-2003, 10:30 PM
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.

Mikael