Efficiency Question

Started by
4 comments, last by pinchg 21 years, 2 months ago
Okay this question is extremely general but i am looking for some tips or suggestions. My project that i am working on is my first major project. When I run my software, i can my task manager window and it tells me that i am using 100% of my processor power on it. But this is going on when my software is just sitting on my desktop, not even moving or anything. So in my mind I would think that there are no calculations being made at this time. My software will not even run on computers without graphics cards and its starting to piss me off a little. I am wondering first of all, is this normal? And second of all, if anybody had any clue as to why this might be happening, maybe if i made a common mistake or something. I can give more details about the software itself if anyone needs it. Thanks Mike
Advertisement
Me again, by the way i''m running it on a 1.4 Athlon with 512/ram and a geforce 4 ti 4200 card.
I''m by no means an expert on windows process management, but OpenGL runs in a constant loop. If all goes well, it SHOULD get 100% of the CPU power, as it is rendering as many frames as the system can handle, per second, regardless of if the scene has changed or not. You can obviously change this by removing the loop and only updating the screen when something inside the program changes.
It is using 100% of the CPU because you asked it to. In your message processing loop you don''t wait for a message so it won''t pause at all. It just keeps rendering if there isn''t a message. If you want to slow it down a bit just add in a call to Sleep. It takes an unsigned integer as a value and waits that many milliseconds before continuing. Ex: Sleep(5); would wait for five milliseconds. You should add the call to Sleep right before or after you render your scene. It will cut your frame rate, but that''s the price you pay for less CPU usage. You could pick a frame rate you want, then calculate the amount of time the CPU should sleep if it can without going under the said frame rate.
WaitMessage can be useful in some situations...
deppends on what you are doing...

//ziruz

------------------------------------------------------------
XL is comming soon @ http://ziruz.cjb.net/
You can use WaitMessage(); it worked for me without any problems. Check out NeHe''s "NeHeGL Base Code". There is a perfect example on how to implement that. Thats actually what i used.

This topic is closed to new replies.

Advertisement