Line data Source code
1 :
2 : /* Copyright (c) 2005-2015, Stefan Eilemann <eile@equalizergraphics.com>
3 : * Daniel Nachbaur <danielnachbaur@gmail.com>
4 : * 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/types.h>
24 : #include <eq/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.
72 : * @version 1.0
73 : */
74 : EQ_API virtual void makeCurrent( const bool cache = true ) const = 0;
75 :
76 : /**
77 : * This results in no context being current in the current thread.
78 : *
79 : * This function resets the pipe's make current cache.
80 : * @version 1.10
81 : */
82 : EQ_API virtual void doneCurrent() const = 0;
83 :
84 : /** Bind the window's FBO, if it uses an FBO drawable. @version 1.0 */
85 : EQ_API virtual void bindFrameBuffer() const = 0;
86 :
87 : /** Bind the window's draw FBO, used for multisampling. @version 1.9 */
88 : EQ_API virtual void bindDrawFrameBuffer() const = 0;
89 :
90 : /** Update the window's FBO from the multisampled FBO. @version 1.9 */
91 : EQ_API virtual void updateFrameBuffer() const = 0;
92 :
93 : /** Swap the front and back buffer. @version 1.0 */
94 : EQ_API virtual void swapBuffers() = 0;
95 :
96 : /** Flush all command buffers. @version 1.5.2 */
97 : EQ_API virtual void flush() = 0;
98 :
99 : /** Finish execution of all commands. @version 1.5.2 */
100 : EQ_API virtual void finish() = 0;
101 :
102 : /**
103 : * Join a NV_swap_group.
104 : *
105 : * See WGL or GLX implementation and OpenGL extension for details on how to
106 : * implement this function.
107 : *
108 : * @param group the swap group name.
109 : * @param barrier the swap barrier name.
110 : * @version 1.0
111 : */
112 : EQ_API virtual void joinNVSwapBarrier( const uint32_t group,
113 : const uint32_t barrier ) = 0;
114 : //@}
115 :
116 : /** @name Frame Buffer Object support. */
117 : //@{
118 : /** @return the FBO of this window, or 0. @version 1.0 */
119 0 : virtual const util::FrameBufferObject* getFrameBufferObject()
120 0 : const { return 0; }
121 : /** @return the FBO of this window, or 0. @version 1.0 */
122 0 : virtual util::FrameBufferObject* getFrameBufferObject() { return 0; }
123 : //@}
124 :
125 : /**
126 : * Set up the given drawable based on the current context.
127 : * @version 1.0
128 : */
129 : EQ_API virtual void queryDrawableConfig( DrawableConfig& dc ) = 0;
130 :
131 : /**
132 : * Get the GLEW context for this window.
133 : *
134 : * The glew context is initialized during window initialization, and
135 : * provides access to OpenGL extensions. This function does not follow the
136 : * Equalizer naming conventions, since GLEW uses a function of this name to
137 : * automatically resolve OpenGL function entry points. Therefore, any
138 : * supported GL function can be called directly from an initialized
139 : * SystemWindow.
140 : *
141 : * @return the extended OpenGL function table for the window's OpenGL
142 : * context.
143 : * @version 1.0
144 : */
145 0 : virtual const GLEWContext* glewGetContext() const { return 0; }
146 :
147 : /**
148 : * Send a window error event to the application node.
149 : *
150 : * @param error the error code.
151 : * @version 1.7.1
152 : */
153 : EQ_API EventOCommand sendError( const uint32_t error );
154 :
155 : /** Process an event. @version 1.0 */
156 : EQ_API virtual bool processEvent( const Event& event );
157 :
158 : /**
159 : * Set the window's pixel viewport wrt its parent pipe.
160 : *
161 : * @param pvp the viewport in pixels.
162 : * @version 1.7.2
163 : */
164 : EQ_API void setPixelViewport( const PixelViewport& pvp );
165 :
166 : /**
167 : * @return the window's pixel viewport wrt the parent pipe.
168 : * @version 1.7.2
169 : */
170 : EQ_API const PixelViewport& getPixelViewport() const;
171 :
172 : /**
173 : * @internal
174 : * @return the OpenGL texture format corresponding to the window's color
175 : * drawable configuration
176 : */
177 : EQ_API uint32_t getColorFormat() const;
178 :
179 : /** Set the window's name. @version 1.7.2 */
180 : EQ_API void setName( const std::string& name );
181 :
182 : /** @return the window's name. @version 1.7.2 */
183 : EQ_API const std::string& getName() const;
184 :
185 : /** @return the value of an integer attribute. @version 1.7.2 */
186 : EQ_API int32_t getIAttribute( const WindowSettings::IAttribute attr ) const;
187 :
188 : /**
189 : * @return the window with which this window shares the GL context.
190 : * @version 1.7.2
191 : */
192 : EQ_API const SystemWindow* getSharedContextWindow() const;
193 :
194 : private:
195 : NotifierInterface& _parent;
196 : WindowSettings _settings;
197 : };
198 : }
199 :
200 :
201 : #endif // EQ_SYSTEM_WINDOW_H
|