Jump to content
  • Advertisement
Sign in to follow this  

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

This topic is 3717 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
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();

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

Share this post

Link to post
Share on other sites
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]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!