Advertisement Jump to content


This topic is now archived and is closed to further replies.


OpenGL OpenGL MFC problem

This topic is 6886 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''ve been trying to solve this problem for the last week and I''m still having problems. The problem is when trying to use an MFC MDI with OpenGL, I''ve been using some of NeHe''s tutorial code, to write to the child window. Everything works except when I try to resize the child window the image that is displayed in the window (a white triangle) vanishes. I''m at my wits end, if any one can help I would be most apreciative. I''ve included the contence of my OnSize function, the variable m_hrc is a HGLRC, and is defined as private in the view class. The display functions, OnPaint and OnSize are both members of the view class. //OnSize Function CClientDC clientDC(this); wglMakeCurrent( clientDC.m_hDC, m_hrc); if(cy == 0) { cy = 1; } glViewport(0, 0, cx, cy); glMatrixMode(GL_PROJECTION); gluPerspective(45.0f, cx / cy, 0.1f, 100.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); wglMakeCurrent(NULL, NULL); //End of Function Thanks in advance.

Share this post

Link to post
Share on other sites
Umm, it might be that you have no current OpenGL context at the end of the function, but since you''re programming in MDI that''s most likely not the problem.
Ahhh!! you do not load the identity into the perspective matrix before setting it!!
It will add it to the current matrix.. that might be it

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!