Equalizer  1.3.1-git
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 namespace detail { class Channel; struct RBStat; }
00032 
00033     struct ChannelFinishReadbackPacket;
00034     struct ChannelFrameSetReadyNodePacket;
00035     struct ChannelFrameSetReadyPacket;
00036     struct ChannelFrameTilesPacket;
00037     struct ChannelFrameTransmitImagePacket;
00038 
00050     class Channel : public fabric::Channel< Window, Channel >
00051     {
00052     public:
00054         EQ_API Channel( Window* parent );
00055 
00057         EQ_API virtual ~Channel();
00058 
00061         EQ_API co::CommandQueue* getPipeThreadQueue(); 
00062         EQ_API co::CommandQueue* getCommandThreadQueue(); 
00063         EQ_API uint32_t getCurrentFrame() const; 
00064         void waitFrameFinished( const uint32_t frame ) const; 
00065 
00070         EQ_API bool isStopped() const;
00071 
00073         EQ_API Pipe* getPipe();
00074 
00076         EQ_API const Pipe* getPipe() const;
00077 
00079         EQ_API Node* getNode();
00080 
00082         EQ_API const Node* getNode() const;
00083 
00085         EQ_API Config* getConfig();
00086 
00088         EQ_API const Config* getConfig() const;
00089 
00091         EQ_API ServerPtr getServer();
00092 
00107         EQ_API const GLEWContext* glewGetContext() const;
00108 
00110         EQ_API ObjectManager* getObjectManager();
00111 
00113         EQ_API const DrawableConfig& getDrawableConfig() const;
00114 
00126         EQ_API View* getNativeView();
00127 
00129         EQ_API const View* getNativeView() const;
00130 
00132         EQ_API util::FrameBufferObject* getFrameBufferObject();
00133 
00135         EQ_API const Vector3ub& getUniqueColor() const;
00136 
00138         EQ_API void addStatistic( Event& event );
00140 
00155         EQ_API virtual Vector2f getJitter() const;
00156 
00161         EQ_API const Frames& getInputFrames();
00162 
00167         EQ_API const Frames& getOutputFrames();
00168 
00182         EQ_API View* getView();
00183 
00185         EQ_API const View* getView() const;
00186 
00196         EQ_API Frustumf getScreenFrustum() const;
00198 
00212         EQ_API virtual void applyBuffer();
00213 
00219         EQ_API virtual void applyColorMask() const;
00220 
00226         EQ_API virtual void applyViewport() const;
00227 
00240         EQ_API virtual void applyFrustum() const;
00241 
00246         EQ_API virtual void applyPerspective() const;
00247 
00252         EQ_API virtual void applyOrtho() const;
00253 
00261         EQ_API void applyScreenFrustum() const;
00262 
00268         EQ_API virtual void applyHeadTransform() const;
00269 
00274         EQ_API virtual void applyPerspectiveTransform() const;
00275 
00280         EQ_API virtual void applyOrthoTransform() const;
00281 
00286         EQ_API virtual void applyFrameBufferObject();
00287 
00292         EQ_API void bindFrameBuffer();        
00294 
00304         EQ_API virtual void resetRegions();
00305 
00315         EQ_API virtual void declareRegion( const eq::PixelViewport& region );
00316 
00323         EQ_API void declareRegion( const eq::Viewport& vp );
00324 
00326         EQ_API PixelViewport getRegion() const;
00327 
00339         EQ_API const PixelViewports& getRegions() const;
00340 
00342 
00354         EQ_API virtual bool processEvent( const Event& event );
00355 
00357         EQ_API virtual void drawStatistics();
00358 
00360         EQ_API virtual void outlineViewport();
00361 
00368         void changeLatency( const uint32_t latency );
00369 
00370     protected:
00372         EQ_API void attach( const UUID& id, const uint32_t instanceID );
00373 
00382         EQ_API void startFrame( const uint32_t frameNumber );
00383 
00390         EQ_API void releaseFrame( const uint32_t frameNumber );
00391 
00398         EQ_API void releaseFrameLocal( const uint32_t frameNumber );
00399 
00410         EQ_API virtual void setupAssemblyState();
00411 
00413         EQ_API virtual void resetAssemblyState();
00415 
00431         EQ_API virtual bool configInit( const uint128_t& initID );
00432 
00434         EQ_API virtual bool configExit();
00435 
00447         EQ_API virtual void frameStart( const uint128_t& frameID,
00448                                         const uint32_t frameNumber );
00449 
00460         EQ_API virtual void frameFinish( const uint128_t& frameID, 
00461                                          const uint32_t frameNumber );
00462 
00473         EQ_API virtual void frameDrawFinish( const uint128_t& frameID, 
00474                                              const uint32_t frameNumber );
00475 
00484         EQ_API virtual void frameClear( const uint128_t& frameID );
00485 
00494         EQ_API virtual void frameDraw( const uint128_t& frameID );
00495 
00505         EQ_API virtual void frameAssemble( const uint128_t& frameID );
00506 
00516          EQ_API virtual void frameReadback( const uint128_t& frameID );
00517 
00528         EQ_API virtual void frameViewStart( const uint128_t& frameID );
00529 
00543         EQ_API virtual void frameViewFinish( const uint128_t& frameID );
00545 
00547         virtual void frameTilesStart( const uint128_t& frameID ) {}
00548 
00550         virtual void frameTilesFinish( const uint128_t& frameID ) {}
00551 
00553         EQ_API virtual void notifyViewportChanged();
00554 
00567         virtual void notifyStopFrame( const uint32_t lastFrameNumber ) {}
00568 
00569     private:
00570         detail::Channel* const _impl;
00571         friend class fabric::Window< Pipe, Window, Channel >;
00572 
00573         //-------------------- Methods --------------------
00575         void _setRenderContext( RenderContext& context );
00576 
00578         bool _configInitFBO();
00579 
00581         void _initDrawableConfig();
00582 
00584         void _frameTiles( const ChannelFrameTilesPacket* packet );
00585 
00587         void _refFrame( const uint32_t frameNumber );
00588 
00590         void _unrefFrame( const uint32_t frameNumber );
00591 
00593         void _transmitImage( const ChannelFrameTransmitImagePacket* packet );
00594         
00595         void _frameReadback( const uint128_t& frameID, uint32_t nFrames,
00596                              co::ObjectVersion* frames );
00597         void _finishReadback( const ChannelFinishReadbackPacket* packet );
00598 
00599         bool _asyncFinishReadback( const std::vector< size_t >& imagePos );
00600 
00601         void _asyncTransmit( FrameData* frame, const uint32_t frameNumber,
00602                              const size_t image,
00603                              const std::vector<uint128_t>& nodes,
00604                              const std::vector< uint128_t >& netNodes,
00605                              const uint32_t taskID );
00606 
00607         void _setReady( const bool async, detail::RBStat* stat );
00608         void _asyncSetReady( const FrameData* frame, detail::RBStat* stat,
00609                              const std::vector< uint128_t >& nodes,
00610                              const std::vector< uint128_t >& netNodes );
00611 
00612         void _setReady( FrameData* frame, detail::RBStat* stat,
00613                         const std::vector< uint128_t >& nodes,
00614                         const std::vector< uint128_t >& netNodes );
00615 
00617         co::QueueSlave* _getQueue( const co::ObjectVersion& queueVersion );
00618 
00619         void _setOutputFrames( const uint32_t nFrames,
00620                                const co::ObjectVersion* frames );
00621         void _resetOutputFrames();
00622 
00623         void _deleteTransferContext();
00624 
00625         /* The command handler functions. */
00626         bool _cmdConfigInit( co::Command& command );
00627         bool _cmdConfigExit( co::Command& command );
00628         bool _cmdFrameStart( co::Command& command );
00629         bool _cmdFrameFinish( co::Command& command );
00630         bool _cmdFrameClear( co::Command& command );
00631         bool _cmdFrameDraw( co::Command& command );
00632         bool _cmdFrameDrawFinish( co::Command& command );
00633         bool _cmdFrameAssemble( co::Command& command );
00634         bool _cmdFrameReadback( co::Command& command );
00635         bool _cmdFinishReadback( co::Command& command );
00636         bool _cmdFrameSetReady( co::Command& command );
00637         bool _cmdFrameTransmitImage( co::Command& command );
00638         bool _cmdFrameSetReadyNode( co::Command& command );
00639         bool _cmdFrameViewStart( co::Command& command );
00640         bool _cmdFrameViewFinish( co::Command& command );
00641         bool _cmdStopFrame( co::Command& command );
00642         bool _cmdFrameTiles( co::Command& command );
00643         bool _cmdDeleteTransferContext( co::Command& command );
00644 
00645         LB_TS_VAR( _pipeThread );
00646     };
00647 }
00648 
00649 #endif // EQ_CHANNEL_H
00650 
Generated on Tue May 1 2012 15:14:24 for Equalizer 1.3.1-git by  doxygen 1.8.0