1 #ifndef AWFUL_SCENEGRAPH_VIEWPORT_H_
2 #define AWFUL_SCENEGRAPH_VIEWPORT_H_
6 #include "math/Rectu32.h"
10 namespace awful
{ namespace scenegraph
12 class ViewPort
: public Serializable
15 ViewPort( const Pointer
< Camera
>& pCamera
) :
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
);
51 template< class C
, typename T
> friend struct awful::attribute_traits
;
52 Pointer
< Camera
> m_pCamera
;