OGRE to MOGRE        

Guidelines for converting Ogre C++ code to Mogre C# code

.NET naming conventions

  • Methods use pascal case instead of camel case.
  • Properties instead of get/set methods. Ogre methods that get transformed to properties are:
    • get/setXXXX methods
    • getXXXX methods
    • bool isXXXX methods


mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
 SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();


mSceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f);
 SceneNode node = mSceneMgr.RootSceneNode.CreateChildSceneNode();

Note: If you see a property that starts with a lower case letter, it means that the property is not a conversion of get/set methods but a direct wrapper of a class field variable (i.e Mesh.sharedVertexData)

.NET Events

Ogre uses Listener classes to provide notifications of various events. The pattern involves subclassing an abstract Listener class (that gets the notifications), and subscribing to a notifier using a addListener method. .NET provides Events for this mechanism, so in Mogre there are no add/removeListener methods. Instead, the notifier exposes one event for each function defined in the Ogre's abstract Listener class.


mFrameListener = new SkeletalAnimationFrameListener(mWindow, mCamera);

 class RefractionTextureListener : public RenderTargetListener
     void preRenderTargetUpdate(const RenderTargetEvent& evt)
 RenderTarget *rttTex = mTexture->getBuffer()->getRenderTarget();


mRoot.FrameStarted += new FrameListener.FrameStartedHandler(Skeletal_FrameStarted);

 RenderTarget rttTex = mTexture.GetBuffer().GetRenderTarget();
 rttTex.PreRenderTargetUpdate += new RenderTargetListener.PreRenderTargetUpdateHandler(rttTex_PreRenderTargetUpdate);
 void rttTex_PreRenderTargetUpdate(RenderTargetEvent_NativePtr evt)

See also