Rotating Line Strips in OpenGL

Started by
0 comments, last by drstrangeluv 24 years, 3 months ago
I'm having a problem rotating line strips in OpenGL. When the line strip is first rendered, it appears just fine; however, as the line strip is rotated, it eventually disappears and then reappears as it approaches its original orientation. It seems that the "back" of the line strip isn't being shown, but this is only an assumption on my part. Any ideas on what might be wrong?

Thanks.

Advertisement
I think this is due to your lighting / material setup. You should have the lights set to GL_LIGHT_MODEL_TWO_SIDE, and the appropriate color. You should set the material properties to the appropriate ambient and diffuse colors. for instance:

GLfloat ambient[] {0.5,0.5,0.5,1.0};
GLfloat diffuse[] {1.0,1.0,1.0,1.0};
glMaterialfv(GL_AMBIENT, ambient);
glMaterialfv(GL_DIFFUSE, diffuse);
glColorfv(diffuse);

will set up a "white" material with a half gray "unlit" color. this tends to work well to give the appropriate lighting cues, and yet not cause dissapearing lines. The glColor*() function gives the appropriate color to the object in case lighting is turned off... not needed unless you plan to turn lights off for some reason.

If you turn off lighting before drawing your lines, you will note that the line looks complete. I have found that adjusting the ambient material properties works well in lighted scenes to avoid the annoying vanishing lines.

This topic is closed to new replies.

Advertisement