Archived

This topic is now archived and is closed to further replies.

pinchg

Efficiency Question

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites