Line data Source code
1 :
2 : /* Copyright (c) 2011-2012, Stefan Eilemann <eile@eyescale.ch>
3 : *
4 : * This library is free software; you can redistribute it and/or modify it under
5 : * the terms of the GNU Lesser General Public License version 2.1 as published
6 : * by the Free Software Foundation.
7 : *
8 : * This library is distributed in the hope that it will be useful, but WITHOUT
9 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11 : * details.
12 : *
13 : * You should have received a copy of the GNU Lesser General Public License
14 : * along with this library; if not, write to the Free Software Foundation, Inc.,
15 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 : */
17 :
18 : #include "channel.h"
19 :
20 : #include "pipe.h"
21 : #include "renderer.h"
22 : #include "view.h"
23 :
24 : #include <seq/renderer.h>
25 : #include <seq/viewData.h>
26 : #include <eq/client/gl.h>
27 :
28 : namespace seq
29 : {
30 : namespace detail
31 : {
32 :
33 2 : Channel::Channel( eq::Window* parent )
34 2 : : eq::Channel( parent )
35 2 : {}
36 :
37 4 : Channel::~Channel()
38 : {
39 4 : }
40 :
41 8 : Pipe* Channel::getPipe()
42 : {
43 8 : return static_cast< Pipe* >( eq::Channel::getPipe( ));
44 : }
45 :
46 1 : const View* Channel::getView() const
47 : {
48 1 : return static_cast< const View* >( eq::Channel::getView( ));
49 : }
50 :
51 1 : const ViewData* Channel::getViewData() const
52 : {
53 1 : const View* view = getView();
54 1 : return view ? view->getViewData() : 0;
55 : }
56 :
57 4 : seq::Renderer* Channel::getRenderer()
58 : {
59 4 : return getPipe()->getRenderer();
60 : }
61 :
62 4 : detail::Renderer* Channel::getRendererImpl()
63 : {
64 4 : return getPipe()->getRendererImpl();
65 : }
66 :
67 0 : const Matrix4f& Channel::getModelMatrix() const
68 : {
69 0 : const ViewData* data = getViewData();
70 0 : LBASSERT( data );
71 0 : if( !data )
72 0 : return Matrix4f::IDENTITY;
73 :
74 0 : return data->getModelMatrix();
75 : }
76 :
77 0 : bool Channel::useOrtho() const
78 : {
79 0 : const ViewData* data = getViewData();
80 0 : LBASSERT( data );
81 0 : if( !data )
82 0 : return false;
83 :
84 0 : return data->useOrtho();
85 : }
86 :
87 2 : void Channel::frameStart( const uint128_t& frameID, const uint32_t frameNumber )
88 : {
89 2 : getRendererImpl()->setChannel( this );
90 2 : eq::Channel::frameStart( frameID, frameNumber );
91 2 : }
92 :
93 2 : void Channel::frameFinish( const uint128_t& frameID, const uint32_t frameNumber)
94 : {
95 2 : getRendererImpl()->setChannel( 0 );
96 2 : eq::Channel::frameFinish( frameID, frameNumber );
97 2 : }
98 :
99 3 : void Channel::frameClear( const uint128_t& )
100 : {
101 3 : seq::Renderer* const renderer = getRenderer();
102 3 : co::Object* const frameData = renderer->getFrameData();
103 3 : renderer->clear( frameData );
104 3 : }
105 :
106 1 : void Channel::frameDraw( const uint128_t& )
107 : {
108 1 : seq::Renderer* const renderer = getRenderer();
109 1 : co::Object* const frameData = renderer->getFrameData();
110 1 : renderer->draw( frameData );
111 1 : }
112 :
113 0 : void Channel::applyModelMatrix()
114 : {
115 0 : glMultMatrixf( getModelMatrix().array );
116 0 : }
117 :
118 1 : void Channel::frameViewFinish( const uint128_t& frameID )
119 : {
120 1 : const ViewData* data = getViewData();
121 1 : LBASSERT( data );
122 1 : if( data && data->getStatistics( ))
123 : {
124 0 : applyBuffer();
125 0 : applyViewport();
126 0 : drawStatistics();
127 : }
128 :
129 1 : eq::Channel::frameViewFinish( frameID );
130 1 : }
131 :
132 : }
133 3 : }
|