Equalizer  1.2.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/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 
00192         EQ_API uint32_t getColorFormat() const;
00194 
00204         virtual void flush() const { glFlush(); }
00205 
00213         virtual void finish() const { glFinish(); }
00214 
00216         EQ_API virtual void swapBuffers();
00217 
00219         EQ_API virtual void drawFPS();
00220 
00222         float getFPS() const { return _avgFPS; }
00223 
00233         EQ_API virtual void makeCurrent( const bool cache = true ) const;
00234 
00236         EQ_API virtual void bindFrameBuffer() const;
00237 
00239         EQ_API virtual void notifyViewportChanged();
00241 
00253         EQ_API void setSystemWindow( SystemWindow* window );
00254 
00256         const SystemWindow* getSystemWindow() const { return _systemWindow; }
00257 
00259         SystemWindow* getSystemWindow() { return _systemWindow; }
00260 
00262         const SystemPipe* getSystemPipe() const;
00263 
00265         SystemPipe* getSystemPipe(); 
00267 
00286         EQ_API virtual bool processEvent( const Event& event );
00288 
00289     protected:
00290         friend class Pipe;
00291 
00293         EQ_API virtual void attach( const UUID& id, const uint32_t instanceID );
00294 
00303         EQ_API void startFrame( const uint32_t frameNumber );
00304 
00311         EQ_API void releaseFrame( const uint32_t frameNumber );
00312 
00319         EQ_API void releaseFrameLocal( const uint32_t frameNumber );
00321 
00335          EQ_API virtual bool configInit( const uint128_t& initID );
00336 
00343         EQ_API virtual bool configInitSystemWindow( const uint128_t& initID );
00344 
00353         EQ_API virtual bool configInitGL( const uint128_t& initID );
00354 
00356         EQ_API virtual bool configExit();
00357 
00359         EQ_API virtual bool configExitSystemWindow();
00360 
00362         virtual bool configExitGL() { return true; }
00363 
00374         EQ_API virtual void frameStart( const uint128_t& frameID, 
00375                                         const uint32_t frameNumber );
00376 
00390         EQ_API virtual void frameFinish( const uint128_t& frameID, 
00391                                          const uint32_t frameNumber );
00392 
00403         EQ_API virtual void frameDrawFinish( const uint128_t& frameID,
00404                                              const uint32_t frameNumber );
00406 
00407     private:
00408         enum State
00409         {
00410             STATE_STOPPED,
00411             STATE_INITIALIZING,
00412             STATE_RUNNING,
00413             STATE_FAILED
00414         };
00415 
00417         Window* _sharedContextWindow;
00418 
00420         SystemWindow* _systemWindow;
00421 
00423         State _state;
00424 
00426         ObjectManager* _objectManager;
00427 
00429         float _lastTime;
00430 
00432         float _avgFPS;
00433 
00435         std::vector< RenderContext > _renderContexts[2];
00436         enum 
00437         {
00438             FRONT = 0,
00439             BACK  = 1
00440         };
00441 
00443         int64_t _lastSwapTime;
00444 
00445         struct Private;
00446         Private* _private; // placeholder for binary-compatible changes
00447 
00449         void _addRenderContext( const RenderContext& context );
00450         friend class Channel;
00451         
00453         void _setupObjectManager();
00455         void _releaseObjectManager();
00456 
00458         void _updateFPS();
00459 
00461         void _enterBarrier( co::ObjectVersion barrier );
00462 
00463         /* The command functions. */
00464         bool _cmdCreateChannel( co::Command& command );
00465         bool _cmdDestroyChannel(co::Command& command );
00466         bool _cmdConfigInit( co::Command& command );
00467         bool _cmdConfigExit( co::Command& command );
00468         bool _cmdFrameStart( co::Command& command );
00469         bool _cmdFrameFinish( co::Command& command );
00470         bool _cmdThrottleFramerate( co::Command& command );
00471         bool _cmdFinish( co::Command& command );
00472         bool _cmdBarrier( co::Command& command );
00473         bool _cmdNVBarrier( co::Command& command );
00474         bool _cmdSwap( co::Command& command );
00475         bool _cmdFrameDrawFinish( co::Command& command );
00476 
00477         EQ_TS_VAR( _pipeThread );
00478     };
00479 }
00480 
00481 #endif // EQ_WINDOW_H
00482 
Generated on Fri Jun 8 2012 15:44:33 for Equalizer 1.2.1 by  doxygen 1.8.0