简体   繁体   English

opengl glutWireTorus工件

[英]opengl glutWireTorus artifact

I am working on a small animation of a sinewave being generated by a moving circle similar to this gif . 我正在研究由类似于此gif的运动圆产生的sinewave的小动画。

However I'm having a weird issue with using glutWireTorus for the circle. 但是我在使用glutWireTorus圈子时遇到了一个奇怪的问题。 Even when I comment out all the other drawing code and leave the torus moving along the z axis alone, I get flashing lines on the inside of it: 即使当我注释掉所有其他绘图代码并使圆环仅沿z轴移动时,其内部也会出现闪烁的线条:

屏幕截图

This is the display function where everything is drawn. 这是显示所有内容的显示功能。 I use the display function as my idle function, also, I checked if that was the issue by creating an idle function and putting my update code there but it still persisted. 我将显示功能用作我的空闲函数,而且,我通过创建一个空闲函数并将更新代码放在此处来检查是否是问题所在,但它仍然存在。

void display(void)
{
    glClearColor(0.f,0.f,0.f,0.f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear the color buffer 
                                                           and the depth buffer

    glLoadIdentity();
    glTranslatef(0.0f,0.0f,-5.0f); //Push everything back 5 units into the scene, 
                                     otherwise we won't see the primitive 
    camera();    
    //yPrev = myCircle.y;

    glPushMatrix();         
    glTranslatef(0.0f,0.0f,t);
    glutWireTorus(0.02,1,100,100);   
    glPopMatrix();

    DrawAxes();    
    glutSwapBuffers(); //swap the buffers   
    glFlush();//Flush the OpenGL buffers to the window

    t-=0.002;

    if (t < -T)
    { 
        t = 0;
    }
}

Uh, interesting, I run into the same problem. 嗯,有趣的是,我遇到了同样的问题。 Here is the picture using parameter 这是使用参数的图片

glutWireTorus(/*innerRadius*/0.3, /*outerRadius*/0.5, /*nsides*/32, /*rings*/32);

圆环32x32

another picture using parameter 使用参数的另一张图片

glutWireTorus(/*innerRadius*/0.3, /*outerRadius*/0.5, /*nsides*/64, /*rings*/128);

圆环的64x128

We don't know why without glutWireTorus function implementation, but we can implements our own torus, or maybe someone can explain it? 我们不知道为什么没有glutWireTorus函数实现,但是我们可以实现自己的环面,或者有人可以解释它?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM