PDA

View Full Version : Strange rendering flicker



Goossen
08-30-2016, 08:09 AM
I am rendering a pointcloud, but when I move the camera, the points begin to flicker(http://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
}
}