Вопрос

I have a problem with glRotatef() function, I want to pause this function when user press Space, I've googled how to store curent function x,y,z but I've nothing found. There is a function in OpenGL glGet() but it can't get x,y,z coordinates. That's what I've done so far:

glPushMatrix();                                     
    if(flag==0)
    {

        glTranslatef(20,5,-10);
        glRotatef(0.8f, 0.8f, 1.0f, 0.5f);
        drawCube();     
    }
    else {
        glTranslatef(20,5,-10);
        drawCube(); 
    }
    glPopMatrix();  

and for Space event:

case VK_SPACE:
                if(flag==0)
                    flag=1;
                else
                    flag=0;
                break;

this work in some way but only not in that way I need. I need to store the position of the cube when user pressed Space and when the user hit again space to continue from curent position.

Это было полезно?

Решение

first thing: old style openGL? please look into upgrading

second create a cubeAngle variable

in your update function increment it with how fast you want to rotate (multiplied by the delay between updates) only if flag==0

then

glPushMatrix();                                     

    glTranslatef(20,5,-10);
    glRotatef(cubeAngle, 0.8f, 1.0f, 0.5f);
    drawCube();     

glPopMatrix();  
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top