Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __CS_CSPLUGINCOMMON_RENDERMANAGER_DEBUGCOMMON_H__
00020 #define __CS_CSPLUGINCOMMON_RENDERMANAGER_DEBUGCOMMON_H__
00021
00026 #include "iutil/dbghelp.h"
00027 #include "csplugincommon/rendermanager/rendertree.h"
00028 #include "csplugincommon/rendermanager/renderview.h"
00029
00030 namespace CS
00031 {
00032 namespace RenderManager
00033 {
00034
00035
00036
00037 class CS_CRYSTALSPACE_EXPORT RMDebugCommonBase : public virtual iDebugHelper
00038 {
00039 protected:
00040 bool wantDebugLockLines;
00041
00042 virtual bool HasDebugLockLines() = 0;
00043 virtual void DeleteDebugLockLines() = 0;
00044
00045
00046
00047 virtual RenderTreeBase::DebugPersistent& GetDebugPersistent() = 0;
00048 public:
00049 RMDebugCommonBase();
00050
00053 csTicks Benchmark (int num_iterations) { return 0; }
00054 bool DebugCommand (const char *cmd);
00055 void Dump (iGraphics3D *g3d) {}
00056 csPtr<iString> Dump () { return 0; }
00057 int GetSupportedTests () const { return 0; }
00058 csPtr<iString> StateTest () { return 0; }
00060 };
00061
00074 template<typename RenderTreeType>
00075 class RMDebugCommon : public RMDebugCommonBase
00076 {
00077 typename RenderTreeType::PersistentData* treePersist;
00078 typedef typename RenderTreeType::DebugLines DebugLinesType;
00079 DebugLinesType* lockedDebugLines;
00080
00081 bool HasDebugLockLines() { return lockedDebugLines != 0; }
00082 void DeleteDebugLockLines()
00083 { delete lockedDebugLines; lockedDebugLines = 0; }
00084 RenderTreeBase::DebugPersistent& GetDebugPersistent()
00085 {
00086 CS_ASSERT_MSG ("SetTreePersistent() not called", treePersist);
00087 return treePersist->debugPersist;
00088 }
00089 public:
00090 RMDebugCommon() : treePersist (0), lockedDebugLines (0) {}
00091 ~RMDebugCommon() { delete lockedDebugLines; }
00092
00094 void SetTreePersistent (typename RenderTreeType::PersistentData& treePersist)
00095 { this->treePersist = &treePersist; }
00096
00098 void DebugFrameRender (CS::RenderManager::RenderView* rview,
00099 RenderTreeType& renderTree)
00100 {
00101 if (wantDebugLockLines)
00102 {
00103 lockedDebugLines =
00104 new DebugLinesType (renderTree.GetDebugLines());
00105 wantDebugLockLines = false;
00106 }
00107 else if (lockedDebugLines)
00108 renderTree.SetDebugLines (*lockedDebugLines);
00109 renderTree.DrawDebugLines (rview->GetGraphics3D (), rview);
00110 renderTree.RenderDebugTextures (rview->GetGraphics3D ());
00111 }
00112 };
00113
00114 }
00115 }
00116
00117 #endif // __CS_CSPLUGINCOMMON_RENDERMANAGER_DEBUGCOMMON_H__