Resizing of the opengl window along with mfc dialog

Started by
2 comments, last by LordOrion 15 years, 12 months ago
Hi, I developed one dialog based applicaation in mfc appwizard,now I have created opengl window in that dialog (by using one class in that I have taken WM_CREATE AND WM_PAINT message handlers)and I placed some controls on that dialog(ex:edit box and bottons)and I make the dialog as resizable.All are working fine (i.e. I can see the opengl window in that window I render one quad ,and controls which I placed in that dialog)i.e. when I execute the program, I can see that dialog in that, one opengl window and cotrols, now my problem is when I resize the dialog with cursor only dialog is going to resize but not the controls and opengl window.But I want that opengl window and controls should be resize. How can I achieve this problem.
Advertisement
You will need to use glViewPort() when ever the screen size is changed.
Hi

I am beginner for the opengl and mfc application. so have not understood where to take the glviewport() (i.e. in opengl class or dialog class)and is it necessary to take any message handlers like wm_size like that.Can u please expalin in some detail.

Thanks in advance.
Hi,
you have to call it where you handle the WM_SIZE message. You can find detailed reference of this function here:

http://opengl.org/sdk/docs/man/ (open it and click on glViewport link on the left bar).

however, the following is the function I use to call to handle the screen resizing: juts call it when you receive the WM_SIZE message passing it the new with and height of the rendering window:

#define _CLIP_NEAR		1.0f#define _CLIP_FAR		100.0f#define _FOW			60.0fvoid resizeScreen ( INT iWidth, INT iHeight ){	if ( iHeight == 0 ) )		iHeight = 1;	// Set the new ViewPort:	glViewport( 0, 0, iWidth, iHeight );	// Setup the projection matrix:	glMatrixMode( GL_PROJECTION );	glLoadIdentity();		// Compute the screen aspect ratio.	GLdouble dAspectRatio = ( (GLdouble)iWidth ) / ( (GLdouble)iHeight );		// Set the perspective projection matrix.	gluPerspective( _FOW, dAspectRatio, _CLIP_NEAR, _CLIP_FAR );	glMatrixMode( GL_MODELVIEW );	glLoadIdentity();} // resizeScreen()


I suggest you to carefully read the documentation of all the gl and glu functions I've called here and understand what they do and why they should be called. You can find the reference of each one of them at the link above


I hope this can Help.
Bye and Thanks!SiS.Professional Software Developer.

This topic is closed to new replies.

Advertisement