Game Engine questions :)

Started by
13 comments, last by Ravuya 17 years, 9 months ago
That looks very neat, however, one of the main problem i run in to with try catch constructions is that when you instanciate variables in the try clause you cant use them in the catch portion. I did a huge project once with try catch and it just didn't do it for me :)

As for Chimera: I think if you start from scratch you may go with the try catch method, it is more modern and has more capabilities, but its just not for me :)

Greetings...

EDIT: previous post -> use enums ... i guess i'm still a C fanatic maybe, i like to stay as low level as possible. Compiler wise it isn't that big of a difference anyway, enums or ints.
Advertisement
Quote:Original post by Saruman
Note that I am not disagreeing with you in any way, but you should also note that this is also a key reason that many people don't use exceptions. The overhead used in exceptions for the stack trace, etc.

I would imagine that in an exceptional circumstance you don't care much about the overhead. [wink] I generally use exceptions in the same area as 'error returned' places in my game code; e.g. some NPC is trying to reference a NULL object and so I must catch this and reassign its target rather than just returning a magic number for NPC_TARGETED_NULL.

But yes, you do have a good point there. However, my game engine is GPU bound.
I have read all of the above posts and seem that i am going for try catch, if you haven't noticed i am working with C++, noob :p.

What i was thinking of implementing was a exception class, for example:

//Errory code here
throw CMyExeption(LINE, FILE, ERROR(d3d hr or something by that maner));

With that i think i can implement only one or to exception classes, probably one solely for D3D, and a Generic one. In that class what i do is write to a "error.log" with something that looks like this:
<X> Error in file: "holyPoop.cpp", line: "2323", D3D error code 32423432: "Unable to load texture blabla.img"
<!> App closing due to major wierd error.

I am not very fond to error managing, i just like to skip it all, its to much work at 3 am whne tring to write as much as posible before 4 am :P.

EDIT::: When i throw and exception, do i go back to executing in the same function?
Say i have this:
{
LoadTextureCodeHere;
if OMFG Failed(hrD3D)
{
throw CExep(OWNED!);
FixError here?
}
ContinueFunctioning;
}

In my head exceptions are only there to let you know about it, but you should be able to fix it rgiht there. Right? If not woop my nooby ass with the 6Million answer :). Sorry i am being so childish, i thought that if all say badwords i can too.

[Edited by - chimera007 on July 19, 2006 1:13:46 PM]
Quote:Original post by Ravuya
I would imagine that in an exceptional circumstance you don't care much about the overhead. [wink]

I agree but there is overhead just for having a single try/catch in the application and having exception handling turned on. Although note I only posted for clarity and I am not promoting the use of error codes vs exceptions or anything.

Quote:
But yes, you do have a good point there. However, my game engine is GPU bound.

True pretty much any engine will be, but once there is a game using it will it still be? :) Again though don't think I'm saying not to use exceptions or optimizing early or anything like that... just wanted to point that out.
Quote:Original post by Saruman
True pretty much any engine will be, but once there is a game using it will it still be? :) Again though don't think I'm saying not to use exceptions or optimizing early or anything like that... just wanted to point that out.

Mm, the aforementioned game is the one in my journal. And yes, it is GPU bound. Although since I upgraded this may no longer be the case.

This topic is closed to new replies.

Advertisement