Line data Source code
1 :
2 : /* Copyright (c) 2009-2013, Stefan Eilemann <eile@equalizergraphics.com>
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 : #ifndef EQ_OBSERVER_H
19 : #define EQ_OBSERVER_H
20 :
21 : #include <eq/client/api.h>
22 : #include <eq/client/types.h>
23 : #include <eq/fabric/observer.h> // base class
24 :
25 : namespace eq
26 : {
27 : namespace detail { class Observer; }
28 :
29 : /**
30 : * An Observer looks at one or more views from a certain position (head
31 : * matrix) with a given eye separation. Multiple observers in a
32 : * configuration can be used to update independent viewers from one
33 : * configuration, e.g., a control host, a HMD and a Cave.
34 : *
35 : * @sa fabric::Observer
36 : */
37 : class Observer : public fabric::Observer< Config, Observer >
38 : {
39 : public:
40 : /** Construct a new observer. @version 1.0 */
41 : EQ_API Observer( Config* parent );
42 :
43 : /** Destruct this observer. @version 1.0 */
44 : EQ_API virtual ~Observer();
45 :
46 : /** @name Operations */
47 : //@{
48 : /**
49 : * Handle an event.
50 : *
51 : * The event type and originator identifier (of this object) have
52 : * already been consumed from the given command.
53 : *
54 : * @param command The event input command.
55 : * @return true if the event requires a redraw, false otherwise.
56 : */
57 : EQ_API virtual bool handleEvent( EventICommand& command );
58 : //@}
59 :
60 : /** @name Data Access */
61 : //@{
62 : /** @return the Server of this observer. @version 1.0 */
63 : EQ_API ServerPtr getServer();
64 : //@}
65 :
66 63 : void addView( View* ) { /* nop */ } //!< @internal
67 0 : void removeView( View* ) { /* nop */ } //!< @internal
68 :
69 : protected:
70 : /**
71 : * @name Callbacks
72 : *
73 : * Callbacks are called by Equalizer during rendering to execute various
74 : * actions from the application main thread before sending the
75 : * corresponding command to the server.
76 : */
77 : //@{
78 : /** Initialize this observer. @version 1.5.2 */
79 : EQ_API virtual bool configInit();
80 : friend class detail::InitVisitor;
81 :
82 : /** Exit this observer. @version 1.5.2 */
83 : EQ_API virtual bool configExit();
84 : friend class detail::ExitVisitor;
85 :
86 : /**
87 : * Start rendering a frame.
88 : *
89 : * Called once at the beginning of each frame before the Config::frame
90 : * is send to the server, to do per-frame updates of observer-specific
91 : * data.
92 : *
93 : * @param frameNumber the frame to start.
94 : * @version 1.5.2
95 : */
96 : EQ_API virtual void frameStart( const uint32_t frameNumber );
97 : friend class detail::FrameVisitor;
98 : //@}
99 :
100 : private:
101 : detail::Observer* const _impl;
102 : };
103 : }
104 : #endif // EQ_OBSERVER_H
|