PDA

View Full Version : OpenGL in MFC



infinitecmdz
09-07-2005, 10:22 AM
Hi,

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

yours

siddharth

Zulfiqar Malik
09-07-2005, 08:12 PM
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.

glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glTranslatef(x, y, z);
// do rendering
glPopMatrix();

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