Equalizer  1.4.1
include/eq/client/window.h
Go to the documentation of this file.
00001 
00002 /* Copyright (c) 2005-2012, Stefan Eilemann <eile@equalizergraphics.com>
00003  *                    2010, Cedric Stalder <cedric.stalder@gmail.com>
00004  *
00005  * This library is free software; you can redistribute it and/or modify it under
00006  * the terms of the GNU Lesser General Public License version 2.1 as published
00007  * by the Free Software Foundation.
00008  *
00009  * This library is distributed in the hope that it will be useful, but WITHOUT
00010  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00012  * details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public License
00015  * along with this library; if not, write to the Free Software Foundation, Inc.,
00016  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00017  */
00018 
00019 #ifndef EQ_WINDOW_H
00020 #define EQ_WINDOW_H
00021 
00022 #include <eq/client/types.h>
00023 #include <eq/client/visitorResult.h> // enum
00024 
00025 #include <eq/util/bitmapFont.h>      // member
00026 #include <eq/fabric/renderContext.h> // member
00027 #include <eq/fabric/window.h>        // base class
00028 
00029 
00030 
00033 namespace eq
00034 {
00062     class Window : public fabric::Window< Pipe, Window, Channel >
00063     {
00064     public:
00066         typedef eq::ObjectManager ObjectManager;
00067 
00069         typedef BitmapFont Font;
00070 
00072         EQ_API Window( Pipe* parent );
00073 
00075         EQ_API virtual ~Window();
00076 
00079         EQ_API co::CommandQueue* getPipeThreadQueue(); 
00080         EQ_API co::CommandQueue* getCommandThreadQueue(); 
00081         EQ_API uint32_t getCurrentFrame() const; 
00082 
00084         EQ_API const Node* getNode() const;
00085 
00087         EQ_API Node*       getNode();
00088 
00090         EQ_API const Config* getConfig() const;
00091 
00093         EQ_API Config*       getConfig();
00094 
00096         EQ_API ClientPtr getClient();
00097 
00099         EQ_API ServerPtr getServer();
00100 
00105         bool isRunning() const { return (_state == STATE_RUNNING); }
00106 
00111         bool isStopped() const { return (_state == STATE_STOPPED); }
00112 
00122         EQ_API bool getRenderContext( const int32_t x, const int32_t y,
00123                                       RenderContext& context ) const;
00125 
00136         void setSharedContextWindow( Window* sharedContextWindow )
00137             { _sharedContextWindow = sharedContextWindow; }
00138 
00143         const Window* getSharedContextWindow() const
00144             { return _sharedContextWindow; }
00145 
00150         Window* getSharedContextWindow() { return _sharedContextWindow; }
00151 
00153         ObjectManager* getObjectManager() { return _objectManager; }
00154 
00156         const ObjectManager* getObjectManager() const { return _objectManager; }
00157 
00162         EQ_API const Font* getSmallFont();
00163 
00168         EQ_API const Font* getMediumFont();
00169 
00184         EQ_API const GLEWContext* glewGetContext() const;
00185 
00193         EQ_API const GLEWContext* getTransferGlewContext();
00194 
00200         EQ_API uint32_t getColorFormat() const;
00202 
00212         EQ_API virtual void flush() const;
00213 
00221         EQ_API virtual void finish() const;
00222 
00224         EQ_API virtual void swapBuffers();
00225 
00227         EQ_API virtual void drawFPS();
00228 
00230         float getFPS() const { return _avgFPS; }
00231 
00241         EQ_API virtual void makeCurrent( const bool cache = true ) const;
00242 
00246         void makeCurrentTransfer( const bool cache = true );
00247 
00249         EQ_API virtual void bindFrameBuffer() const;
00250 
00252         EQ_API virtual void notifyViewportChanged();
00254 
00266         EQ_API void setSystemWindow( SystemWindow* window );
00267 
00269         const SystemWindow* getSystemWindow() const { return _systemWindow; }
00270 
00272         SystemWindow* getSystemWindow() { return _systemWindow; }
00273 
00275         const SystemPipe* getSystemPipe() const;
00276 
00278         SystemPipe* getSystemPipe();
00279 
00281         bool createTransferWindow();
00282 
00284         void deleteTransferSystemWindow();
00286 
00305         EQ_API virtual bool processEvent( const Event& event );
00307 
00308     protected:
00309         friend class Pipe;
00310 
00312         EQ_API virtual void attach( const UUID& id, const uint32_t instanceID );
00313 
00322         EQ_API void startFrame( const uint32_t frameNumber );
00323 
00330         EQ_API void releaseFrame( const uint32_t frameNumber );
00331 
00338         EQ_API void releaseFrameLocal( const uint32_t frameNumber );
00340 
00354          EQ_API virtual bool configInit( const uint128_t& initID );
00355 
00362         EQ_API virtual bool configInitSystemWindow( const uint128_t& initID );
00363 
00372         EQ_API virtual bool configInitGL( const uint128_t& initID );
00373 
00375         EQ_API virtual bool configExit();
00376 
00378         EQ_API virtual bool configExitSystemWindow();
00379 
00381         virtual bool configExitGL() { return true; }
00382 
00393         EQ_API virtual void frameStart( const uint128_t& frameID,
00394                                         const uint32_t frameNumber );
00395 
00409         EQ_API virtual void frameFinish( const uint128_t& frameID,
00410                                          const uint32_t frameNumber );
00411 
00422         EQ_API virtual void frameDrawFinish( const uint128_t& frameID,
00423                                              const uint32_t frameNumber );
00425 
00426     private:
00427         enum State
00428         {
00429             STATE_STOPPED,
00430             STATE_INITIALIZING,
00431             STATE_RUNNING,
00432             STATE_FAILED
00433         };
00434 
00436         Window* _sharedContextWindow;
00437 
00439         SystemWindow* _transferWindow;
00440 
00442         SystemWindow* _systemWindow;
00443 
00445         State _state;
00446 
00448         ObjectManager* _objectManager;
00449 
00451         float _lastTime;
00452 
00454         float _avgFPS;
00455 
00457         std::vector< RenderContext > _renderContexts[2];
00458         enum
00459         {
00460             FRONT = 0,
00461             BACK  = 1
00462         };
00463 
00465         int64_t _lastSwapTime;
00466 
00467         struct Private;
00468         Private* _private; // placeholder for binary-compatible changes
00469 
00471         void _addRenderContext( const RenderContext& context );
00472         friend class Channel;
00473 
00475         void _setupObjectManager();
00477         void _releaseObjectManager();
00478 
00480         void _updateFPS();
00481 
00483         void _enterBarrier( co::ObjectVersion barrier );
00484 
00485         /* The command functions. */
00486         bool _cmdCreateChannel( co::Command& command );
00487         bool _cmdDestroyChannel(co::Command& command );
00488         bool _cmdConfigInit( co::Command& command );
00489         bool _cmdConfigExit( co::Command& command );
00490         bool _cmdFrameStart( co::Command& command );
00491         bool _cmdFrameFinish( co::Command& command );
00492         bool _cmdThrottleFramerate( co::Command& command );
00493         bool _cmdFlush( co::Command& command );
00494         bool _cmdFinish( co::Command& command );
00495         bool _cmdBarrier( co::Command& command );
00496         bool _cmdNVBarrier( co::Command& command );
00497         bool _cmdSwap( co::Command& command );
00498         bool _cmdFrameDrawFinish( co::Command& command );
00499 
00500         LB_TS_VAR( _pipeThread );
00501     };
00502 }
00503 
00504 #endif // EQ_WINDOW_H
00505 
Generated on Mon Nov 26 2012 14:41:50 for Equalizer 1.4.1 by  doxygen 1.7.6.1