00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __CS_CSENGINE_RENDERLOOP_H__
00022 #define __CS_CSENGINE_RENDERLOOP_H__
00023
00024
00025 #include "csutil/hashr.h"
00026 #include "csutil/refarr.h"
00027 #include "iengine/renderloop.h"
00028 #include "iutil/strset.h"
00029 #include "ivideo/graph3d.h"
00030 #include "ivideo/shader/shader.h"
00031 #include "ivideo/rendersteps/irenderstep.h"
00032
00033 class csEngine;
00034 class csRenderView;
00035 class csRenderLoop;
00036
00037 class csRenderLoop : public iRenderLoop
00038 {
00039 protected:
00040 friend class csLightIteratorRenderStep;
00041 friend class csGenericRenderStep;
00042
00043 csEngine* engine;
00044
00045 csRefArray<iRenderStep> steps;
00046 public:
00047 SCF_DECLARE_IBASE;
00048
00049 csRenderLoop (csEngine* engine);
00050 virtual ~csRenderLoop();
00051
00052 void StartDraw (iCamera *c, iClipper2D *view, csRenderView &rview);
00053 virtual void Draw (iCamera* c, iClipper2D* clipper);
00054
00055 virtual int AddStep (iRenderStep* step);
00056 virtual int GetStepCount ();
00057 };
00058
00059 class StringHashKeyHandler
00060 {
00061 public:
00062 static uint32 ComputeHash (const char* const& key)
00063 {
00064 return (csHashCompute (key));
00065 }
00066
00067 static bool CompareKeys (const char* const& key1, const char* const& key2)
00068 {
00069 return (strcmp (key1, key2) == 0);
00070 }
00071 };
00072
00073 template <class T>
00074 class csRefHashKeyHandler
00075 {
00076 public:
00077 static uint32 ComputeHash (const csRef<T>& key)
00078 {
00079 return (uint32)((T*)key);
00080 }
00081
00082 static bool CompareKeys (const csRef<T>& key1, const csRef<T>& key2)
00083 {
00084 return ((T*)key1 == (T*)key2);
00085 }
00086 };
00087
00088 class csRenderLoopManager : public iRenderLoopManager
00089 {
00090
00091 csHashReversible<csRef<iRenderLoop>, const char*,
00092 StringHashKeyHandler, csRefHashKeyHandler<iRenderLoop> > loops;
00093 csStringSet strings;
00094
00095 csEngine* engine;
00096 public:
00097 SCF_DECLARE_IBASE;
00098
00099 csRenderLoopManager(csEngine* engine);
00100 virtual ~csRenderLoopManager();
00101
00102 virtual csPtr<iRenderLoop> Create ();
00103
00104 virtual bool Register (const char* name, iRenderLoop* loop);
00105 virtual iRenderLoop* Retrieve (const char* name);
00106 virtual const char* GetName (iRenderLoop* loop);
00107 virtual bool Unregister (iRenderLoop* loop);
00108
00112 csPtr<iRenderLoop> Load (const char* fileName);
00113 };
00114
00115 #endif