Line data Source code
1 :
2 : /* Copyright (c) 2011-2016, 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/gl.h>
27 :
28 : namespace seq
29 : {
30 : namespace detail
31 : {
32 :
33 0 : Channel::Channel( eq::Window* parent )
34 0 : : eq::Channel( parent )
35 0 : {}
36 :
37 0 : Channel::~Channel()
38 : {
39 0 : }
40 :
41 0 : Pipe* Channel::getPipe()
42 : {
43 0 : return static_cast< Pipe* >( eq::Channel::getPipe( ));
44 : }
45 :
46 0 : const View* Channel::getView() const
47 : {
48 0 : return static_cast< const View* >( eq::Channel::getView( ));
49 : }
50 :
51 0 : const ViewData* Channel::getViewData() const
52 : {
53 0 : const View* view = getView();
54 0 : return view ? view->getViewData() : 0;
55 : }
56 :
57 0 : seq::Renderer* Channel::getRenderer()
58 : {
59 0 : return getPipe()->getRenderer();
60 : }
61 :
62 0 : detail::Renderer* Channel::getRendererImpl()
63 : {
64 0 : 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 : static const Matrix4f identity;
72 0 : if( !data )
73 0 : return identity;
74 :
75 0 : return data->getModelMatrix();
76 : }
77 :
78 0 : bool Channel::useOrtho() const
79 : {
80 0 : const ViewData* data = getViewData();
81 0 : LBASSERT( data );
82 0 : if( !data )
83 0 : return false;
84 :
85 0 : return data->useOrtho();
86 : }
87 :
88 0 : void Channel::frameStart( const uint128_t& frameID, const uint32_t frameNumber )
89 : {
90 0 : getRendererImpl()->setChannel( this );
91 0 : eq::Channel::frameStart( frameID, frameNumber );
92 0 : }
93 :
94 0 : void Channel::frameFinish( const uint128_t& frameID, const uint32_t frameNumber)
95 : {
96 0 : getRendererImpl()->setChannel( 0 );
97 0 : eq::Channel::frameFinish( frameID, frameNumber );
98 0 : }
99 :
100 0 : void Channel::frameClear( const uint128_t& )
101 : {
102 0 : seq::Renderer* const renderer = getRenderer();
103 0 : co::Object* const frameData = renderer->getFrameData();
104 0 : renderer->clear( frameData );
105 0 : }
106 :
107 0 : void Channel::frameDraw( const uint128_t& )
108 : {
109 0 : seq::Renderer* const renderer = getRenderer();
110 0 : co::Object* const frameData = renderer->getFrameData();
111 0 : renderer->draw( frameData );
112 0 : }
113 :
114 0 : void Channel::applyModelMatrix()
115 : {
116 0 : EQ_GL_CALL( glMultMatrixf( getModelMatrix().array ));
117 0 : }
118 :
119 0 : void Channel::frameViewFinish( const uint128_t& frameID )
120 : {
121 0 : const ViewData* data = getViewData();
122 0 : LBASSERT( data );
123 0 : if( data && data->getStatistics( ))
124 : {
125 0 : applyBuffer();
126 0 : applyViewport();
127 0 : drawStatistics();
128 : }
129 :
130 0 : eq::Channel::frameViewFinish( frameID );
131 0 : }
132 :
133 : }
134 42 : }
|