lib/client/channel.h

00001 
00002 /* Copyright (c) 2005-2009, Stefan Eilemann <eile@equalizergraphics.com> 
00003  *
00004  * This library is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU Lesser General Public License version 2.1 as published
00006  * by the Free Software Foundation.
00007  *  
00008  * This library is distributed in the hope that it will be useful, but WITHOUT
00009  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00010  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00011  * details.
00012  * 
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this library; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016  */
00017 
00018 #ifndef EQ_CHANNEL_H
00019 #define EQ_CHANNEL_H
00020 
00021 #include <eq/client/event.h>         // member
00022 #include <eq/client/renderContext.h> // member
00023 #include <eq/client/types.h>
00024 #include <eq/client/visitorResult.h> // enum
00025 #include <eq/client/windowSystem.h>  // GLEWContext
00026 #include <eq/client/window.h>
00027 
00028 #include <eq/net/object.h>           // base class
00029 
00030 namespace eq
00031 {
00032 namespace util
00033 {
00034     class FrameBufferObject;
00035 }
00036     class ChannelVisitor;
00037     class Pixel;
00038     class Range;
00039     class SceneObject;
00040     struct RenderContext;
00041 
00051     class Channel : public net::Object
00052     {
00053     public:
00054     
00061         enum Drawable
00062         {
00063             FB_WINDOW   = EQ_BIT_NONE, 
00064             FBO_COLOR   = EQ_BIT1,     
00065             FBO_DEPTH   = EQ_BIT2,     
00066             FBO_STENCIL = EQ_BIT3      
00067         };
00068         
00070         EQ_EXPORT Channel( Window* parent );
00071 
00073         EQ_EXPORT virtual ~Channel();
00074 
00080         Window*       getWindow()       { return _window; }
00081 
00083         const Window* getWindow() const { return _window; }
00084 
00086         EQ_EXPORT Pipe*       getPipe();
00087 
00089         EQ_EXPORT const Pipe* getPipe() const;
00090 
00092         EQ_EXPORT Node*       getNode();
00093 
00095         EQ_EXPORT const Node* getNode() const;
00096 
00098         EQ_EXPORT Config*       getConfig();
00099 
00101         EQ_EXPORT const Config* getConfig() const;
00102 
00104         EQ_EXPORT ServerPtr getServer();
00105 
00107         const std::string& getName() const { return _name; }
00108 
00122         EQ_EXPORT GLEWContext*       glewGetContext();
00123 
00125         EQ_EXPORT const GLEWContext* glewGetContext() const;
00126 
00128         EQ_EXPORT Window::ObjectManager* getObjectManager();
00129 
00139         uint32_t getTasks() const { return _tasks; }
00140 
00147         EQ_EXPORT VisitorResult accept( ChannelVisitor& visitor );
00148 
00150         EQ_EXPORT VisitorResult accept( ChannelVisitor& visitor ) const;
00151 
00162         EQ_EXPORT void setNearFar( const float nearPlane, const float farPlane);
00163 
00165         const Vector3ub& getUniqueColor() const { return _color; }
00166 
00177         EQ_EXPORT const View* getNativeView() const;
00178 
00180         const PixelViewport& getNativePixelViewPort() const
00181             { return _nativeContext.pvp; }
00182 
00184         EQ_EXPORT util::FrameBufferObject* getFrameBufferObject();
00185 
00187         EQ_EXPORT void addStatistic( Event& event );
00189 
00201         EQ_EXPORT uint32_t getDrawBuffer() const;
00202 
00204         EQ_EXPORT uint32_t getReadBuffer() const;
00205 
00207         EQ_EXPORT const ColorMask& getDrawBufferMask() const;
00208 
00210         EQ_EXPORT const PixelViewport& getPixelViewport() const;
00211 
00213         EQ_EXPORT const Frustumf& getFrustum() const;
00214 
00216         EQ_EXPORT const Frustumf& getOrtho() const;
00217 
00219         EQ_EXPORT Vector2f getJitter() const;
00220 
00229         EQ_EXPORT const Matrix4f& getHeadTransform() const;
00230 
00232         EQ_EXPORT const Viewport& getViewport() const;
00233 
00235         EQ_EXPORT const Range& getRange() const;
00236 
00238         EQ_EXPORT const Pixel& getPixel() const;
00239 
00241         EQ_EXPORT const SubPixel& getSubPixel() const;
00242 
00244         EQ_EXPORT const Zoom& getZoom() const;
00245 
00250         EQ_EXPORT uint32_t getPeriod() const;
00251 
00256         EQ_EXPORT uint32_t getPhase() const;
00257 
00267         EQ_EXPORT const Vector2i& getPixelOffset() const;
00268 
00270         EQ_EXPORT Eye getEye() const;
00271 
00273         const FrameVector& getInputFrames() { return _inputFrames; }
00274 
00276         const FrameVector& getOutputFrames() { return _outputFrames; }
00277 
00290         EQ_EXPORT const View* getView() const;
00291 
00300         EQ_EXPORT Frustumf getScreenFrustum() const;
00301 
00303         EQ_EXPORT const Vector4i& getOverdraw() const;
00304 
00306         EQ_EXPORT void setMaxSize( const Vector2i& size );
00307 
00309         EQ_EXPORT uint32_t getTaskID() const;
00311 
00324         EQ_EXPORT virtual void applyBuffer();
00325 
00330         EQ_EXPORT virtual void applyColorMask() const;
00331 
00336         EQ_EXPORT virtual void applyViewport() const;
00337 
00349         EQ_EXPORT virtual void applyFrustum() const;
00350 
00358         EQ_EXPORT virtual void applyOrtho() const;
00359 
00366         EQ_EXPORT void applyScreenFrustum() const;
00367 
00372         EQ_EXPORT virtual void applyHeadTransform() const;
00373 
00377         EQ_EXPORT virtual void applyFrameBufferObject();
00378 
00382         EQ_EXPORT void bindFrameBuffer();        
00384 
00395         EQ_EXPORT virtual bool processEvent( const Event& event );
00396 
00398         EQ_EXPORT virtual void drawStatistics();
00399 
00401         EQ_EXPORT virtual void outlineViewport();
00402 
00407         // Note: also update string array initialization in channel.cpp
00409         enum IAttribute
00410         {
00412             IATTR_HINT_STATISTICS,
00414             IATTR_HINT_SENDTOKEN,
00415             IATTR_FILL1,
00416             IATTR_FILL2,
00417             IATTR_ALL
00418         };
00419         
00421         EQ_EXPORT int32_t getIAttribute( const IAttribute attr ) const;
00423         EQ_EXPORT static const std::string& getIAttributeString(
00424                                                         const IAttribute attr );
00426 
00427     protected:
00429         EQ_EXPORT void attachToSession( const uint32_t id, 
00430                                         const uint32_t instanceID, 
00431                                         net::Session* session );
00432 
00440         void startFrame( const uint32_t frameNumber ) { /* currently nop */ }
00441 
00447         void releaseFrame( const uint32_t frameNumber ) { /* currently nop */ }
00448 
00454         void releaseFrameLocal( const uint32_t frameNumber ) { /* nop */ }
00455 
00464         EQ_EXPORT virtual void setupAssemblyState();
00465 
00469         EQ_EXPORT virtual void resetAssemblyState();
00471 
00486         EQ_EXPORT virtual bool configInit( const uint32_t initID );
00487 
00489         EQ_EXPORT virtual bool configExit();
00490 
00501         virtual void frameStart( const uint32_t frameID, 
00502                                  const uint32_t frameNumber ) 
00503             { startFrame( frameNumber ); }
00504 
00514         virtual void frameFinish( const uint32_t frameID, 
00515                                   const uint32_t frameNumber ) 
00516             { releaseFrame( frameNumber ); }
00517 
00527         virtual void frameDrawFinish( const uint32_t frameID, 
00528                                       const uint32_t frameNumber )
00529             { releaseFrameLocal( frameNumber ); }
00530 
00538         EQ_EXPORT virtual void frameClear( const uint32_t frameID );
00539 
00547         EQ_EXPORT virtual void frameDraw( const uint32_t frameID );
00548 
00557         EQ_EXPORT virtual void frameAssemble( const uint32_t frameID );
00558 
00567         EQ_EXPORT virtual void frameReadback( const uint32_t frameID );
00568 
00578         virtual void frameViewStart( const uint32_t frameID ) { /* nop */ }
00579 
00592         virtual void frameViewFinish( const uint32_t frameID ) { /* nop */ }
00594 
00605         EQ_EXPORT void setErrorMessage( const std::string& message );
00607 
00608     private:
00609         //-------------------- Members --------------------
00611         Window* const _window;
00612         friend class Window;
00613 
00615         RenderContext _nativeContext;
00616 
00618         RenderContext* _context;
00619             
00621         std::string    _name;
00622         
00624         Vector3ub _color;
00625 
00627         std::string     _error;
00628 
00630         int32_t _iAttributes[IATTR_ALL];
00632         static std::string _iAttributeStrings[IATTR_ALL];
00633 
00635         uint32_t _tasks;
00636 
00637         enum State
00638         {
00639             STATE_STOPPED,
00640             STATE_INITIALIZING,
00641             STATE_RUNNING
00642         };
00643 
00645         State _state;
00646 
00648         FrameVector _outputFrames;
00649 
00651         FrameVector _inputFrames;
00652 
00654         bool _fixedPVP;
00655 
00657         util::FrameBufferObject* _fbo; 
00658         
00660         uint32_t _drawable;
00661         
00663         std::vector< Statistic > _statistics;
00664 
00666         Vector2i _initialSize;
00667 
00669         Vector2i _maxSize;
00670 
00671         union // placeholder for binary-compatible changes
00672         {
00673             char dummy[64];
00674         };
00675 
00676         //-------------------- Methods --------------------
00684         void _setViewport( const Viewport& vp );
00685 
00693         void _setPixelViewport( const PixelViewport& pvp );
00694 
00696         void _notifyViewportChanged();
00697 
00699         void _setRenderContext( RenderContext& context );
00700 
00702         bool _configInitFBO();
00703 
00704         virtual void getInstanceData( net::DataOStream& os ) { EQDONTCALL }
00705         virtual void applyInstanceData( net::DataIStream& is ) { EQDONTCALL }
00706 
00707         /* The command handler functions. */
00708         net::CommandResult _cmdConfigInit( net::Command& command );
00709         net::CommandResult _cmdConfigExit( net::Command& command );
00710         net::CommandResult _cmdFrameStart( net::Command& command );
00711         net::CommandResult _cmdFrameFinish( net::Command& command );
00712         net::CommandResult _cmdFrameClear( net::Command& command );
00713         net::CommandResult _cmdFrameDraw( net::Command& command );
00714         net::CommandResult _cmdFrameDrawFinish( net::Command& command );
00715         net::CommandResult _cmdFrameAssemble( net::Command& command );
00716         net::CommandResult _cmdFrameReadback( net::Command& command );
00717         net::CommandResult _cmdFrameTransmit( net::Command& command );
00718         net::CommandResult _cmdFrameViewStart( net::Command& command );
00719         net::CommandResult _cmdFrameViewFinish( net::Command& command );
00720     };
00721 }
00722 
00723 #endif // EQ_CHANNEL_H
00724 
Generated on Sat Feb 6 12:59:44 2010 for Equalizer 0.9.1 by  doxygen 1.6.1