Equalizer
1.2.1
|
00001 00002 /* Copyright (c) 2010-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 EQFABRIC_CHANNEL_H 00020 #define EQFABRIC_CHANNEL_H 00021 00022 #include <eq/fabric/object.h> // base class 00023 #include <eq/fabric/paths.h> 00024 #include <eq/fabric/renderContext.h> // member 00025 #include <eq/fabric/types.h> 00026 #include <eq/fabric/visitorResult.h> // enum 00027 00028 namespace eq 00029 { 00030 namespace fabric 00031 { 00033 template< class W, class C > class Channel : public Object 00034 { 00035 public: 00036 typedef LeafVisitor< C > Visitor; 00037 typedef W Parent; 00038 00046 enum Drawable 00047 { 00048 FB_WINDOW = EQ_BIT_NONE, 00049 FBO_COLOR = EQ_BIT1, 00050 FBO_DEPTH = EQ_BIT2, 00051 FBO_STENCIL = EQ_BIT3 00052 }; 00053 00057 void init(); 00058 00060 W* getWindow() { return _window; } 00061 00063 const W* getWindow() const { return _window; } 00064 00066 bool isDestination() const 00067 { return _data.nativeContext.view.identifier!=co::base::UUID::ZERO;} 00068 00070 void setViewVersion( const co::ObjectVersion& view ); 00071 00073 const co::ObjectVersion& getViewVersion() const 00074 { return _data.nativeContext.view; } 00075 00077 void setPixelViewport( const PixelViewport& pvp ); 00078 00080 EQFABRIC_INL void setViewport( const Viewport& vp ); 00081 00083 virtual void notifyViewportChanged(); 00084 00086 const PixelViewport& getNativePixelViewport() const 00087 { return _data.nativeContext.pvp; } 00088 00090 bool hasFixedViewport() const { return _data.fixedVP; } 00091 00103 EQFABRIC_INL void setNearFar( const float nearPlane, 00104 const float farPlane); 00105 00110 uint32_t getDrawable() const { return _drawable; } 00111 00119 EQFABRIC_INL VisitorResult accept( Visitor& visitor ); 00120 00122 EQFABRIC_INL VisitorResult accept( Visitor& visitor ) const; 00123 00132 EQFABRIC_INL void setCapabilities( const uint64_t bitmask ); 00133 00135 EQFABRIC_INL uint64_t getCapabilities() const; 00136 00138 EQFABRIC_INL void setMaxSize( const Vector2i& size ); 00139 00140 void setOverdraw( const Vector4i& overdraw ); 00141 const Vector2i& getMaxSize() const { return _maxSize; } 00142 00144 EQFABRIC_INL ChannelPath getPath() const; 00145 00146 EQFABRIC_INL virtual void backup(); 00147 EQFABRIC_INL virtual void restore(); 00148 00149 00161 uint32_t getDrawBuffer() const { return _context->buffer; } 00162 00164 uint32_t getReadBuffer() const { return _context->buffer; } 00165 00167 const ColorMask& getDrawBufferMask() const 00168 { return _context->bufferMask; } 00169 00174 const PixelViewport& getPixelViewport() const { return _context->pvp; } 00175 00184 virtual bool useOrtho() const { return false; } 00185 00190 const Frustumf& getFrustum() const 00191 { return useOrtho() ? getOrtho() : getPerspective(); } 00192 00197 const Frustumf& getPerspective() const { return _context->frustum; } 00198 00203 const Frustumf& getOrtho() const { return _context->ortho; } 00204 00214 const Matrix4f& getHeadTransform() const 00215 { return useOrtho() ? getOrthoTransform() : getPerspectiveTransform(); } 00216 00226 const Matrix4f& getPerspectiveTransform() const 00227 { return _context->headTransform; } 00228 00238 const Matrix4f& getOrthoTransform() const 00239 { return _context->orthoTransform; } 00240 00245 const Viewport& getViewport() const { return _context->vp; } 00246 00251 const Range& getRange() const { return _context->range; } 00252 00257 const Pixel& getPixel() const { return _context->pixel; } 00258 00263 const SubPixel& getSubPixel() const { return _context->subpixel; } 00264 00269 const Zoom& getZoom() const { return _context->zoom; } 00270 00275 uint32_t getPeriod() const { return _context->period; } 00276 00281 uint32_t getPhase() const { return _context->phase; } 00282 00293 const Vector2i& getPixelOffset() const { return _context->offset; } 00294 00296 Eye getEye() const { return _context->eye; } 00297 00299 const Vector4i& getOverdraw() const { return _context->overdraw; } 00300 00302 uint32_t getTaskID() const { return _context->taskID; } 00304 00307 // Note: also update string array initialization in channel.cpp 00309 enum IAttribute 00310 { 00312 IATTR_HINT_STATISTICS, 00314 IATTR_HINT_SENDTOKEN, 00315 IATTR_LAST, 00316 IATTR_ALL = IATTR_LAST + 5 00317 }; 00318 00320 EQFABRIC_INL int32_t getIAttribute( const IAttribute attr ) const; 00322 EQFABRIC_INL static const std::string& getIAttributeString( 00323 const IAttribute attr ); 00325 00326 virtual bool omitOutput() const { return false; } 00327 virtual void output( std::ostream& ) const {} 00328 00329 protected: 00331 EQFABRIC_INL Channel( W* parent ); 00332 00334 Channel( const Channel& from ); 00335 00337 EQFABRIC_INL virtual ~Channel(); 00338 00340 EQFABRIC_INL virtual void serialize( co::DataOStream& os, 00341 const uint64_t dirtyBits ); 00343 EQFABRIC_INL virtual void deserialize( co::DataIStream& is, 00344 const uint64_t dirtyBits ); 00345 00347 EQFABRIC_INL virtual void setDirty( const uint64_t bits ); 00348 00349 void setDrawable( const uint32_t drawable ); 00350 00354 void overrideContext( RenderContext& context ) { _context = &context; } 00355 00357 void resetRenderContext() { _context = &_data.nativeContext; } 00358 00360 const RenderContext& getContext() const { return *_context; } 00361 00363 const RenderContext& getNativeContext() const 00364 { return _data.nativeContext; } 00366 00368 void setIAttribute( const IAttribute attr, const int32_t value ) 00369 { _iAttributes[attr] = value; setDirty( DIRTY_ATTRIBUTES ); } 00370 00372 virtual ChangeType getChangeType() const { return UNBUFFERED; } 00373 00374 enum DirtyBits 00375 { 00376 DIRTY_ATTRIBUTES = Object::DIRTY_CUSTOM << 0, // 64 00377 DIRTY_VIEWPORT = Object::DIRTY_CUSTOM << 1, // 128 00378 DIRTY_MEMBER = Object::DIRTY_CUSTOM << 2, // 256 00379 DIRTY_FRUSTUM = Object::DIRTY_CUSTOM << 3, // 512 00380 DIRTY_CAPABILITIES = Object::DIRTY_CUSTOM << 4, // 1024 00381 DIRTY_CHANNEL_BITS = 00382 DIRTY_ATTRIBUTES | DIRTY_VIEWPORT | DIRTY_MEMBER | 00383 DIRTY_FRUSTUM | DIRTY_OBJECT_BITS 00384 }; 00385 00387 virtual uint64_t getRedistributableBits() const 00388 { return DIRTY_CHANNEL_BITS; } 00389 00390 virtual void updateCapabilities() {}; 00391 00392 private: 00394 W* const _window; 00395 00396 struct BackupData 00397 { 00398 BackupData() : capabilities( EQ_BIT_ALL_64 ), fixedVP( true ) {} 00399 00401 RenderContext nativeContext; 00402 00404 uint64_t capabilities; 00405 00407 bool fixedVP; 00408 } 00409 _data, _backup; 00410 00412 RenderContext* _context; 00413 00415 int32_t _iAttributes[IATTR_ALL]; 00416 00418 uint32_t _drawable; 00419 00421 Vector2i _maxSize; 00422 00423 struct Private; 00424 Private* _private; // placeholder for binary-compatible changes 00425 }; 00426 00427 template< class W, class C > EQFABRIC_INL 00428 std::ostream& operator << ( std::ostream&, const Channel< W, C >& ); 00429 } 00430 } 00431 00432 #endif // EQFABRIC_CHANNEL_H 00433