Math: renamed Rect to Rectf, implemented Vector2u32 and Rectu32. Scenegraph: implemen...
[fail.git] / scenegraph / RenderContext.h
blob06719338cddc3a089e375ef4793df260b6560899
1 #ifndef AWFUL_SCENEGRAPH_RENDERCONTEXT_H_
2 #define AWFUL_SCENEGRAPH_RENDERCONTEXT_H_
4 #include "core/core.h"
5 #include "Material.h"
6 #include "Drawable.h"
7 #include "ViewPort.h"
8 #include <list>
9 #include <map>
11 namespace awful { namespace scenegraph
13 class Drawable;
15 class RenderContext : public RefCounted
17 public:
18 RenderContext( const Pointer< ViewPort >& pViewPort ) :
19 m_pViewPort( pViewPort )
23 void addGeometry( Pointer< Drawable > pDrawable_ )
25 MaterialKey key( pDrawable_->getpMaterial() );
26 m_RenderMap[ key ].push_back( pDrawable_ );
29 void addToRenderList() const
31 ms_RenderList.push_front( ConstPointer< RenderContext >( this ) );
34 static void RenderAll();
35 static void ClearAll();
36 void clear();
38 const Pointer< ViewPort >& getpViewPort() const { return m_pViewPort; }
39 void setpViewPort( const Pointer< ViewPort >& x ) { m_pViewPort = x; }
41 private:
42 void render() const;
44 typedef std::list< ConstPointer< RenderContext > > ContextList;
45 static ContextList ms_RenderList;
47 struct MaterialKey
49 MaterialKey( Material* pMaterial_ ) : pMaterial( pMaterial_ ) {}
51 ConstPointer< Material > pMaterial;
53 bool operator==( const MaterialKey& b ) const
55 return *pMaterial == *b.pMaterial;
58 bool operator<( const MaterialKey& b ) const
60 return *pMaterial < *b.pMaterial;
65 Pointer< ViewPort > m_pViewPort;
67 typedef std::list< ConstPointer< Drawable > > Bucket;
68 typedef std::map< MaterialKey, Bucket > RenderMap;
69 RenderMap m_RenderMap;
73 #endif