OpenGL in MFC


I am a beginner in OpenGL and I am trying to learn Opengl with MFC. I have setup the opengl view class and all. I have created a dialog which will will get the vaules of x, y , z to translate and rotate. The problem is when I try it , it works perfectly well for the first translations in any axis. But the next time, when i pull down the dialog it does not work. The translation values come from the dialog and controls correctly and the values get correctly passed to the glTranslatef(), but there is no change in the rendering. I have called the InvalidateRect() for every change in the translation values and the OnDraw() does get called and the values do enter the functions to translate. But there is no change on the screen

Could anyone help me out on this…

Thank you



First off, this is not an advanced question. Please post such questions in the beginners forum.

As for your question …

Are you swapping your buffers using SwapBuffers(HDC)? You will need to do that in case you are using double buffering, otherwise the data will always be in the back buffer and never show up on screen.

Secondly are you pushing the modelview matrix before calling translatef? i.e.

glTranslatef(x, y, z);
// do rendering

that would be the correct way to render multiple (or even one) object(s) with different translations and rotations in the entire scene.