cpu

Started by
11 comments, last by Spoonbender 18 years ago
when I run code from nehe tutorial(opengl) my cpu is at 100%,why?(2.2 frec)
Advertisement
thanx 2 all reading this...
and that before it
Unless you have added a blocking operation that uses some kind of sleep() routine, your code will run as fast as possible no matter what the complexity and so use 100% cpu
Those tutorials rely on looping the rendering code over and over so that the screen is continuously updated. Therefore, unless you specifically tell the operating system to give other programs a turn, you will use 100% of the CPUs capacity.

- Jason Astle-Adams

On my computer when the tutorial is running at foreground, my CPU is at less than 10% (AMD Sempron 2200+, GeForce 5700). But when the window is minimized or all of its client area is covered by other windows, CPU is up to 100%. What's the deal??
i did know that it was looping, thanx.
soo how todo, to use smaller code?another sugestion?
and i do not see a game that uses that amounth of cpu...
Almost every game uses 100% cpu. (Except when they run with VSync enabled)
Quote:Originally posted by frozen_hell1618
soo how todo, to use smaller code?another sugestion?

I think you probably mean faster or more efficient code, so that it won't be using 100% of the CPU resources, yes? That isn't actually the problem though, since you're running (one of the earlier?) NeHe tutorials it isn't really doing much, and so will be running quite efficiently. It is in fact doing exactly what it's supposed to do; nowhere in the code have you told it that it should surrender some of the CPU resources back to the operating system to assign to other tasks, so it's running the instructions it's been given as fast as it can.

As the AP suggested, one 'fix' for this that some people use is to ensure that the program is running above a certain desired framerate (you wouldn't want to use less resources if your game was already running too slow...), and if so sleep() for a certain amount of time.

- Jason Astle-Adams

This topic is closed to new replies.

Advertisement