Game Development Community

What are the preprocessor defines for engine type?

by Michael Bacon · in Torque Game Engine · 11/24/2007 (10:44 pm) · 11 replies

I want to add a little TGEA specific code into the GameCamera as provided by one of the members.

So what are the proper ifdefs to distinguish betwen TGEA and TGE?

Looking around I've found TORQUE_GAME_ENGINE but I don't own TGEA so I can't tell if that exists or not.

Does TGEA have a TORQUE_GAME_ENGINE_ADVANCED define to differentiate?

#1
11/25/2007 (1:53 am)
Great q; i'd love to know also. anyone ?
#2
11/25/2007 (7:18 am)
I don't really know where to look, but in main.cc it says:
#ifdef TORQUE_DEBUG
   return "Debug";
#else
   return "Release";
#endif

and the tgea.vcproj states:
<VisualStudioProject
	ProjectType="Visual C++"
	Version="8.00"
	Name="Torque Game Engine Advanced"
	ProjectGUID="{AB2BBBBE-BC30-47C6-842F-94BA56DF25BD}"
	RootNamespace="TGEA"
	>

If those weren't the right places to look, Please let me know so I know where to look next time I need to.
#3
11/25/2007 (7:45 am)
Try the core/torqueConfig.h file. Should be right at the top, the first #define.

The first block only tells us if we are release or debug, the second really doesn't tell me much of anything (its just a random piece of a project file).
#4
11/25/2007 (8:39 am)
Brian, i guess you could just make one up. TORQUE_GAME_ENGINE_ADVANCED seems like a great choice.
i think i would define it in addition to TORQUE_GAME_ENGINE, rather than instead of, but i'm not the best w/ that sort of stuff.
#5
11/25/2007 (9:02 am)
The TGEA define is TORQUE_SHADER_ENGINE

Quote:i think i would define it in addition to TORQUE_GAME_ENGINE

The entire point of having different defines is so you can easily ifdef out code relevant to each engine. If both were defined then that would make the ifdefs more "complicated," thus defeating the purpose :)

T.
#6
11/25/2007 (9:09 am)
True.

but suppose there's some functionality which you want in your TGEA app coded inside a TGE #ifdef,
then you'll lose it by undefining TGE.

either way it gets messy.
well as i said, i don't have good sea-legs around this stuff, so i'm sure your suggestion is the more maintainable one.
#7
11/25/2007 (9:13 am)
If you need both then you just do:

#if defined(TORQUE_GAME_ENGINE) || defined(TORQUE_SHADER_ENGINE)
...
#endif

Having both defined on both engines means for TGEA you ALWAYS have to do:

#if defined(TORQUE_GAME_ENGINE) && defined(TORQUE_SHADER_ENGINE)
...
#endif

and for TGE you ALWAYS have to do:

#if defined(TORQUE_GAME_ENGINE) && !defined(TORQUE_SHADER_ENGINE)
...
#endif

With the way it is now, the most common case only requires a #ifdef on a single define, which is significantly less typing and far more readable.

This is, however, a moot point as TGB defines TORQUE_GAME_ENGINE and no special TGB define ... which should probably be fixed ;-)

T.
#8
11/25/2007 (10:23 am)
Heh. yeah, any way you slice it it's a pain, imo.
#define's are just like god's curse to programmers.
#9
11/25/2007 (3:59 pm)
Lol thats exactly what I was looking for there.

#defines are the programmer's curse to god. Not the other way around.
#10
11/25/2007 (4:34 pm)
Defines have their uses. Like every other language feature, they are also misused.

A real programmer knows when to use certain language features and when not to, regardless of any stigma attached to it. It's a matter of the right tool for the right job. Even goto has it's (rare) uses :)

T.
#11
11/25/2007 (5:34 pm)
Thanks for the information. I hadn't looked into the core directory before. (mabe I need to dig into the code more)