Line data Source code
1 :
2 : /* Copyright (c) 2007-2015, Stefan Eilemann <eile@equalizergraphics.com>
3 : * Daniel Pfeifer <daniel@pfeifer-mail.de>
4 : * 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 : #include "windowSystem.h"
21 :
22 : #include "gl.h"
23 :
24 : #include <eq/util/objectManager.h>
25 : #include <eq/fabric/gpuInfo.h>
26 : #include <co/dataIStream.h>
27 : #include <co/dataOStream.h>
28 :
29 : namespace eq
30 : {
31 : static WindowSystemIF* _stack = 0;
32 :
33 28 : WindowSystemIF::WindowSystemIF()
34 28 : : _next( _stack )
35 : {
36 28 : _stack = this;
37 28 : }
38 :
39 0 : uint32_t WindowSystemIF::_setupLists( util::ObjectManager& gl, const void* key,
40 : const int num )
41 : {
42 0 : GLuint lists = gl.getList( key );
43 0 : if( lists != util::ObjectManager::INVALID )
44 0 : gl.deleteList( key );
45 :
46 0 : if( num == 0 )
47 0 : lists = util::ObjectManager::INVALID;
48 : else
49 : {
50 0 : lists = gl.newList( key, num );
51 0 : LBASSERT( lists != util::ObjectManager::INVALID );
52 : }
53 0 : return lists;
54 : }
55 :
56 92 : WindowSystem::WindowSystem( const std::string& type )
57 : {
58 92 : _chooseImpl( type );
59 92 : }
60 :
61 92 : void WindowSystem::_chooseImpl( const std::string& name )
62 : {
63 92 : LBASSERTINFO( _stack, "no window system available" );
64 :
65 184 : for( WindowSystemIF* ws = _stack; ws; ws = ws->_next )
66 : {
67 184 : if( ws->getName() == name )
68 : {
69 92 : _impl = ws;
70 184 : return;
71 : }
72 : }
73 :
74 0 : for( WindowSystemIF* ws = _stack; ws; ws = ws->_next )
75 0 : if( !ws->getName().empty( ))
76 0 : _impl = ws;
77 0 : if( !_impl )
78 0 : _impl = _stack;
79 :
80 0 : LBWARN << "Window system '" << name << "' not supported, " << "using "
81 0 : << _impl->getName() << " instead." << std::endl;
82 : }
83 :
84 0 : bool WindowSystem::supports( std::string const& type )
85 : {
86 0 : for( WindowSystemIF* ws = _stack; ws; ws = ws->_next )
87 : {
88 0 : if( ws->getName() == type )
89 0 : return true;
90 : }
91 :
92 0 : return false;
93 : }
94 :
95 1 : void WindowSystem::configInit( Node* node )
96 : {
97 3 : for( WindowSystemIF* ws = _stack; ws; ws = ws->_next )
98 2 : ws->configInit( node );
99 1 : }
100 :
101 1 : void WindowSystem::configExit( Node* node )
102 : {
103 3 : for( WindowSystemIF* ws = _stack; ws; ws = ws->_next )
104 2 : ws->configExit(node );
105 1 : }
106 :
107 1 : std::string WindowSystem::getName() const
108 : {
109 1 : LBASSERT( _impl );
110 1 : return _impl->getName();
111 : }
112 :
113 0 : SystemWindow* WindowSystem::createWindow( Window* window,
114 : const WindowSettings& settings )
115 : {
116 0 : LBASSERT( _impl );
117 0 : return _impl->createWindow( window, settings );
118 : }
119 :
120 1 : SystemPipe* WindowSystem::createPipe( Pipe* pipe )
121 : {
122 1 : LBASSERT( _impl );
123 1 : return _impl->createPipe( pipe );
124 : }
125 :
126 1 : MessagePump* WindowSystem::createMessagePump()
127 : {
128 1 : LBASSERT( _impl );
129 1 : return _impl->createMessagePump();
130 : }
131 :
132 0 : bool WindowSystem::setupFont( util::ObjectManager& gl, const void* key,
133 : const std::string& name,
134 : const uint32_t size ) const
135 : {
136 0 : LBASSERT( _impl );
137 0 : return _impl->setupFont( gl, key, name, size );
138 : }
139 :
140 1 : bool WindowSystem::hasMainThreadEvents() const
141 : {
142 1 : LBASSERT( _impl );
143 1 : return _impl->hasMainThreadEvents();
144 : }
145 :
146 0 : bool WindowSystem::operator == ( const WindowSystem& other) const
147 : {
148 0 : return _impl == other._impl;
149 : }
150 :
151 0 : bool WindowSystem::operator != ( const WindowSystem& other ) const
152 : {
153 0 : return _impl != other._impl;
154 : }
155 :
156 1 : std::ostream& operator << ( std::ostream& os, const WindowSystem& ws )
157 : {
158 1 : return os << ws.getName();
159 : }
160 :
161 0 : co::DataOStream& operator << ( co::DataOStream& os, const WindowSystem& ws )
162 : {
163 0 : return os << ws.getName();
164 : }
165 :
166 0 : co::DataIStream& operator >> ( co::DataIStream& is, WindowSystem& ws )
167 : {
168 0 : std::string name;
169 0 : is >> name;
170 0 : ws = WindowSystem( name );
171 0 : return is;
172 : }
173 :
174 42 : } // namespace eq
|