Math: renamed Rect to Rectf, implemented Vector2u32 and Rectu32. Scenegraph: implemen...
[fail.git] / scenegraph / ViewPort.h
blob850ca7a8788dfe85c158ebfceb41ea06cc92c911
1 #ifndef AWFUL_SCENEGRAPH_VIEWPORT_H_
2 #define AWFUL_SCENEGRAPH_VIEWPORT_H_
4 #include "core/core.h"
5 #include "Camera.h"
6 #include "math/Rectu32.h"
7 #include <GL/gl.h>
8 #include <GL/glu.h>
10 namespace awful { namespace scenegraph
12 class ViewPort : public Serializable
14 public:
15 ViewPort( const Pointer< Camera >& pCamera ) :
16 m_pCamera( pCamera ),
17 m_ZNear( 0.1f ),
18 m_ZFar( 50.f )
22 ViewPort( const Serialization_tag& ) {}
24 const Pointer< Camera >& getpCamera() const { return m_pCamera; }
25 void setpCamera( const Pointer< Camera >& x ) { m_pCamera = x; }
27 const math::Rectu32& getRect() const { return m_Rect; }
28 math::Rectu32& getRect() { return m_Rect; }
29 void setRect( const math::Rectu32& x ) { m_Rect = x; }
31 const float& getZNear() const { return m_ZNear; }
32 void setZNear( const float& x ) { m_ZNear = x; }
34 const float& getZFar() const { return m_ZFar; }
35 void setZFar( const float& x ) { m_ZFar = x; }
38 void renderSetup() const
40 glViewport( m_Rect.left(), m_Rect.top(), m_Rect.width(), m_Rect.height() );
42 float ratio = static_cast< float >( m_Rect.width() ) /
43 static_cast< float >( m_Rect.height() );
45 glMatrixMode( GL_PROJECTION );
46 m_pCamera->renderSetup();
47 gluPerspective( m_pCamera->getFOV(), ratio, m_ZNear, m_ZFar );
50 private:
51 template< class C, typename T > friend struct awful::attribute_traits;
52 Pointer< Camera > m_pCamera;
53 math::Rectu32 m_Rect;
54 float m_ZNear;
55 float m_ZFar;
59 #endif