At ArKaos we work a lot on the fluidity of the animations produced by our softwares. To do so we multi thread a lot the software and make the best use of the graphical acceleration.
It looks like on the Mac, under 10.5.6 at least, it’s very difficult to have perfectly fluid animations on one monitor while continuing to update a software interface on another monitor. Unfortunately it’s what we want to achieve in all our softwares.
I was able to reduce the problem by creating a simple application that draw a band in one window at 60 FPS. As soon as the system is slowing down you see clearly the speed of the animation being irregular. Because the code is very light, uses no texture, I was expecting this code to run very smoothly.
The function that is called for every frame is as simple as this one:
void display1(void)
{
static int framecount = 0;
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 1.0, 1.0);
glLoadIdentity (); /* clear the matrix */
/* viewing transformation */
float x_pos = – ((framecount++ % 60) – 30.0) / 8.0;
gluLookAt (x_pos, 0.0, 5.0, x_pos, 0.0, 0.0, 0.0, 1.0, 0.0);
glScalef (1.0, 2.0, 1.0); /* modeling transformation */
glColor3f(1,1,1);
glBegin(GL_POLYGON);
glVertex2f(-0.5,3);
glVertex2f(-0.5,-3);
glVertex2f(0.5,-3);
glVertex2f(0.5,3);
glEnd();
glFinish ();
}
It simply draw a band like this that cycle in the window:
Because framecount is incremented for each new frame it has a very visible impact when you miss a frame, this is what I want to see.
Here is the result of sharking the application, untitled and untitled copy are the 2 instances running. You see that the whole machine is almost idle, but very clearly on this picture after 6 frames you see that the time between 2 ticks on the untitled line start to double:
I have the feeling that the problem is in the WindowServer process but it’s out of my scope to understand what is wrong there.
If you are curious my very simple GLUT sample is here GlutSample.zip
Once you unzip it just run band1 and band2 and move one window on a second monitor you should see the animation become irregular.
Here is the shark file GlutSample.mshark
> move one window on a second monitor you should see the animation become irregular.
Do you have by any chance two GPU’s? If so, than this behaviour might be explained by the GL implementation on Mac OS X. Afaik, the renderer is allocated on the GPU which has most of the pixels when the context is created. If you move the window to another GPU, the original renderer still renders it and the copies the pixels to the new GPU.
More info here:
http://www.equalizergraphics.com/documentation/parallelOpenGLFAQ.html#multigpu
HTH,
Stefan.