View Full Version : rotating triangles

10-20-2009, 07:15 AM
I had a previous similar post, now I have a higher quality video demonstarting the problem:

So I'm rotating triangles, but there seems to be jumps in lighting. Is it because some kind of Z fighting? ( I tried with single triangles and with duplicated triangles, but opposite normals.) Do I have to rotate the lights in the opposite direction relative to the camera? Do I have to rotate lights at all?

The current code:

void update(int v){
if (play){

glLoadIdentity(); //Reset the camera


GLfloat lightPos0[] = {-1.0*sin(angle+80.0), cos(angle+80.0), 0.1f, 1.0f};
glLightfv(GL_LIGHT0, GL_POSITION, lightPos0);

angle = angle + 0.03;
glutTimerFunc(50, update, 0);

10-20-2009, 07:16 AM
By the way I'm experiencing very high CPU load with glut (eats one core completely), even if I take down the framerate. Is it normal?

10-20-2009, 09:03 AM
Sorry, I can only answer your second question:

All my OpenGL applications use many CPU performance...

How do you take down the framerate ? With Sleep(int x) it should go...

But please don't use that ^^ . Use VSync !

10-20-2009, 11:38 AM
How do you take down the framerate ? With Sleep(int x) it should go...

But please don't use that ^^ . Use VSync !

I did it with setting the update timer higher.

10-20-2009, 11:57 AM
On topic of CPU usage being high. Using glutTimer typically does not drag down the CPU unless I have a very complicated scene or I use a software render mode like MESA. In either case CPU load has nothing to do with glutTimer but rather with the actual time to render the scene being nearly equal to the timer delay setting (50ms in your case)

You may want to see a previous post GLUT FPS regulation (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=261909#Post2619 09) where two simple codes comparing glutTimer and glutIdle are given. When I run the glutIdle version my CPU goes to 100% but the glutTimer function stays near 5% (Linux+Nvidia 9600GT card) becuase the scene is trivially simple/fast to render.