Line data Source code
1 :
2 : /* Copyright (c) 2005-2014, Stefan Eilemann <eile@equalizergraphics.com>
3 : * 2014, Daniel Nachbaur <danielnachbaur@gmail.com>
4 : * 2009, Maxim Makhinya
5 : *
6 : * This library is free software; you can redistribute it and/or modify it under
7 : * the terms of the GNU Lesser General Public License version 2.1 as published
8 : * by the Free Software Foundation.
9 : *
10 : * This library is distributed in the hope that it will be useful, but WITHOUT
11 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 : * details.
14 : *
15 : * You should have received a copy of the GNU Lesser General Public License
16 : * along with this library; if not, write to the Free Software Foundation, Inc.,
17 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 : */
19 :
20 : #ifndef EQ_SYSTEM_WINDOW_H
21 : #define EQ_SYSTEM_WINDOW_H
22 :
23 : #include <eq/client/types.h>
24 : #include <eq/client/windowSettings.h> // WindowSettings::IAttribute enum
25 :
26 : namespace eq
27 : {
28 : /**
29 : * The interface definition for system-specific windowing code.
30 : *
31 : * The system window abstracts all window system specific code and facilitates
32 : * porting to new windowing systems. Each eq::Window uses one eq::SystemWindow,
33 : * which is created and initialized in Window::configInitSystemWindow.
34 : */
35 : class SystemWindow
36 : {
37 : public:
38 : /** Create a new SystemWindow for the given eq::Window. @version 1.7.2 */
39 : EQ_API SystemWindow( NotifierInterface& parent,
40 : const WindowSettings& settings );
41 :
42 : /** Destroy the SystemWindow. @version 1.0 */
43 : EQ_API virtual ~SystemWindow();
44 :
45 : /** @name Methods forwarded from eq::Window */
46 : //@{
47 : /**
48 : * Initialize this system window.
49 : *
50 : * This method should take into account all attributes of the parent Window.
51 : *
52 : * @return true if the window was correctly initialized, false
53 : * on any error.
54 : * @version 1.0
55 : */
56 : EQ_API virtual bool configInit() = 0;
57 :
58 : /**
59 : * De-initialize this system window.
60 : *
61 : * This function might be called on partially or uninitialized system
62 : * windows, and the implemenation has therefore be tolerant enough to handle
63 : * this case.
64 : * @version 1.0
65 : */
66 : EQ_API virtual void configExit() = 0;
67 :
68 : /**
69 : * Make the system window rendering context and drawable current.
70 : *
71 : * This function invalidates the pipe's make current cache. If this function
72 : * is not called, Pipe::setCurrent() has to be called appropriately.
73 : * @version 1.0
74 : */
75 : EQ_API virtual void makeCurrent( const bool cache = true ) const = 0;
76 :
77 : /** Bind the window's FBO, if it uses an FBO drawable. @version 1.0 */
78 : EQ_API virtual void bindFrameBuffer() const = 0;
79 :
80 : /** Swap the front and back buffer. @version 1.0 */
81 : EQ_API virtual void swapBuffers() = 0;
82 :
83 : /** Flush all command buffers. @version 1.5.2 */
84 : EQ_API virtual void flush() = 0;
85 :
86 : /** Finish execution of all commands. @version 1.5.2 */
87 : EQ_API virtual void finish() = 0;
88 :
89 : /**
90 : * Join a NV_swap_group.
91 : *
92 : * See WGL or GLX implementation and OpenGL extension for details on how to
93 : * implement this function.
94 : *
95 : * @param group the swap group name.
96 : * @param barrier the swap barrier name.
97 : * @version 1.0
98 : */
99 : EQ_API virtual void joinNVSwapBarrier( const uint32_t group,
100 : const uint32_t barrier ) = 0;
101 : //@}
102 :
103 : /** @name Frame Buffer Object support. */
104 : //@{
105 : /** @return the FBO of this window, or 0. @version 1.0 */
106 0 : virtual const util::FrameBufferObject* getFrameBufferObject()
107 0 : const { return 0; }
108 : //@}
109 :
110 : /**
111 : * Set up the given drawable based on the current context.
112 : * @version 1.0
113 : */
114 : EQ_API virtual void queryDrawableConfig( DrawableConfig& dc ) = 0;
115 :
116 : /**
117 : * Get the GLEW context for this window.
118 : *
119 : * The glew context is initialized during window initialization, and
120 : * provides access to OpenGL extensions. This function does not follow the
121 : * Equalizer naming conventions, since GLEW uses a function of this name to
122 : * automatically resolve OpenGL function entry points. Therefore, any
123 : * supported GL function can be called directly from an initialized
124 : * SystemWindow.
125 : *
126 : * @return the extended OpenGL function table for the window's OpenGL
127 : * context.
128 : * @version 1.0
129 : */
130 0 : virtual const GLEWContext* glewGetContext() const { return 0; }
131 :
132 : /**
133 : * Send a window error event to the application node.
134 : *
135 : * @param error the error code.
136 : * @version 1.7.1
137 : */
138 : EQ_API EventOCommand sendError( const uint32_t error );
139 :
140 : /** Process an event. @version 1.0 */
141 : EQ_API virtual bool processEvent( const Event& event );
142 :
143 : /**
144 : * Set the window's pixel viewport wrt its parent pipe.
145 : *
146 : * @param pvp the viewport in pixels.
147 : * @version 1.7.2
148 : */
149 : EQ_API void setPixelViewport( const PixelViewport& pvp );
150 :
151 : /**
152 : * @return the window's pixel viewport wrt the parent pipe.
153 : * @version 1.7.2
154 : */
155 : EQ_API const PixelViewport& getPixelViewport() const;
156 :
157 : /**
158 : * @internal
159 : * @return the OpenGL texture format corresponding to the window's color
160 : * drawable configuration
161 : */
162 : EQ_API uint32_t getColorFormat() const;
163 :
164 : /** Set the window's name. @version 1.7.2 */
165 : EQ_API void setName( const std::string& name );
166 :
167 : /** @return the window's name. @version 1.7.2 */
168 : EQ_API const std::string& getName() const;
169 :
170 : /** @return the value of an integer attribute. @version 1.7.2 */
171 : EQ_API int32_t getIAttribute( const WindowSettings::IAttribute attr ) const;
172 :
173 : /**
174 : * @return the window with which this window shares the GL context.
175 : * @version 1.7.2
176 : */
177 : EQ_API const SystemWindow* getSharedContextWindow() const;
178 :
179 : private:
180 : NotifierInterface& _parent;
181 : WindowSettings _settings;
182 : };
183 : }
184 :
185 :
186 : #endif // EQ_SYSTEM_WINDOW_H
|