Equalizer  1.2.1
include/eq/client/channel.h
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_CHANNEL_H
00020 #define EQ_CHANNEL_H
00021 
00022 #include <eq/client/event.h>          // member
00023 #include <eq/client/types.h>
00024 #include <eq/client/gl.h>             // GLEWContext
00025 
00026 #include <eq/fabric/channel.h>        // base class
00027 #include <eq/fabric/drawableConfig.h> // member
00028 
00029 namespace eq
00030 {
00031     struct ChannelFrameTransmitImagePacket;
00032     struct ChannelFrameSetReadyPacket;
00033 
00045     class Channel : public fabric::Channel< Window, Channel >
00046     {
00047     public:
00049         EQ_API Channel( Window* parent );
00050 
00052         EQ_API virtual ~Channel();
00053 
00056         EQ_API co::CommandQueue* getPipeThreadQueue(); 
00057         EQ_API co::CommandQueue* getCommandThreadQueue(); 
00058         EQ_API uint32_t getCurrentFrame() const; 
00059 
00064         bool isStopped() const { return (_state == STATE_STOPPED); }
00065 
00067         EQ_API Pipe* getPipe();
00068 
00070         EQ_API const Pipe* getPipe() const;
00071 
00073         EQ_API Node* getNode();
00074 
00076         EQ_API const Node* getNode() const;
00077 
00079         EQ_API Config* getConfig();
00080 
00082         EQ_API const Config* getConfig() const;
00083 
00085         EQ_API ServerPtr getServer();
00086 
00101         EQ_API const GLEWContext* glewGetContext() const;
00102 
00104         EQ_API ObjectManager* getObjectManager();
00105 
00107         EQ_API const DrawableConfig& getDrawableConfig() const;
00108 
00120         EQ_API View* getNativeView();
00121 
00123         EQ_API const View* getNativeView() const;
00124 
00126         EQ_API util::FrameBufferObject* getFrameBufferObject();
00127 
00129         EQ_API void addStatistic( Event& event, const uint32_t index );
00131 
00146         EQ_API virtual Vector2f getJitter() const;
00147 
00152         const Frames& getInputFrames() { return _inputFrames; }
00153 
00158         const Frames& getOutputFrames() { return _outputFrames; }
00159 
00173         EQ_API View* getView();
00174 
00176         EQ_API const View* getView() const;
00177 
00187         EQ_API Frustumf getScreenFrustum() const;
00189 
00203         EQ_API virtual void applyBuffer();
00204 
00210         EQ_API virtual void applyColorMask() const;
00211 
00217         EQ_API virtual void applyViewport() const;
00218 
00231         EQ_API virtual void applyFrustum() const;
00232 
00237         EQ_API virtual void applyPerspective() const;
00238 
00243         EQ_API virtual void applyOrtho() const;
00244 
00252         EQ_API void applyScreenFrustum() const;
00253 
00259         EQ_API virtual void applyHeadTransform() const;
00260 
00265         EQ_API virtual void applyPerspectiveTransform() const;
00266 
00271         EQ_API virtual void applyOrthoTransform() const;
00272 
00277         EQ_API virtual void applyFrameBufferObject();
00278 
00283         EQ_API void bindFrameBuffer();        
00285 
00297         EQ_API virtual bool processEvent( const Event& event );
00298 
00300         EQ_API virtual void drawStatistics();
00301 
00303         EQ_API virtual void outlineViewport();
00304 
00311         void changeLatency( const uint32_t latency );
00312 
00314         const Vector3ub& getUniqueColor() const { return _color; }
00315 
00316     protected:
00318         EQ_API void attach( const UUID& id, const uint32_t instanceID );
00319 
00328         EQ_API void startFrame( const uint32_t frameNumber );
00329 
00336         EQ_API void releaseFrame( const uint32_t frameNumber );
00337 
00344         EQ_API void releaseFrameLocal( const uint32_t frameNumber );
00345 
00356         EQ_API virtual void setupAssemblyState();
00357 
00359         EQ_API virtual void resetAssemblyState();
00361 
00377         EQ_API virtual bool configInit( const uint128_t& initID );
00378 
00380         EQ_API virtual bool configExit();
00381 
00393         EQ_API virtual void frameStart( const uint128_t& frameID,
00394                                         const uint32_t frameNumber );
00395 
00406         EQ_API virtual void frameFinish( const uint128_t& frameID, 
00407                                          const uint32_t frameNumber );
00408 
00419         EQ_API virtual void frameDrawFinish( const uint128_t& frameID, 
00420                                              const uint32_t frameNumber );
00421 
00430         EQ_API virtual void frameClear( const uint128_t& frameID );
00431 
00440         EQ_API virtual void frameDraw( const uint128_t& frameID );
00441 
00451         EQ_API virtual void frameAssemble( const uint128_t& frameID );
00452 
00462          EQ_API virtual void frameReadback( const uint128_t& frameID );
00463 
00474         EQ_API virtual void frameViewStart( const uint128_t& frameID );
00475 
00489         EQ_API virtual void frameViewFinish( const uint128_t& frameID );
00491 
00493         virtual void frameTilesStart( const uint128_t& frameID ) {}
00494 
00496         virtual void frameTilesFinish( const uint128_t& frameID ) {}
00497 
00499         EQ_API virtual void notifyViewportChanged();
00500 
00513         virtual void notifyStopFrame( const uint32_t lastFrameNumber ) {}
00514 
00515     private:
00516         //-------------------- Members --------------------
00517         friend class fabric::Window< Pipe, Window, Channel >;
00518 
00520         DrawableConfig _drawableConfig;
00521 
00522         enum State
00523         {
00524             STATE_STOPPED,
00525             STATE_INITIALIZING,
00526             STATE_RUNNING,
00527             STATE_FAILED
00528         };
00529 
00531         State _state;
00532 
00534         Frames _outputFrames;
00535 
00537         Frames _inputFrames;
00538 
00540         util::FrameBufferObject* _fbo; 
00541 
00543         Vector3ub _color;
00544 
00545         typedef std::vector< Statistic > Statistics;
00546         struct FrameStatistics
00547         {
00548             Statistics data; 
00549 
00550             co::base::a_int32_t used;
00551         };
00552 
00553         typedef std::vector< FrameStatistics > StatisticsRB;
00554 
00556         co::base::Lockable< StatisticsRB, co::base::SpinLock > _statistics;
00557         /* Index of current vector StatisticsRB */ 
00558         uint32_t _statisticsIndex;
00559         friend class ChannelStatistics;
00560 
00562         Vector2i _initialSize;
00563 
00564         struct Private;
00565         Private* _private; // placeholder for binary-compatible changes
00566 
00567         //-------------------- Methods --------------------
00569         void _setRenderContext( RenderContext& context );
00570 
00572         bool _configInitFBO();
00573 
00575         void _initDrawableConfig();
00576 
00578         void _unrefFrame( const uint32_t frameNumber, const uint32_t index );
00579 
00581         void _transmitImage( Image* image, 
00582                              const ChannelFrameTransmitImagePacket* packet );
00583         
00585         void _sendFrameDataReady( const ChannelFrameTransmitImagePacket* packet );
00586 
00587         void _setOutputFrames( uint32_t nFrames, co::ObjectVersion* frames );
00588         void _frameReadback( const uint128_t& frameID, uint32_t nFrames,
00589                              co::ObjectVersion* frames );
00590 
00592         co::QueueSlave* _getQueue( const co::ObjectVersion& queueVersion );
00593 
00595         void _transmitImages( const RenderContext& context, Frame* frame,
00596                               const size_t startPos );
00597 
00599         void _resetOutputFrames( const RenderContext& context );
00600 
00601         /* The command handler functions. */
00602         bool _cmdConfigInit( co::Command& command );
00603         bool _cmdConfigExit( co::Command& command );
00604         bool _cmdFrameStart( co::Command& command );
00605         bool _cmdFrameFinish( co::Command& command );
00606         bool _cmdFrameClear( co::Command& command );
00607         bool _cmdFrameDraw( co::Command& command );
00608         bool _cmdFrameDrawFinish( co::Command& command );
00609         bool _cmdFrameAssemble( co::Command& command );
00610         bool _cmdFrameReadback( co::Command& command );
00611         bool _cmdFrameTransmitImage( co::Command& command );
00612         bool _cmdFrameSetReady( co::Command& command );
00613         bool _cmdFrameViewStart( co::Command& command );
00614         bool _cmdFrameViewFinish( co::Command& command );
00615         bool _cmdStopFrame( co::Command& command );
00616         bool _cmdFrameTiles( co::Command& command );
00617 
00618         EQ_TS_VAR( _pipeThread );
00619     };
00620 }
00621 
00622 #endif // EQ_CHANNEL_H
00623 
Generated on Fri Jun 8 2012 15:44:29 for Equalizer 1.2.1 by  doxygen 1.8.0