I am going to use Ogre3D as the rendering engine for our 3D software. I am not sure if I need to use the engine as it is, or if I need to write a wrapper for the parts I want to use. What are the advantages and disadvantages of both writing a wrapper, and not writing a wrapper?
2 Answers
Ogre3D is already a wrapper/abstraction for OpenGL/DirectX. Adding another wrapper on top of that might be overkill, unless you will write a completely other rendering engine that will replace the functionality you used from Ogre. It's hard to judge, since I don't know how much of the Ogre API you're going to use.
Ogre3D already works for Linux/PC/Mac/iOS and apparently Google Native Client (which will probably also work on Android).
Generally there are situations where a wrapper might be a good idea (Gajet makes some good points) but in your current situation I'd rather invest some time to get Ogre3D running on all your target platforms. Maybe you'll have to write some additional code to achieve that, but I think it's probably less than writing a wrapper that works with different engines. And if you happen to be able to port Ogre3D to another platform, it would be a great service to the community.
Edit: Apparently Ogre3D has already been ported to Android. Here's a thread abut porting Ogre to Android.
writing a wrapper will help you in some ways:
- you can change engine whenever you like, you'll just have to change your wrapper's implementation. this is especially useful if you think you might someday change your target platform.
- when you write a wrapper your whole game code will share similar coding style. for example you know all functions start will small letters or all classes star with capital letters or any other coding style that you think of.
but there are also some drawbacks:
- you may restrict engine functionalities, by your wrapper. that's just possible if you don't want to copy all the features engine provide with exactly same structures.
- it always takes time to write something. both from programmers and computer. there are also many potential bugs you might introduce and whenever you need a new feature from engine you need to first write a wrapper to make that feature available in your code. it may decrease production speed alot.
-
1\$\begingroup\$ Even if you have a lot of experience with different rendering engines you are going to spend a LOT of time creating a usable abstraction. Why do you think that you're going to be swapping around renderers? \$\endgroup\$ Oct 2, 2011 at 15:53
-
\$\begingroup\$ @PatrickHughes: As I said you have to if you want to change your target platform. for example if you write your game for iOS and then you try porting it to PC, you have to change your renderer! \$\endgroup\$– Ali1S232Oct 2, 2011 at 16:32
-
\$\begingroup\$ well I am in a situation where I need it to work on both PC and Android. even though the Android version will be a very limited compared to the pc .. I might write my own renderer for the android sorry I didn't mention that in the question. \$\endgroup\$ Oct 2, 2011 at 16:34
-
1\$\begingroup\$ Moreover if you are using a (stupid) language that do not support inlining (such as ActionScript or Java), a wrapper will decrease performances. \$\endgroup\$– o0'.Oct 4, 2011 at 13:14