OGRE 3D 軟體工程與哲學

My OGRE 3D working journal vol.1

The series will be based on OGRE version 1.8.1 and start from the samples in OGRE SDK. The short-term goal is to realize the OGRE architecture, low-level implementation, and the supported graphics specification. The mid-term goal is to develop a personal project based on this engine.

The architecture of OGRE v1.8.1 SampleBrowser

The entry function of OGRE SDK samples is OgreBites::SampleBrowser::go, which dynamically links to SampleContext::go.

The OGRE official SDK samples OgreSDK_vc10_v1-8-1 wraps multiple (36) sample modules and SampleBrowser into one Visual Studio solution, with the dependencies between the projects. Therefore when I needed to build the projects in development, I needed to build all projects (because of the dependencies). It wasted lots of time, so I decided to pull the SampleBrowser project out of the solution, which should decouple the dependency between SampleBrowser and other sample projects (I was only using the dlls of the sample projects).

When I was running the SampleBrowser project, it happened that an exception was thrown. After tracing down, I found the problem was in the OgreMain module, so I decided to build the OgreMain module by myself with the OGRE source ogre_src_v1-8-1_1. The building was pretty troublesome, including:

  • Built and managed the dependency libraries, including spending lots of time in building the boost library.
  • Generated the solution-project hierarchy in Visual Studio via the OGRE provided CMake. Pulled the OgreMain project out, including the Visual Studio project settings and source file selection.      

So far the problem of throwing exception could be reproduced. After fixing the problem, the single SampleBrowser project was also completed. Here are some notes when I was working on the above tasks:

  • The methods of error handling in OGRE are assertion and log.
  • The macros of the testing project should be consistent with the test target project, otherwise memory access violation occurred (e.g., the macros of the testing project should contain USE_RTSHADER_SYSTEM).
  • When there are lots of dependencies in a project (e.g., SampleBrowser), the management of the dependent libs/dlls is very important.   

Here is the architecture of OGRE samples for future reference.

larry 20130314 updates:
The main attributes in OgreBites::Sample
  • OIS::Keyboard* mKeyboard; // a reference pointer from the engine
  • OIS::Mouse* mMouse; // a reference pointer from the engine
  • FileSystemLayer* mFSLayer; // a reference pointer from the engine
  • Ogre::SceneManager* mSceneMgr; // created/destroyed by the sample
  • Ogre::RTShader::ShaderGenerator* mShaderGenerator; // a reference pointer from the engine
  • + _setup
  • + _shutdown
  • + frameStarted
  • + frameRenderingQueued
  • + frameEnded
  • # locateResources
  • # loadResources
  • # unloadResources
  • # createSceneManager
  • # setupView
  • # setupContent
  • # cleanupContent
  • # unloadResources

The main methods in OgreBites::SdkSample
  • + frameRenderingQueued
  • + _setup
  • + _shutdown
  • # setupView

The relationship between SampleBrowser and Sample is executable-plugin, and the interfaces are OgreBites::SamplePlugin and OgreBites::Sample (nothing to do with SdkSample, Sample_xxx). SamplePlugin is for install/uninstall related jobs; Sample is for general graphics engine jobs, including loading resources, scene management, renderer setting, camera setting, etc.