without big explanations.
Here is a part of the code in main.exe
Imagine that we have a simple scene and frame is drawn in 10ms.PHP Code:startDraw = GetTickCount();
drawFrame();
frameTime = GetTickCount() - startDraw;
while(frameTime < 40)
{
frameTime = GetTickCount() - startDraw;
}
After frame is drawn we get here
for 30 ms we will use cpu just to check if 40ms have passed since frame started to draw.PHP Code:while(frameTime < 40)
{
frameTime = GetTickCount() - startDraw;
}
why we just don't go to sleep for a little and then check for the passed time? Let the system do useful things
So the point is - don't waste cpu time if we have a simple frame that is drawn faster then 40 ms.PHP Code:while(frameTime < 40)
{
Sleep(1); // will sleep for 10-15 ms, depending on time accuracy
frameTime = GetTickCount() - startDraw;
}
How to add this thing in main using ollydbg:
1. Search for SwapBuffers or glFlush (search for name/lable CTRL+N)
and you will find this part of the code
in 97d it will look like this:PHP Code:frameTime = GetTickCount() - startDraw;
while(frameTime < 40)
{
frameTime = GetTickCount() - startDraw;
}
1.03.27 jpn:
2. Modify the code by adding sleep function call:
97d:
1.03.27 jpn:
Note: if main spends >= 40 ms for frame drawing, this thing won't save you from high cpu usage :D cpu will be busy in drawing frame
this thing needs testings, i made some tests + thx to Dios he made little tests, so test and maybe it will be useful








Reply With Quote
But unfortunately, not with many players around.



