Equalizer 1.0

include/eq/window.h

Go to the documentation of this file.
00001 
00002 /* Copyright (c) 2005-2011, 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/gl.h>            // GLEWContext
00023 #include <eq/types.h>
00024 #include <eq/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 util::BitmapFont< const void* > 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 
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 
00191         EQ_API uint32_t getColorFormat() const;
00193 
00203         virtual void flush() const { glFlush(); }
00204 
00212         virtual void finish() const { glFinish(); }
00213 
00215         EQ_API virtual void swapBuffers();
00216 
00218         EQ_API virtual void drawFPS();
00219 
00221         float getFPS() const { return _avgFPS; }
00222 
00232         EQ_API virtual void makeCurrent( const bool cache = true ) const;
00233 
00235         EQ_API virtual void bindFrameBuffer() const;
00236 
00238         EQ_API virtual void notifyViewportChanged();
00240 
00252         EQ_API void setSystemWindow( SystemWindow* window );
00253 
00255         const SystemWindow* getSystemWindow() const { return _systemWindow; }
00256 
00258         SystemWindow* getSystemWindow() { return _systemWindow; }
00259 
00261         const SystemPipe* getSystemPipe() const;
00262 
00264         SystemPipe* getSystemPipe(); 
00266 
00285         EQ_API virtual bool processEvent( const Event& event );
00287 
00288     protected:
00289         friend class Pipe;
00290 
00292         EQ_API virtual void attach( const UUID& id, const uint32_t instanceID );
00293 
00302         EQ_API void startFrame( const uint32_t frameNumber );
00303 
00310         EQ_API void releaseFrame( const uint32_t frameNumber );
00311 
00318         EQ_API void releaseFrameLocal( const uint32_t frameNumber );
00320 
00334          EQ_API virtual bool configInit( const uint128_t& initID );
00335 
00342         EQ_API virtual bool configInitSystemWindow( const uint128_t& initID );
00343 
00352         EQ_API virtual bool configInitGL( const uint128_t& initID );
00353 
00355         EQ_API virtual bool configExit();
00356 
00358         EQ_API virtual bool configExitSystemWindow();
00359 
00361         virtual bool configExitGL() { return true; }
00362 
00373         EQ_API virtual void frameStart( const uint128_t& frameID, 
00374                                         const uint32_t frameNumber );
00375 
00389         EQ_API virtual void frameFinish( const uint128_t& frameID, 
00390                                          const uint32_t frameNumber );
00391 
00402         EQ_API virtual void frameDrawFinish( const uint128_t& frameID,
00403                                              const uint32_t frameNumber );
00405 
00406     private:
00407         enum State
00408         {
00409             STATE_STOPPED,
00410             STATE_INITIALIZING,
00411             STATE_RUNNING,
00412             STATE_FAILED
00413         };
00414 
00416         Window* _sharedContextWindow;
00417 
00419         SystemWindow* _systemWindow;
00420 
00422         State _state;
00423 
00425         ObjectManager* _objectManager;
00426 
00428         float _lastTime;
00429 
00431         float _avgFPS;
00432 
00434         std::vector< RenderContext > _renderContexts[2];
00435         enum 
00436         {
00437             FRONT = 0,
00438             BACK  = 1
00439         };
00440 
00442         int64_t _lastSwapTime;
00443 
00444         struct Private;
00445         Private* _private; // placeholder for binary-compatible changes
00446 
00448         void _addRenderContext( const RenderContext& context );
00449         friend class Channel;
00450         
00452         void _setupObjectManager();
00454         void _releaseObjectManager();
00455 
00457         void _updateFPS();
00458 
00460         void _enterBarrier( co::ObjectVersion barrier );
00461 
00462         /* The command functions. */
00463         bool _cmdCreateChannel( co::Command& command );
00464         bool _cmdDestroyChannel(co::Command& command );
00465         bool _cmdConfigInit( co::Command& command );
00466         bool _cmdConfigExit( co::Command& command );
00467         bool _cmdFrameStart( co::Command& command );
00468         bool _cmdFrameFinish( co::Command& command );
00469         bool _cmdThrottleFramerate( co::Command& command );
00470         bool _cmdFinish( co::Command& command );
00471         bool _cmdBarrier( co::Command& command );
00472         bool _cmdNVBarrier( co::Command& command );
00473         bool _cmdSwap( co::Command& command );
00474         bool _cmdFrameDrawFinish( co::Command& command );
00475 
00476         EQ_TS_VAR( _pipeThread );
00477     };
00478 }
00479 
00480 #endif // EQ_WINDOW_H
00481 
Generated on Sun May 8 2011 19:11:08 for Equalizer 1.0 by  doxygen 1.7.3