csplugincommon/rendermanager/debugcommon.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2008 by Frank Richter 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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 /* Helper class containing stuff which doesn't require any of the template 00035 * parameters to RMDebugCommon 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 /* Only the final derived render manager knows the exact class containing 00045 RenderTreeBase::DebugPersistent (and can instantiate it), hence this 00046 indirection */ 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 } // namespace RenderManager 00115 } // namespace CS 00116 00117 #endif // __CS_CSPLUGINCOMMON_RENDERMANAGER_DEBUGCOMMON_H__
Generated for Crystal Space 2.0 by doxygen 1.6.1