CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

renderloop.h

00001 /*
00002     Copyright (C) 2003 by Jorrit Tyberghein
00003               (C) 2003 by Frank Richter
00004               (C) 2003 by Anders Stenberg
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public
00017     License along with this library; if not, write to the Free
00018     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 */
00020 
00021 #ifndef __CS_CSENGINE_RENDERLOOP_H__
00022 #define __CS_CSENGINE_RENDERLOOP_H__
00023 
00024 //#include "csutil/hashmapr.h"
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   //csHashMapReversible loops;
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

Generated for Crystal Space by doxygen 1.2.14