Equalizer  1.6.1
include/eq/client/window.h
Go to the documentation of this file.
1 
2 /* Copyright (c) 2005-2012, Stefan Eilemann <eile@equalizergraphics.com>
3  * 2010, Cedric Stalder <cedric.stalder@gmail.com>
4  * 2010, 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_WINDOW_H
21 #define EQ_WINDOW_H
22 
23 #include <eq/client/types.h>
24 #include <eq/client/visitorResult.h> // enum
25 
26 #include <eq/util/bitmapFont.h> // member
27 #include <eq/fabric/renderContext.h> // member
28 #include <eq/fabric/window.h> // base class
29 
30 
31 
34 namespace eq
35 {
63  class Window : public fabric::Window< Pipe, Window, Channel >
64  {
65  public:
68 
70  typedef BitmapFont Font;
71 
73  EQ_API Window( Pipe* parent );
74 
76  EQ_API virtual ~Window();
77 
80  EQ_API co::CommandQueue* getPipeThreadQueue();
81  EQ_API co::CommandQueue* getCommandThreadQueue();
82  EQ_API uint32_t getCurrentFrame() const;
83 
85  EQ_API const Node* getNode() const;
86 
88  EQ_API Node* getNode();
89 
91  EQ_API const Config* getConfig() const;
92 
94  EQ_API Config* getConfig();
95 
97  EQ_API ClientPtr getClient();
98 
100  EQ_API ServerPtr getServer();
101 
106  bool isRunning() const { return (_state == STATE_RUNNING); }
107 
112  bool isStopped() const { return (_state == STATE_STOPPED); }
113 
123  EQ_API bool getRenderContext( const int32_t x, const int32_t y,
124  RenderContext& context ) const;
126 
137  void setSharedContextWindow( Window* sharedContextWindow )
138  { _sharedContextWindow = sharedContextWindow; }
139 
145  { return _sharedContextWindow; }
146 
151  Window* getSharedContextWindow() { return _sharedContextWindow; }
152 
154  ObjectManager* getObjectManager() { return _objectManager; }
155 
157  const ObjectManager* getObjectManager() const { return _objectManager; }
158 
163  EQ_API const Font* getSmallFont();
164 
169  EQ_API const Font* getMediumFont();
170 
185  EQ_API const GLEWContext* glewGetContext() const;
186 
194  EQ_API const GLEWContext* getTransferGlewContext();
195 
201  EQ_API uint32_t getColorFormat() const;
203 
213  EQ_API virtual void flush() const;
214 
222  EQ_API virtual void finish() const;
223 
225  EQ_API virtual void swapBuffers();
226 
228  EQ_API virtual void drawFPS();
229 
231  float getFPS() const { return _avgFPS; }
232 
242  EQ_API virtual void makeCurrent( const bool cache = true ) const;
243 
247  void makeCurrentTransfer( const bool cache = true ) const;
248 
250  EQ_API virtual void bindFrameBuffer() const;
251 
253  EQ_API virtual void notifyViewportChanged();
255 
267  EQ_API void setSystemWindow( SystemWindow* window );
268 
270  const SystemWindow* getSystemWindow() const { return _systemWindow; }
271 
273  SystemWindow* getSystemWindow() { return _systemWindow; }
274 
276  const SystemPipe* getSystemPipe() const;
277 
280 
282  bool createTransferWindow();
283 
285  void deleteTransferSystemWindow();
287 
306  EQ_API virtual bool processEvent( const Event& event );
308 
309  protected:
310  friend class Pipe;
311 
313  EQ_API virtual void attach( const UUID& id, const uint32_t instanceID );
314 
323  EQ_API void startFrame( const uint32_t frameNumber );
324 
331  EQ_API void releaseFrame( const uint32_t frameNumber );
332 
339  EQ_API void releaseFrameLocal( const uint32_t frameNumber );
341 
355  EQ_API virtual bool configInit( const uint128_t& initID );
356 
363  EQ_API virtual bool configInitSystemWindow( const uint128_t& initID );
364 
373  EQ_API virtual bool configInitGL( const uint128_t& initID );
374 
376  EQ_API virtual bool configExit();
377 
379  EQ_API virtual bool configExitSystemWindow();
380 
382  virtual bool configExitGL() { return true; }
383 
394  EQ_API virtual void frameStart( const uint128_t& frameID,
395  const uint32_t frameNumber );
396 
410  EQ_API virtual void frameFinish( const uint128_t& frameID,
411  const uint32_t frameNumber );
412 
423  EQ_API virtual void frameDrawFinish( const uint128_t& frameID,
424  const uint32_t frameNumber );
426 
427  private:
428  enum State
429  {
430  STATE_STOPPED,
431  STATE_INITIALIZING,
432  STATE_RUNNING,
433  STATE_FAILED
434  };
435 
437  Window* _sharedContextWindow;
438 
440  SystemWindow* _transferWindow;
441 
443  SystemWindow* _systemWindow;
444 
446  State _state;
447 
449  ObjectManager* _objectManager;
450 
452  float _lastTime;
453 
455  float _avgFPS;
456 
458  std::vector< RenderContext > _renderContexts[2];
459  enum
460  {
461  FRONT = 0,
462  BACK = 1
463  };
464 
466  int64_t _lastSwapTime;
467 
469  Channels _grabbedChannels;
470 
471  struct Private;
472  Private* _private; // placeholder for binary-compatible changes
473 
475  void _addRenderContext( const RenderContext& context );
476  friend class Channel;
477 
479  Channels _getEventChannels( const PointerEvent& event );
480 
482  void _setupObjectManager();
484  void _releaseObjectManager();
485 
487  void _updateFPS();
488 
490  void _enterBarrier( co::ObjectVersion barrier );
491 
492  /* The command functions. */
493  bool _cmdCreateChannel( co::ICommand& command );
494  bool _cmdDestroyChannel(co::ICommand& command );
495  bool _cmdConfigInit( co::ICommand& command );
496  bool _cmdConfigExit( co::ICommand& command );
497  bool _cmdFrameStart( co::ICommand& command );
498  bool _cmdFrameFinish( co::ICommand& command );
499  bool _cmdThrottleFramerate( co::ICommand& command );
500  bool _cmdFlush( co::ICommand& command );
501  bool _cmdFinish( co::ICommand& command );
502  bool _cmdBarrier( co::ICommand& command );
503  bool _cmdNVBarrier( co::ICommand& command );
504  bool _cmdSwap( co::ICommand& command );
505  bool _cmdFrameDrawFinish( co::ICommand& command );
506 
507  LB_TS_VAR( _pipeThread );
508  };
509 }
510 
511 #endif // EQ_WINDOW_H
A configuration is a visualization session driven by an application.
virtual void frameFinish(const uint128_t &frameID, const uint32_t frameNumber)
Finish rendering a frame.
Event structure to report window system and other events.
Definition: event.h:171
virtual void finish() const
Finish outstanding rendering requests.
bool isRunning() const
Base data transport class for windows.
virtual bool configExitGL()
De-initialize the OpenGL state for this window.
void setSystemWindow(SystemWindow *window)
Set the OS-specific window.
std::vector< C * > Channels
A vector of pointers to channels.
const Font * getMediumFont()
A Window represents an on-screen or off-screen drawable.
void releaseFrame(const uint32_t frameNumber)
Signal the completion of a frame to the parent.
SystemWindow * getSystemWindow()
void releaseFrameLocal(const uint32_t frameNumber)
Signal the release of the local synchronization to the parent.
const ObjectManager * getObjectManager() const
BitmapFont Font
Fonts used for overlays.
virtual bool configExit()
Exit this window.
void startFrame(const uint32_t frameNumber)
Start a frame by unlocking all child resources.
A wrapper around AGL, WGL and GLX bitmap fonts.
A Node represents a single computer in the cluster.
Window * getSharedContextWindow()
ClientPtr getClient()
A facility class to manage OpenGL objects across shared contexts.
A Pipe represents a graphics card (GPU) on a Node.
lunchbox::RefPtr< Server > ServerPtr
A reference-counted pointer to an eq::Server.
const Window * getSharedContextWindow() const
virtual bool configInitSystemWindow(const uint128_t &initID)
Initialize the OS-specific window.
bool getRenderContext(const int32_t x, const int32_t y, RenderContext &context) const
Get the last rendering context at the x, y position.
float getFPS() const
virtual bool configInit(const uint128_t &initID)
Initialize this window.
lunchbox::RefPtr< Client > ClientPtr
A reference-counted pointer to an eq::Client.
The interface definition for system-specific GPU handling.
Definition: systemPipe.h:37
virtual void flush() const
Flush outstanding rendering requests.
const Node * getNode() const
ObjectManager * getObjectManager()
bool isStopped() const
void setSharedContextWindow(Window *sharedContextWindow)
Set the window with which this window shares the OpenGL context.
The interface definition for system-specific windowing code.
Definition: systemWindow.h:35
virtual void makeCurrent(const bool cache=true) const
Make the window&#39;s drawable and context current.
const Config * getConfig() const
virtual bool configInitGL(const uint128_t &initID)
Initialize the OpenGL state for this window.
virtual bool configExitSystemWindow()
De-initialize the OS-specific window.
const SystemPipe * getSystemPipe() const
const Font * getSmallFont()
eq::ObjectManager ObjectManager
The per-window OpenGL object manager.
Window(Pipe *parent)
Construct a new window.
virtual void drawFPS()
Render the current framerate as on overlay.
ServerPtr getServer()
virtual bool processEvent(const Event &event)
Process a received event.
virtual void swapBuffers()
Swap the front and back buffer of the window.
const SystemWindow * getSystemWindow() const
virtual void frameStart(const uint128_t &frameID, const uint32_t frameNumber)
Start rendering a frame.
const GLEWContext * glewGetContext() const
Get the GLEW context for this window.
virtual void frameDrawFinish(const uint128_t &frameID, const uint32_t frameNumber)
Finish drawing.
virtual ~Window()
Destruct the window.