如何动画实心球体上的曲线球体、实心、曲线、动画

由网友(笑着看你离开)分享简介:我是做节目在OpenGL动画固球在曲线它是这样//显示功能i am making a program in opengl to animate a solid-sphere over a curveit goes like//display function void display() { glC...

我是做节目在OpenGL动画固球在曲线 它是这样 //显示功能

i am making a program in opengl to animate a solid-sphere over a curve it goes like //display function

void display()  
{  
    glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);  
    glLoadIdentity();  
    //set of condition   
    loop:j=1 to 5  
        loop:i=1 to 3  
            if(j==1)
            {  
                animate(x,y,z)  
                glutSwapBuffers();
            }
            elseif(j==5)
            {  
                animate(x,y,z)  
                glutSwapBuffers();
            }  
            else //for all value j between 1 and 5
            {  
                animate(x,y,z);  
                glutSwapBuffers();
            }  
}  

//animate function  
void animate(float x, float y, float z)  
{  
    glLoadIdentity();  
    glTranslatef(0,0,-20);  
    glPushMatrix();  
    glTranslatef (x, y, z);  
    glutSolidSphere (0.3, 10, 10);  

    int i, j;  

    for(i = 0; i < 10000; i++) //for introducing delay  
        for(j = 0; j < 5000; j++);


    glPopMatrix();  
    glutSwapBuffers();  
}  

问题:实心球是翻译过的曲线,但其每下一个 位置我不能够删除其previous位置...例如 如果球体变为从像P1,P2,P3,P4和THEN P5..after位置序列 来位置P5它在所有其他人仍清晰可见previous位置(P1,P2,P3,P4) 但我希望它只是在目前的翻译时位置显示领域 我怎样才能做到这一点?

Problem:the solid sphere is translating over the curve but for its each next position i am not able to remove its previous position...for instance if the sphere goes from sequence of position like P1,P2,P3,P4 AND THEN P5..after coming to position P5 its still visible at all others previous position(P1,P2,P3,P4) but i want it to display sphere only at current position while translation How can i do this?

推荐答案

您不能清除帧缓冲,这意味着要绘制在previous框架顶部每一帧。尝试使用 glClearColor(0.0,0.0,0.0,1.0F); 与你想要的颜色

You are not clearing the frame buffer, which means that you are drawing each frame on top of the previous frame. Try using glClearColor(0.0f, 0.0f, 0.0f, 1.0f ); with the color you desire.

阅读全文

相关推荐

最新文章