CPU problem with V3
Displaying 1-7 of 7 total.
1
ErayMan
|
I talked about it on my gruedorf blog, but I post it here for help.
It's almost copy/paste, cause well, me lazy ;)
I have a problem that is with me from the beginning with Verge. Everytime I’m in some kind of loop, like, let’s say, inside a menu or in my battle system, Verge3 uses 100% of my CPU. I have no idea how to make it work less aggressive.
In the loop I am making sure it does things once per 1/100s only, but if 1/100 has not passed yet, it just runs in the loop until it has. :/
I guess I could put everything in a HookTimer function instead of a simple while() loop, but then I heard that if HookTimer takes more than 1/100s to process, it could get ugly.
So how does people do it? Is HookTimer the way to go?
Posted on 2008-05-28 21:12:38
|
resident
|
HookRender is probably a better bet than Timer. The function usually gets executed once a render cycle after your map has been drawn, which makes it pretty good for menus.
Posted on 2008-05-29 00:38:23
|
ErayMan
|
Looks good, thanks :) ! That function seems to miss from the V3 Documentation hehehe.
So would the function inside HookRender() be called everytime I call Render()? If there is a Render() inside the function that gets HookRendered, will that make an infinite loop? :/
Posted on 2008-05-29 10:28:21
|
resident
|
Did I say HookRender? Arses. I mean HookRetrace, which isn't missing from the docs.
http://www.verge-rpg.com/docs/view.php?libid=1&function=174
Though it can essentially do the same thing as the ficticious HookRender. (Where the hell did I get that name from? That's gonna bug me, now). It usually gets called once a frame, though it'll get called as many times as you have "R" in curmap.rstring.
Posted on 2008-05-29 12:59:34 (last edited on 2008-05-29 13:05:10)
|
ErayMan
|
Oh hehe :P
Thanks, that should do the trick. I'll try it as soon as I can and I'll let you know how it goes :)
Posted on 2008-05-29 15:28:32
|
pthaloearth
|
just fyi hookrender does indeed crash if you throw a render() in it
Posted on 2008-05-30 09:30:52
|
Swordsman
|
Render calls anything hookretraced. So if you call render inside a hookretrace, you get a suddenly infinite number of calls. But there is a way around that.
Something like this:
int renderstopper;
void HookFunc()
{
if(renderstopper == 0)
{
renderstopper = 1;
// code stuffs go here
render();
// and probably here too
renderstopper = 0;
}
}
This might seem useless, or possibly a sign of poor design, but it is occasionally quite handy. Like if you need the engine to render the map several different ways before one showpage. Or if your code gets... complicated, and you want it to be safer or something, I guess.
Posted on 2008-06-03 02:51:45 (last edited on 2008-06-03 02:55:03)
|