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     class ChannelVisitor;
00033     class Pixel;
00034     class Range;
00035     class SceneObject;
00036     class FrameBufferObject;
00037     struct RenderContext;
00038 
00046     class Channel : public net::Object
00047     {
00048     public:
00049     
00054         enum Drawable
00055         {
00056             FBO_NONE      = EQ_BIT_NONE,
00057             FBO_COLOR     = EQ_BIT1,  
00058             FBO_DEPTH     = EQ_BIT2,  
00059             FBO_STENCIL   = EQ_BIT3   
00060         };
00061         
00063         EQ_EXPORT Channel( Window* parent );
00064 
00066         EQ_EXPORT virtual ~Channel();
00067 
00072         Window*       getWindow()       { return _window; }
00073         const Window* getWindow() const { return _window; }
00074 
00075         EQ_EXPORT Pipe*       getPipe();
00076         EQ_EXPORT const Pipe* getPipe() const;
00077 
00078         EQ_EXPORT Node*       getNode();
00079         EQ_EXPORT const Node* getNode() const;
00080 
00081         EQ_EXPORT Config*       getConfig();
00082         EQ_EXPORT const Config* getConfig() const;
00083 
00084         EQ_EXPORT ServerPtr getServer();
00085 
00086         EQ_EXPORT Window::ObjectManager* getObjectManager();
00087 
00101         EQ_EXPORT GLEWContext*       glewGetContext();
00102         EQ_EXPORT const GLEWContext* glewGetContext() const;
00103         
00105         const std::string& getName() const { return _name; }
00106 
00115         uint32_t getTasks() const { return _tasks; }
00116 
00123         EQ_EXPORT VisitorResult accept( ChannelVisitor& visitor );
00124 
00136         EQ_EXPORT void setNearFar( const float nearPlane, const float farPlane);
00137 
00139         const Vector3ub& getUniqueColor() const { return _color; }
00140 
00152         EQ_EXPORT const View* getView();
00153 
00158         EQ_EXPORT const View* getNativeView();
00159 
00161         EQ_EXPORT void addStatistic( Event& event );
00163 
00173         EQ_EXPORT uint32_t getDrawBuffer() const;
00174 
00176         EQ_EXPORT uint32_t getReadBuffer() const;
00177 
00179         EQ_EXPORT const ColorMask& getDrawBufferMask() const;
00180 
00182         EQ_EXPORT const PixelViewport& getPixelViewport() const;
00183 
00193         EQ_EXPORT const Vector2i& getPixelOffset() const;
00194 
00196         EQ_EXPORT const Frustumf& getFrustum() const;
00197 
00199         EQ_EXPORT const Frustumf& getOrtho() const;
00200 
00202         EQ_EXPORT const Viewport& getViewport() const;
00203 
00205         EQ_EXPORT const Range& getRange() const;
00206 
00208         EQ_EXPORT const Pixel& getPixel() const;
00209 
00211         EQ_EXPORT const Zoom& getZoom() const;
00212 
00214         EQ_EXPORT Eye getEye() const;
00215 
00220         EQ_EXPORT const Matrix4f& getHeadTransform() const;
00221 
00223         const FrameVector& getInputFrames() { return _inputFrames; }
00224 
00226         const FrameVector& getOutputFrames() { return _outputFrames; }
00227 
00236         EQ_EXPORT Frustumf getScreenFrustum() const;
00237 
00241         const PixelViewport& getNativePixelViewPort() const
00242             { return _nativeContext.pvp; }
00243 
00245         EQ_EXPORT const Vector4i& getOverdraw() const;
00246 
00248         EQ_EXPORT void setMaxSize( const Vector2i& size );
00249 
00251         EQ_EXPORT uint32_t getTaskID() const;
00252 
00256         EQ_EXPORT FrameBufferObject* getFrameBufferObject();
00258 
00270         EQ_EXPORT virtual void applyBuffer();
00271 
00275         EQ_EXPORT virtual void applyColorMask() const;
00276 
00280         EQ_EXPORT virtual void applyViewport() const;
00281 
00285         EQ_EXPORT virtual void applyFrustum() const;
00286 
00290         EQ_EXPORT virtual void applyOrtho() const;
00291 
00298         EQ_EXPORT void applyScreenFrustum() const;
00299 
00304         EQ_EXPORT virtual void applyHeadTransform() const;
00305 
00309         EQ_EXPORT virtual void applyFrameBufferObject();
00310         
00321         EQ_EXPORT virtual bool processEvent( const Event& event );
00322 
00324         EQ_EXPORT virtual void drawStatistics();
00325 
00327         EQ_EXPORT virtual void outlineViewport();
00328 
00333         // Note: also update string array initialization in channel.cpp
00334         enum IAttribute
00335         {
00336             IATTR_HINT_STATISTICS,
00337             IATTR_HINT_SENDTOKEN,
00338             IATTR_FILL1,
00339             IATTR_FILL2,
00340             IATTR_ALL
00341         };
00342         
00343         EQ_EXPORT int32_t getIAttribute( const IAttribute attr ) const;
00344         EQ_EXPORT static const std::string& getIAttributeString(
00345                                                         const IAttribute attr );
00347 #if 0
00348 
00350         SceneObject* getNextSceneObject();
00351         SceneObject* checkNextSceneObject();
00352         //void putSceneObject( SceneObject* object );
00353         void passSceneObject( SceneObject* object );
00354         void flushSceneObjects();
00356 #endif
00357 
00358     protected:
00359         friend class Window;
00360 
00361         EQ_EXPORT void attachToSession( const uint32_t id, 
00362                                         const uint32_t instanceID, 
00363                                         net::Session* session );
00364 
00372         void startFrame( const uint32_t frameNumber ) { /* currently nop */ }
00373 
00379         void releaseFrame( const uint32_t frameNumber ) { /* currently nop */ }
00380 
00386         void releaseFrameLocal( const uint32_t frameNumber ) { /* nop */ }
00388 
00401         EQ_EXPORT virtual bool configInit( const uint32_t initID );
00402 
00406         EQ_EXPORT virtual bool configExit();
00407 
00411         EQ_EXPORT void bindFrameBuffer();
00412         
00423         virtual void frameStart( const uint32_t frameID, 
00424                                  const uint32_t frameNumber ) 
00425             { startFrame( frameNumber ); }
00426 
00436         virtual void frameFinish( const uint32_t frameID, 
00437                                   const uint32_t frameNumber ) 
00438             { releaseFrame( frameNumber ); }
00439 
00449         virtual void frameDrawFinish( const uint32_t frameID, 
00450                                       const uint32_t frameNumber )
00451             { releaseFrameLocal( frameNumber ); }
00452 
00458         EQ_EXPORT virtual void frameClear( const uint32_t frameID );
00459 
00465         EQ_EXPORT virtual void frameDraw( const uint32_t frameID );
00466 
00473         EQ_EXPORT virtual void frameAssemble( const uint32_t frameID );
00474 
00481         EQ_EXPORT virtual void frameReadback( const uint32_t frameID );
00482 
00491         virtual void frameViewStart( const uint32_t frameID ) { /* nop */ }
00492 
00501         virtual void frameViewFinish( const uint32_t frameID ) { /* nop */ }
00502 
00509         EQ_EXPORT virtual void setupAssemblyState();
00510 
00514         EQ_EXPORT virtual void resetAssemblyState();
00516 
00527         EQ_EXPORT void setErrorMessage( const std::string& message );
00529 
00530     private:
00531         //-------------------- Members --------------------
00533         Window* const _window;
00534 
00536         RenderContext _nativeContext;
00537 
00539         RenderContext* _context;
00540             
00542         std::string    _name;
00543         
00545         Vector3ub _color;
00546 
00548         std::string     _error;
00549 
00551         int32_t _iAttributes[IATTR_ALL];
00553         static std::string _iAttributeStrings[IATTR_ALL];
00554 
00556         uint32_t _tasks;
00557 
00558         enum State
00559         {
00560             STATE_STOPPED,
00561             STATE_INITIALIZING,
00562             STATE_RUNNING
00563         };
00564 
00566         State _state;
00567 
00569         FrameVector _outputFrames;
00570 
00572         FrameVector _inputFrames;
00573 
00575         bool _fixedPVP;
00576 
00578         FrameBufferObject* _fbo; 
00579         
00581         uint32_t _drawable;
00582         
00584         std::vector< Statistic > _statistics;
00585 
00587         Vector2i _initialSize;
00588 
00590         Vector2i _maxSize;
00591 
00592         union // placeholder for binary-compatible changes
00593         {
00594             char dummy[64];
00595         };
00596 
00598         bool _configInitFBO();
00599         
00600         //-------------------- Methods --------------------
00608         void _setViewport( const Viewport& vp );
00609 
00617         void _setPixelViewport( const PixelViewport& pvp );
00618 
00620         void _notifyViewportChanged();
00621 
00623         void _setRenderContext( RenderContext& context );
00624 
00625         virtual void getInstanceData( net::DataOStream& os ) { EQDONTCALL }
00626         virtual void applyInstanceData( net::DataIStream& is ) { EQDONTCALL }
00627 
00628         /* The command handler functions. */
00629         net::CommandResult _cmdConfigInit( net::Command& command );
00630         net::CommandResult _cmdConfigExit( net::Command& command );
00631         net::CommandResult _cmdFrameStart( net::Command& command );
00632         net::CommandResult _cmdFrameFinish( net::Command& command );
00633         net::CommandResult _cmdFrameClear( net::Command& command );
00634         net::CommandResult _cmdFrameDraw( net::Command& command );
00635         net::CommandResult _cmdFrameDrawFinish( net::Command& command );
00636         net::CommandResult _cmdFrameAssemble( net::Command& command );
00637         net::CommandResult _cmdFrameReadback( net::Command& command );
00638         net::CommandResult _cmdFrameTransmit( net::Command& command );
00639         net::CommandResult _cmdFrameViewStart( net::Command& command );
00640         net::CommandResult _cmdFrameViewFinish( net::Command& command );
00641     };
00642 }
00643 
00644 #endif // EQ_CHANNEL_H
00645 
Generated on Mon Aug 10 18:58:31 2009 for Equalizer 0.9 by  doxygen 1.5.8