Equalizer  1.3.1-git
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/gl.h>            // GLEWContext
00023 #include <eq/client/types.h>
00024 #include <eq/client/visitorResult.h> // enum
00025 
00026 #include <eq/util/bitmapFont.h>      // member
00027 #include <eq/fabric/renderContext.h> // member
00028 #include <eq/fabric/window.h>        // base class
00029 
00030 
00031 
00034 namespace eq
00035 {
00063     class Window : public fabric::Window< Pipe, Window, Channel >
00064     {
00065     public:
00067         typedef eq::ObjectManager ObjectManager;
00068 
00070         typedef BitmapFont Font;
00071 
00073         EQ_API Window( Pipe* parent );
00074 
00076         EQ_API virtual ~Window();
00077 
00080         EQ_API co::CommandQueue* getPipeThreadQueue(); 
00081         EQ_API co::CommandQueue* getCommandThreadQueue(); 
00082         EQ_API uint32_t getCurrentFrame() const; 
00083 
00085         EQ_API const Node* getNode() const; 
00086 
00088         EQ_API Node*       getNode();
00089 
00091         EQ_API const Config* getConfig() const;
00092 
00094         EQ_API Config*       getConfig();
00095 
00097         EQ_API ClientPtr getClient();
00098 
00100         EQ_API ServerPtr getServer();
00101 
00106         bool isRunning() const { return (_state == STATE_RUNNING); }
00107 
00112         bool isStopped() const { return (_state == STATE_STOPPED); }
00113 
00123         EQ_API bool getRenderContext( const int32_t x, const int32_t y,
00124                                          RenderContext& context ) const;
00126 
00137         void setSharedContextWindow( Window* sharedContextWindow )
00138             { _sharedContextWindow = sharedContextWindow; }
00139 
00144         const Window* getSharedContextWindow() const
00145             { return _sharedContextWindow; }
00146 
00151         Window* getSharedContextWindow() { return _sharedContextWindow; }
00152 
00154         ObjectManager* getObjectManager() { return _objectManager; }
00155 
00157         const ObjectManager* getObjectManager() const { return _objectManager; }
00158 
00163         EQ_API const Font* getSmallFont();
00164 
00169         EQ_API const Font* getMediumFont();
00170 
00185         EQ_API const GLEWContext* glewGetContext() const;
00186 
00194         EQ_API const GLEWContext* getTransferGlewContext();
00195 
00201         EQ_API uint32_t getColorFormat() const;
00203 
00213         virtual void flush() const { glFlush(); }
00214 
00222         virtual void finish() const { glFinish(); }
00223 
00225         EQ_API virtual void swapBuffers();
00226 
00228         EQ_API virtual void drawFPS();
00229 
00231         float getFPS() const { return _avgFPS; }
00232 
00242         EQ_API virtual void makeCurrent( const bool cache = true ) const;
00243 
00247         void makeCurrentTransfer( const bool cache = true );
00248 
00250         EQ_API virtual void bindFrameBuffer() const;
00251 
00253         EQ_API virtual void notifyViewportChanged();
00255 
00267         EQ_API void setSystemWindow( SystemWindow* window );
00268 
00270         const SystemWindow* getSystemWindow() const { return _systemWindow; }
00271 
00273         SystemWindow* getSystemWindow() { return _systemWindow; }
00274 
00276         const SystemPipe* getSystemPipe() const;
00277 
00279         SystemPipe* getSystemPipe(); 
00280 
00288         const eq::SystemWindow* getTransferSystemWindow();
00289 
00296         void deleteTransferSystemWindow();
00298 
00317         EQ_API virtual bool processEvent( const Event& event );
00319 
00320     protected:
00321         friend class Pipe;
00322 
00324         EQ_API virtual void attach( const UUID& id, const uint32_t instanceID );
00325 
00334         EQ_API void startFrame( const uint32_t frameNumber );
00335 
00342         EQ_API void releaseFrame( const uint32_t frameNumber );
00343 
00350         EQ_API void releaseFrameLocal( const uint32_t frameNumber );
00352 
00366          EQ_API virtual bool configInit( const uint128_t& initID );
00367 
00374         EQ_API virtual bool configInitSystemWindow( const uint128_t& initID );
00375 
00384         EQ_API virtual bool configInitGL( const uint128_t& initID );
00385 
00387         EQ_API virtual bool configExit();
00388 
00390         EQ_API virtual bool configExitSystemWindow();
00391 
00393         virtual bool configExitGL() { return true; }
00394 
00405         EQ_API virtual void frameStart( const uint128_t& frameID, 
00406                                         const uint32_t frameNumber );
00407 
00421         EQ_API virtual void frameFinish( const uint128_t& frameID, 
00422                                          const uint32_t frameNumber );
00423 
00434         EQ_API virtual void frameDrawFinish( const uint128_t& frameID,
00435                                              const uint32_t frameNumber );
00437 
00438     private:
00439         enum State
00440         {
00441             STATE_STOPPED,
00442             STATE_INITIALIZING,
00443             STATE_RUNNING,
00444             STATE_FAILED
00445         };
00446 
00448         Window* _sharedContextWindow;
00449 
00451         SystemWindow* _transferWindow;
00452 
00454         SystemWindow* _systemWindow;
00455 
00457         State _state;
00458 
00460         ObjectManager* _objectManager;
00461 
00463         float _lastTime;
00464 
00466         float _avgFPS;
00467 
00469         std::vector< RenderContext > _renderContexts[2];
00470         enum 
00471         {
00472             FRONT = 0,
00473             BACK  = 1
00474         };
00475 
00477         int64_t _lastSwapTime;
00478 
00479         struct Private;
00480         Private* _private; // placeholder for binary-compatible changes
00481 
00483         void _addRenderContext( const RenderContext& context );
00484         friend class Channel;
00485         
00487         void _setupObjectManager();
00489         void _releaseObjectManager();
00490 
00492         void _updateFPS();
00493 
00495         void _enterBarrier( co::ObjectVersion barrier );
00496 
00497         /* The command functions. */
00498         bool _cmdCreateChannel( co::Command& command );
00499         bool _cmdDestroyChannel(co::Command& command );
00500         bool _cmdConfigInit( co::Command& command );
00501         bool _cmdConfigExit( co::Command& command );
00502         bool _cmdFrameStart( co::Command& command );
00503         bool _cmdFrameFinish( co::Command& command );
00504         bool _cmdThrottleFramerate( co::Command& command );
00505         bool _cmdFlush( co::Command& command );
00506         bool _cmdFinish( co::Command& command );
00507         bool _cmdBarrier( co::Command& command );
00508         bool _cmdNVBarrier( co::Command& command );
00509         bool _cmdSwap( co::Command& command );
00510         bool _cmdFrameDrawFinish( co::Command& command );
00511 
00512         LB_TS_VAR( _pipeThread );
00513     };
00514 }
00515 
00516 #endif // EQ_WINDOW_H
00517 
Generated on Tue May 1 2012 15:14:29 for Equalizer 1.3.1-git by  doxygen 1.8.0