Line data Source code
1 :
2 : /* Copyright (c) 2006-2013, Stefan Eilemann <eile@equalizergraphics.com>
3 : * 2011, Daniel Pfeifer <daniel@pfeifer-mail.de>
4 : * 2014, Daniel Nachbaur <danielnachbaur@gmail.com>
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_WINDOWSYSTEM_H
21 : #define EQ_WINDOWSYSTEM_H
22 :
23 : #include <eq/client/api.h>
24 : #include <eq/client/types.h>
25 :
26 : namespace eq
27 : {
28 :
29 : /**
30 : * The interface for windowing toolkits.
31 : *
32 : * This class is intended to be overwritten by an (anonymous) class with exactly
33 : * one static instance. The constructor will register this factory instance for
34 : * use with the WindowSystem frontend. See glx/windowSystem.cpp for an example.
35 : *
36 : * The implementation provides access to operating system dependent
37 : * functionality needed by Equalizer, and hides these specifics behind
38 : * interfaces.
39 : */
40 : class WindowSystemIF
41 : {
42 : protected:
43 : /** Create a new window system instance. @version 1.6 */
44 : EQ_API WindowSystemIF();
45 :
46 : /** Destroy the window system instance. @version 1.6 */
47 12 : virtual ~WindowSystemIF() {}
48 :
49 : /** @internal */
50 : static uint32_t _setupLists( util::ObjectManager& gl, const void* key,
51 : const int num );
52 :
53 : /** @return the unique name of the window system. @version 1.6 */
54 : virtual std::string getName() const = 0;
55 :
56 : /** @return a new system pipe. @version 1.6 */
57 : virtual SystemPipe* createPipe(Pipe* pipe) const = 0;
58 :
59 : /** @return a new event message pump @version 1.6 */
60 : virtual MessagePump* createMessagePump() const = 0;
61 :
62 : /** @return a new system window @version 1.7.2 */
63 : virtual SystemWindow* createWindow( Window* window,
64 : const WindowSettings& settings ) const = 0;
65 :
66 : /**
67 : * Create a set of display lists for the given font.
68 : *
69 : * The implementation is expected to set up one display list per ASCII
70 : * character, and store the name of the first list in the given object
71 : * manager using the given key.
72 : *
73 : * @param gl the object manager for display list allocation.
74 : * @param key the key for display list allocation.
75 : * @param name the name of the font, OS-specific.
76 : * @param size the font size in points.
77 : * @return true if the font was created, false otherwise.
78 : * @warning experimental, might not be supported in the future.
79 : */
80 : virtual bool setupFont( util::ObjectManager& gl, const void* key,
81 : const std::string& name, const uint32_t size ) const = 0;
82 :
83 : /** Perform per-process initialization for a Config. @version 1.6 */
84 8 : virtual void configInit( Node* /*node*/ ) {}
85 :
86 : /** Perform per-process de-initialization for a Config. @version 1.6 */
87 8 : virtual void configExit( Node* /*node*/ ) {}
88 :
89 : private:
90 : WindowSystemIF* _next;
91 : friend class WindowSystem;
92 : };
93 :
94 : /** @internal
95 : * Access to the instantiated window systems.
96 : * @sa Pipe::getWindowSystem()
97 : */
98 : class WindowSystem
99 : {
100 : public:
101 : EQ_API WindowSystem();
102 : EQ_API WindowSystem( const std::string& name );
103 :
104 : static bool supports( std::string const& type );
105 :
106 : static void configInit( Node* node );
107 : static void configExit( Node* node );
108 :
109 : EQ_API std::string getName() const;
110 :
111 : EQ_API SystemWindow* createWindow( Window* window,
112 : const WindowSettings& settings ) const;
113 : EQ_API SystemPipe* createPipe( Pipe* pipe ) const;
114 : EQ_API MessagePump* createMessagePump() const;
115 : EQ_API bool setupFont( util::ObjectManager& gl, const void* key,
116 : const std::string& name, const uint32_t size ) const;
117 :
118 : EQ_API bool operator == ( const WindowSystem& other ) const;
119 : EQ_API bool operator != ( const WindowSystem& other ) const;
120 :
121 : private:
122 : const WindowSystemIF* _impl;
123 : void _chooseImpl( const std::string& name );
124 : };
125 :
126 : /** Print the window system name to the given output stream. @version 1.0 */
127 : EQ_API std::ostream& operator << ( std::ostream& os, const WindowSystem& );
128 :
129 : /** co::Object serializer. @version 1.1.3 */
130 : EQ_API co::DataOStream& operator << ( co::DataOStream& os, const WindowSystem& );
131 :
132 : /** WindowSystem deserializer. @version 1.1.3 */
133 : EQ_API co::DataIStream& operator >> ( co::DataIStream& is, WindowSystem& ws );
134 :
135 : } // namespace eq
136 :
137 : #endif // EQ_WINDOWSYSTEM_H
|