[cello-devel] High CPU load also on Linux!

Frank Goenninger frank_goenninger at t-online.de
Wed Mar 10 12:32:35 UTC 2004


After a bit of searching on WWW I found this bit of explanation:

(An answer to a message complaining about high cpu usage when doing
OpenGL stuff):

<QUOTE>
I know that you are working with Win32.. and I have no clue about that..
but heres why OpenGL often eats CPU on those examples you find on the
net.. I suppose your examples are using the Glut.

[code]

void idelCB(void) {
... /* Do something */ ...
glutPostRedisplay(); /* <= This should be the problem */
}

void displayCB(void) {
.....
}

int main(int argc, char** argv) {

glutInit(&argc, argv);...
....
glutIdelFunc(idleCB);
glutDisplayFunc(displayCB);
....
glutMainLoop();
}

[/code]

If you or your API you are using are dealing with the glutPostRedisplay
like Im doing in the code abow, OpenGL will fight to produce as many FPS
thats possible.. (It will call the displayCB after each call to
idleCB).. To go around this, add an FPS counter, and a usleep in the
idleCB function, and this could reduce your CPU usage alot.. My basic
guess is thatt your application running in like a 1000FPS =)
</QUOTE>


Oookkkayyyyyy....

Now that's confirming what I supposed (based on own experience with 
X11 low level programming some 12 years ago...).

Working on a fix now...

Frank


On Wed, 2004-03-10 at 13:16, Frank Goenninger wrote:
> Hi all:
> 
> Now that the demos are all running it's about time to tackle the more
> inner problems.
> 
> One of those is that the CPU is about 90% tied to the one process of
> lisp running any one of the demos. So even if there is no animation 
> on the screen (as in Cloucell or ft-test) then I see the high load.
> 
> As the main routine is the GLUT Main Loop it seems as if we have an
> "active wait" (read: polling) for events coming in (mouse movement, 
> click, etc).
> 
> I did not yet check what get's called within GLUT Main Loop.
> 
> Any ideas already on that topic?
> 
> Regards,
>   Frank
> 
> ______________________________________________________________________
> _______________________________________________
> cello-devel site list
> cello-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/cello-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <https://mailman.common-lisp.net/pipermail/cello-devel/attachments/20040310/574ee8a9/attachment.sig>


More information about the cello-devel mailing list