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