All done with un-inlining constructors. Onwards to fucking up the entire directory...
[fail.git] / scenegraph / RenderContext.h
blob24619d9363fcdde2c7d2579eb881bae215f9cef6
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 "Text.h"
8 #include "ViewPort.h"
9 #include <list>
10 #include <map>
12 namespace awful { namespace scenegraph
14 class Drawable;
15 class Text;
17 class RenderContext : public RefCounted
19 public:
20 RenderContext( const Pointer< ViewPort >& pViewPort );
22 void addDrawable( const Pointer< Drawable >& pDrawable_ )
24 MaterialKey key( pDrawable_->getpMaterial() );
25 m_RenderMap[ key ].push_back( pDrawable_ );
28 void addText( const Pointer< Text >& pText_, float z )
30 m_TextMap.insert( std::make_pair( z, pText_ ) );
33 void addToRenderList() const
35 ms_RenderList.push_front( ConstPointer< RenderContext >( this ) );
38 static void RenderAll();
39 static void ClearAll();
40 void clear();
42 const Pointer< ViewPort >& getpViewPort() const { return m_pViewPort; }
43 void setpViewPort( const Pointer< ViewPort >& x ) { m_pViewPort = x; }
45 private:
46 void render() const;
48 typedef std::list< ConstPointer< RenderContext > > ContextList;
49 static ContextList ms_RenderList;
51 struct MaterialKey
53 MaterialKey( Material* pMaterial_ ) : pMaterial( pMaterial_ ) {}
55 ConstPointer< Material > pMaterial;
57 bool operator==( const MaterialKey& b ) const
59 return *pMaterial == *b.pMaterial;
62 bool operator<( const MaterialKey& b ) const
64 return *pMaterial < *b.pMaterial;
69 Pointer< ViewPort > m_pViewPort;
71 typedef std::list< ConstPointer< Drawable > > Bucket;
72 typedef std::map< MaterialKey, Bucket > RenderMap;
73 RenderMap m_RenderMap;
75 typedef std::multimap< float, ConstPointer< Text > > TextMap;
76 TextMap m_TextMap;
80 #endif