Equalizer 1.0

include/eq/channel.h

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_CHANNEL_H
00020 #define EQ_CHANNEL_H
00021 
00022 #include <eq/event.h>          // member
00023 #include <eq/types.h>
00024 #include <eq/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 ChannelFrameTransmitPacket;
00032 
00044     class Channel : public fabric::Channel< Window, Channel >
00045     {
00046     public:
00048         EQ_API Channel( Window* parent );
00049 
00051         EQ_API virtual ~Channel();
00052 
00055         EQ_API co::CommandQueue* getPipeThreadQueue(); 
00056         EQ_API co::CommandQueue* getCommandThreadQueue(); 
00057 
00062         bool isStopped() const { return (_state == STATE_STOPPED); }
00063 
00065         EQ_API Pipe* getPipe();
00066 
00068         EQ_API const Pipe* getPipe() const;
00069 
00071         EQ_API Node* getNode();
00072 
00074         EQ_API const Node* getNode() const;
00075 
00077         EQ_API Config* getConfig();
00078 
00080         EQ_API const Config* getConfig() const;
00081 
00083         EQ_API ServerPtr getServer();
00084 
00099         EQ_API const GLEWContext* glewGetContext() const;
00100 
00102         EQ_API ObjectManager* getObjectManager();
00103 
00105         EQ_API const DrawableConfig& getDrawableConfig() const;
00106 
00118         EQ_API View* getNativeView();
00119 
00121         EQ_API const View* getNativeView() const;
00122 
00124         EQ_API util::FrameBufferObject* getFrameBufferObject();
00125 
00127         EQ_API void addStatistic( Event& event, const uint32_t index );
00129 
00144         EQ_API virtual Vector2f getJitter() const;
00145 
00150         const Frames& getInputFrames() { return _inputFrames; }
00151 
00156         const Frames& getOutputFrames() { return _outputFrames; }
00157 
00171         EQ_API View* getView();
00172 
00174         EQ_API const View* getView() const;
00175 
00185         EQ_API Frustumf getScreenFrustum() const;
00187 
00201         EQ_API virtual void applyBuffer();
00202 
00208         EQ_API virtual void applyColorMask() const;
00209 
00215         EQ_API virtual void applyViewport() const;
00216 
00229         EQ_API virtual void applyFrustum() const;
00230 
00235         EQ_API virtual void applyPerspective() const;
00236 
00241         EQ_API virtual void applyOrtho() const;
00242 
00250         EQ_API void applyScreenFrustum() const;
00251 
00257         EQ_API virtual void applyHeadTransform() const;
00258 
00263         EQ_API virtual void applyPerspectiveTransform() const;
00264 
00269         EQ_API virtual void applyOrthoTransform() const;
00270 
00275         EQ_API virtual void applyFrameBufferObject();
00276 
00281         EQ_API void bindFrameBuffer();        
00283 
00295         EQ_API virtual bool processEvent( const Event& event );
00296 
00298         EQ_API virtual void drawStatistics();
00299 
00301         EQ_API virtual void outlineViewport();
00302 
00309         void changeLatency( const uint32_t latency );
00310 
00312         const Vector3ub& getUniqueColor() const { return _color; }
00313 
00314     protected:
00316         EQ_API void attach( const UUID& id, const uint32_t instanceID );
00317 
00326         EQ_API void startFrame( const uint32_t frameNumber );
00327 
00334         EQ_API void releaseFrame( const uint32_t frameNumber );
00335 
00342         EQ_API void releaseFrameLocal( const uint32_t frameNumber );
00343 
00354         EQ_API virtual void setupAssemblyState();
00355 
00357         EQ_API virtual void resetAssemblyState();
00359 
00375         EQ_API virtual bool configInit( const uint128_t& initID );
00376 
00378         EQ_API virtual bool configExit();
00379 
00391         EQ_API virtual void frameStart( const uint128_t& frameID,
00392                                         const uint32_t frameNumber );
00393 
00404         EQ_API virtual void frameFinish( const uint128_t& frameID, 
00405                                          const uint32_t frameNumber );
00406 
00417         EQ_API virtual void frameDrawFinish( const uint128_t& frameID, 
00418                                              const uint32_t frameNumber );
00419 
00428         EQ_API virtual void frameClear( const uint128_t& frameID );
00429 
00438         EQ_API virtual void frameDraw( const uint128_t& frameID );
00439 
00449         EQ_API virtual void frameAssemble( const uint128_t& frameID );
00450 
00460          EQ_API virtual void frameReadback( const uint128_t& frameID );
00461 
00472         EQ_API virtual void frameViewStart( const uint128_t& frameID );
00473 
00487         EQ_API virtual void frameViewFinish( const uint128_t& frameID );
00489 
00491         EQ_API virtual void notifyViewportChanged();
00492 
00505         virtual void notifyStopFrame( const uint32_t lastFrameNumber ) {}
00506 
00507     private:
00508         //-------------------- Members --------------------
00509         friend class fabric::Window< Pipe, Window, Channel >;
00510 
00512         DrawableConfig _drawableConfig;
00513 
00514         enum State
00515         {
00516             STATE_STOPPED,
00517             STATE_INITIALIZING,
00518             STATE_RUNNING,
00519             STATE_FAILED
00520         };
00521 
00523         State _state;
00524 
00526         Frames _outputFrames;
00527 
00529         Frames _inputFrames;
00530 
00532         util::FrameBufferObject* _fbo; 
00533 
00535         Vector3ub _color;
00536 
00537         typedef std::vector< Statistic > Statistics;
00538         struct FrameStatistics
00539         {
00540             Statistics data; 
00541 
00542             co::base::a_int32_t used;
00543         };
00544 
00545         typedef std::vector< FrameStatistics > StatisticsRB;
00546 
00548         co::base::Lockable< StatisticsRB, co::base::SpinLock > _statistics;
00549         /* Index of current vector StatisticsRB */ 
00550         uint32_t _statisticsIndex;
00551         friend class ChannelStatistics;
00552 
00554         Vector2i _initialSize;
00555 
00556         struct Private;
00557         Private* _private; // placeholder for binary-compatible changes
00558 
00559         //-------------------- Methods --------------------
00561         void _setRenderContext( RenderContext& context );
00562 
00564         bool _configInitFBO();
00565 
00567         void _initDrawableConfig();
00568 
00570         void _unrefFrame( const uint32_t frameNumber, const uint32_t index );
00571 
00573         void _transmit( const ChannelFrameTransmitPacket* packet );
00574 
00575         /* The command handler functions. */
00576         bool _cmdConfigInit( co::Command& command );
00577         bool _cmdConfigExit( co::Command& command );
00578         bool _cmdFrameStart( co::Command& command );
00579         bool _cmdFrameFinish( co::Command& command );
00580         bool _cmdFrameClear( co::Command& command );
00581         bool _cmdFrameDraw( co::Command& command );
00582         bool _cmdFrameDrawFinish( co::Command& command );
00583         bool _cmdFrameAssemble( co::Command& command );
00584         bool _cmdFrameReadback( co::Command& command );
00585         bool _cmdFrameTransmit( co::Command& command );
00586         bool _cmdFrameTransmitAsync( co::Command& command );
00587         bool _cmdFrameViewStart( co::Command& command );
00588         bool _cmdFrameViewFinish( co::Command& command );
00589         bool _cmdStopFrame( co::Command& command );
00590 
00591         EQ_TS_VAR( _pipeThread );
00592     };
00593 }
00594 
00595 #endif // EQ_CHANNEL_H
00596 
Generated on Sun May 8 2011 19:11:05 for Equalizer 1.0 by  doxygen 1.7.3