views:

74

answers:

1

I'm currently running into a problem regarding animation in OpenGL. I have between 200 and 10000 gears on the screen at a time all rotating. When the window is not in maximized view, my CPU runs at about 10-20 % consistently. No spikes, no stuttering in the animation, it runs perfectly smooth regardless of the number of gears on screen. When I maximize the window though, everything falls apart. My CPU maxes out, I begin getting weird spikes in CPU usage, the animation begins stuttering as a result, and it just looks really ugly, even when I have only 200 gears on screen.

My animation technique looks like this:

While Animating
   Calculate current rotation angle based on a running timer
   draw Image
   call glFlush()
End While

If it helps, I'm using the Tao framework in VB.net. I'm not performing any other calculations other than the ones to calculate the rotation angle mentioned above and perform a few glRotateD and glscaleD in the method to draw the image.

In addition, I guess I was under the impression that regardless of the window size in an orthographic 2-dimensional drawing that is scaling on resizing of the window, the drawing time would always take the same amount of time. Is this a correct assumption?

Any help is greatly appreciated =)


Edit

Note that I've seen the animation run perfectly smooth at full screen before. Every once in awhile, OpenGL will decide it's happy and run perfectly at full screen using between 10-20% of the CPU (same as when not maximized). I haven't pinpointed what causes this though, because it will run one time perfectly, then without changing anything, I will run it again and encounter the choppiness. I simply want to pinpoint what causes the animation to slow down and eliminate it.

I've run a dot trace on my program and it says that the swapBuffers method is using 55 % of my processing time even though I'm never explicitly calling the method. Is the method called by something else that I can eliminate, or is this simply OpenGL's "dead time" method to limit the animation to 60 fps?

+1  A: 

I was under the impression that regardless of the window size in an orthographic 2-dimensional drawing that is scaling on resizing of the window, the drawing time would always take the same amount of time. Is this a correct assumption?

If only :)

More pixels require more memory bandwidth/shader units/etc. Look into fillrate.

genpfault
How exactly would I go about implementing this idea? I notice it states that there really is no solid way to calculate what the fillrate is for a particular video card. Is there a way to get an approximation? And if so, what would I do differently knowing how much a video card can render per second?
AndyPerfect
Only test may give good approximation. If you want to regulate fps, it's better just to measure time in the frame.
alxx
I don't need to regulate fps, I'm perfectly fine drawing each frame once the previous frame has completed.
AndyPerfect