How to make movement in the opengl window from mfc dialog.

Started by
2 comments, last by Dathu 15 years, 12 months ago
Hi I have created an opengl child inside and mfc dialog.you can refer link: http://www.codeguru.com/cpp/g-m/ope...icle.php/c5583/. Now I included two edit boxes at the side of the opengl window and a button. Now my question is how to make movement for the triangle from the edit boxes (The edit boxes are x,y coordinate values ).Once I enter the x,y values and press the button the triangle should move according to the given x,y coordinates. can any one give the solution.
Advertisement
You need to call the render function, upon pressing enter key

And inside the render function, you need to load a translated matrix,
defined the values, in your edit controls.
Gents nandu Intelligents veyrayaa
You have to map commands from the edit boxes into the mainframe message queue
There is a bit of work involved , first, map the messages from the edit box, they will be queued into the window owning the control, then , once you have mapped successfully the messages, redirect to the view class , normally i do this because the view owns the opengl rendering context.

So, what you have to do is

Map messages from the control into the window owning the control itself
normally , click on the class name , a window appears with all the commands
avaible for the control you are inspecting.
Visual studio will write the function for you, you only have to
put your code there.

Get the mainframe pointer with this line :

#define MAINFRAME ( (CMainFrame*) AfxGetMainWnd() )

this will provide access to the mainframe more easily , put this into the view class .cpp file

normally messages are routed towards the mainframe class so , when you want to perform an action into the opengl view do this :

CView *pView;
pView=( CMainAppView* ) GetActiveView();
pView->Invalidate(FALSE);

this will give you control for the view class from the mainframe
note that all the controls are owned by the mainframe
so you are forced to follow this route.

Hope i have helped
Hi ,

I have choosen dialog based application from MFCAppwizard.I have created two dialogs one is main dialog in which I placed a button once I pressed that button another dialog will come by using 'DoModal' function,this dialog is inserted from resources and it is derived from CDialog base class.In that dialog I created opengl window. This opengl window is created by using another class which is derived from genericCWnd class,In that class I have taken WM_PAINT,WM_CREATE message handlers which used to create and paint the opengl window.All things are working fine i.e once I pressed the first button It is calling another dialog and In which opengl window also drawn in that opengl window I drawn one triangle.
Now my problem is I have to place two edit boxes and one button in second dialog(which is having the opengl window)and I'll give x value in one edit box and y value in another edit box, Now I'll press that button according to the given x,y values the primitive(or object) should move.

[Edited by - Dathu on April 21, 2008 11:46:58 PM]

This topic is closed to new replies.

Advertisement