Multiple openGL windows in MFC dialog

I have a MFC dialog control with numerous standard MFC controls (i.e. push buttons, lists etc).

I have also created 4 openGL windows, however when I resize my dialog the openGL windows drawing area does not resize with it?

My openGLControl class has CWnd as its base class.

I use MoveWindow ( a, b, c, d ) to change the size of my openGL window. The openGL area changes size, just the area that is used for drawing does not change? Anyone experienced this before? Or have any ideas on how to fix this?

Any help much appreciated.


Are would calling glViewport again in OnSize?

yes I am.

Here is the code in OnSize()

void COpenGLControl::OnSize( UINT nType, int cx, int cy )
CWnd::OnSize( nType, cx, cy );

if (cy == 0) cy = 1;

glViewport( 0, 0, cx, cy );
glMatrixMode( GL_MODELVIEW );

glOrtho( -1.0, 1.0, -1.0, 1.0, 1.0, -1.0 );

glMatrixMode( GL_MODELVIEW );


glOrtho should be used on the projection matrix, not the modelview matrix.

You say that you GL windows are embedded in CWnd objects? Well you need to rezise the CWnd objects in the dilog in the OnSize method in the CDialog.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.