0

I am rendering a pointcloud, but when I move the camera, points begin to flicker(youtu.be/wMTVID7NATo).

The strange thing is that the flicker disappear or is reduced when I change either the clear colour or the colour of the points. For example glClearColor(0, 0, 0, 1) and glColor3f(0.5f, 0.5f, 0.5f) causes flicker, but this flicker is gone when I use glClearColor(1, 1, 1, 1) or glColor3f(1, 1, 1).

What is causing this flicker and how can I get rid of it without changing clear or point colour?

Here is my code:

int main(int argc, char** argv) {
    glutInit(&argc, argv);   
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); 
    glutInitWindowSize(640, 480);
    mainWindow = glutCreateWindow("MyWindow");
    glutTimerFunc(1, timerRoutine, 0);
    glutDisplayFunc(displayFunc); 
    glutMotionFunc(motionFunc);
    glutMouseFunc(mouseFunc);

    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

    glEnable(GL_DEPTH_TEST); 
    glDepthFunc(GL_LEQUAL);
    glClearDepth(10.0f);  
}

void timerRoutine(int t) {
    glutPostRedisplay();
    glutTimerFunc(t, timerRoutine, 0);
}

void displayFunc() {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glBegin(GL_POINTS);
    for (int i = 0; i < pointCount; ++i) {
        glColor3f(points[i].getIntensity(), points[i].getIntensity(), points[i].getIntensity());
        glVertex3f(points[i].getX(), points[i].getY(), points[i].getZ());
    }
    glEnd();
    glutSwapBuffers();
}

void mouseFunc(int x, int y, int z, int w) {
    if (x == 0) {
        if (y == 0) { //LMB Down 
            leftMouseButton = true;
        }
        else if (y == 1) { //LMB Up
            leftMouseButton = false;
        }
    }
}

void motionFunc(int x, int y) {
    if (leftMouseButton ) {
        camera.rotate(y, 0, x)); //Apply rotation to GL_MODELVIEW
    }
}
  • 1
    What is clearBuffer? Is it possible to record video with flicking? – Unick Aug 30 '16 at 11:39
  • 1
    Could you please disable glutTimerFunc? Why do you call register callback inside callback? – Unick Aug 30 '16 at 11:41
  • I need glutTimerFunc to make sure displayFunc is called ferquently. – Kay Goossen Aug 30 '16 at 12:41
  • 1
    I think glut will call display about 60 fps. I think timerRoutine(int t) should be simple "glutPostRedisplay();". – Unick Aug 30 '16 at 12:49
  • 1
    Could you please attach screenshot with flicker? It is hard to understand, what is going wrong. – Unick Aug 30 '16 at 13:28
  • https://youtu.be/wMTVID7NATo – Kay Goossen Aug 30 '16 at 13:43
  • 1
    I marked problem on image https://cloud.mail.ru/public/Afu7/MSiRXCFB2 Is it correct? It looks like z-fighting problem. What is the range of point coords? – Unick Aug 30 '16 at 15:02
  • 1
    Do you draw only white points? What is the color of points? – Unick Aug 30 '16 at 15:07
  • Unick - This is different problem that isn't addressed yet. The points are some random points taken from a larger file, but there is no effort is done yet to make sure these random points are uniformly distributed + when there are fewer points inside the frustum more points will be loaded. The point count in the darker area to the left of the marked area didn't change in the video, but is constantly flickering. – Kay Goossen Aug 30 '16 at 15:43
  • The points have grey values in the range 0.2 till 1.0 – Kay Goossen Aug 30 '16 at 15:46

0 Answers0