Equalizer  1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
fabric/channel.h
1 
2 /* Copyright (c) 2010-2013, Stefan Eilemann <eile@equalizergraphics.com>
3  * 2010, Cedric Stalder <cedric.stalder@gmail.com>
4  * 2013, Julio Delgado Mangas <julio.delgadomangas@epfl.ch>
5  *
6  * This library is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License version 2.1 as published
8  * by the Free Software Foundation.
9  *
10  * This library is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef EQFABRIC_CHANNEL_H
21 #define EQFABRIC_CHANNEL_H
22 
23 #include <eq/fabric/object.h> // base class
24 #include <eq/fabric/paths.h>
25 #include <eq/fabric/renderContext.h> // member
26 #include <eq/fabric/types.h>
27 
28 namespace eq
29 {
30 namespace fabric
31 {
33 template< class W, class C > class Channel : public Object
34 {
35 public:
37  typedef W Parent;
38 
45  enum Drawable
46  {
47  FB_WINDOW = LB_BIT_NONE,
48  FBO_COLOR = LB_BIT1,
49  FBO_DEPTH = LB_BIT2,
50  FBO_STENCIL = LB_BIT3
51  };
52 
56  void init();
57 
59  W* getWindow() { return _window; }
60 
62  const W* getWindow() const { return _window; }
63 
65  bool isDestination() const
66  { return _data.nativeContext.view.identifier != 0;}
67 
69  void setViewVersion( const co::ObjectVersion& view );
70 
72  const co::ObjectVersion& getViewVersion() const
73  { return _data.nativeContext.view; }
74 
76  void setPixelViewport( const PixelViewport& pvp );
77 
79  EQFABRIC_INL void setViewport( const Viewport& vp );
80 
82  virtual void notifyViewportChanged();
83 
86  { return _data.nativeContext.pvp; }
87 
89  bool hasFixedViewport() const { return _data.fixedVP; }
90 
102  EQFABRIC_INL void setNearFar( const float nearPlane, const float farPlane );
103 
108  uint32_t getDrawable() const { return _drawable; }
109 
117  EQFABRIC_INL VisitorResult accept( Visitor& visitor );
118 
120  EQFABRIC_INL VisitorResult accept( Visitor& visitor ) const;
121 
130  EQFABRIC_INL void setCapabilities( const uint64_t bitmask );
131 
133  EQFABRIC_INL uint64_t getCapabilities() const;
134 
136  EQFABRIC_INL void setMaxSize( const Vector2i& size );
137 
138  void setOverdraw( const Vector4i& overdraw );
139  const Vector2i& getMaxSize() const { return _maxSize; }
140 
142  EQFABRIC_INL ChannelPath getPath() const;
143 
144  EQFABRIC_INL virtual void backup();
145  EQFABRIC_INL virtual void restore();
146 
147 
159  uint32_t getDrawBuffer() const { return _context->buffer; }
160 
162  uint32_t getReadBuffer() const { return _context->buffer; }
163 
166  { return _context->bufferMask; }
167 
172  const PixelViewport& getPixelViewport() const { return _context->pvp; }
173 
182  virtual bool useOrtho() const { return false; }
183 
188  const Frustumf& getFrustum() const
189  { return useOrtho() ? getOrtho() : getPerspective(); }
190 
195  const Frustumf& getPerspective() const { return _context->frustum; }
196 
201  const Frustumf& getOrtho() const { return _context->ortho; }
202 
212  const Matrix4f& getHeadTransform() const
214 
225  { return _context->headTransform; }
226 
237  { return _context->orthoTransform; }
238 
243  const Viewport& getViewport() const { return _context->vp; }
244 
249  const Range& getRange() const { return _context->range; }
250 
255  const Pixel& getPixel() const { return _context->pixel; }
256 
261  const SubPixel& getSubPixel() const { return _context->subpixel; }
262 
267  const Zoom& getZoom() const { return _context->zoom; }
268 
273  uint32_t getPeriod() const { return _context->period; }
274 
279  uint32_t getPhase() const { return _context->phase; }
280 
291  const Vector2i& getPixelOffset() const { return _context->offset; }
292 
294  Eye getEye() const { return _context->eye; }
295 
297  const Vector4i& getOverdraw() const { return _context->overdraw; }
298 
300  uint32_t getTaskID() const { return _context->taskID; }
302 
305  // Note: also update string array initialization in channel.cpp
308  {
313  IATTR_LAST,
314  IATTR_ALL = IATTR_LAST + 5
315  };
316 
319  {
320  SATTR_DUMP_IMAGE,
321  SATTR_LAST,
322  SATTR_ALL = SATTR_LAST + 5
323  };
324 
326  EQFABRIC_INL int32_t getIAttribute( const IAttribute attr ) const;
327 
329  EQFABRIC_INL std::string getSAttribute( const SAttribute attr ) const;
330 
332  EQFABRIC_INL static const std::string& getIAttributeString(
333  const IAttribute attr );
334 
336  EQFABRIC_INL static const std::string& getSAttributeString(
337  const SAttribute attr );
339 
340  virtual bool omitOutput() const { return false; }
341  virtual void output( std::ostream& ) const {}
342 
343 protected:
345  EQFABRIC_INL Channel( W* parent );
346 
348  Channel( const Channel& from );
349 
351  EQFABRIC_INL virtual ~Channel();
352 
354  EQFABRIC_INL virtual void serialize( co::DataOStream& os,
355  const uint64_t dirtyBits );
357  EQFABRIC_INL virtual void deserialize( co::DataIStream& is,
358  const uint64_t dirtyBits );
359 
361  EQFABRIC_INL virtual void setDirty( const uint64_t bits );
362 
363  void setDrawable( const uint32_t drawable );
364 
368  void overrideContext( RenderContext& context ) { _context = &context; }
369 
371  void resetContext() { _context = &_data.nativeContext; }
372 
374  const RenderContext& getContext() const { return *_context; }
375 
377  const RenderContext& getNativeContext() const
378  { return _data.nativeContext; }
380 
382  void setIAttribute( const IAttribute attr, const int32_t value )
383  { _iAttributes[attr] = value; setDirty( DIRTY_ATTRIBUTES ); }
384 
386  void setSAttribute( const SAttribute attr, const std::string& value )
387  { _sAttributes[attr] = value; setDirty( DIRTY_ATTRIBUTES ); }
388 
390  virtual ChangeType getChangeType() const { return UNBUFFERED; }
391 
392  enum DirtyBits
393  {
394  DIRTY_ATTRIBUTES = Object::DIRTY_CUSTOM << 0, // 64
395  DIRTY_VIEWPORT = Object::DIRTY_CUSTOM << 1, // 128
396  DIRTY_MEMBER = Object::DIRTY_CUSTOM << 2, // 256
397  DIRTY_FRUSTUM = Object::DIRTY_CUSTOM << 3, // 512
398  DIRTY_CAPABILITIES = Object::DIRTY_CUSTOM << 4, // 1024
399  DIRTY_CHANNEL_BITS =
400  DIRTY_ATTRIBUTES | DIRTY_VIEWPORT | DIRTY_MEMBER |
401  DIRTY_FRUSTUM | DIRTY_OBJECT_BITS
402  };
403 
405  virtual uint64_t getRedistributableBits() const
406  { return DIRTY_CHANNEL_BITS; }
407 
408  virtual void updateCapabilities() {}
409 
410 private:
412  W* const _window;
413 
414  struct BackupData
415  {
416  BackupData() : capabilities( LB_BIT_ALL_64 ), fixedVP( true ) {}
417 
419  RenderContext nativeContext;
420 
422  uint64_t capabilities;
423 
425  bool fixedVP;
426  }
427  _data, _backup;
428 
430  RenderContext* _context;
431 
433  int32_t _iAttributes[IATTR_ALL];
434 
436  std::string _sAttributes[SATTR_ALL];
437 
439  uint32_t _drawable;
440 
442  Vector2i _maxSize;
443 
444  struct Private;
445  Private* _private; // placeholder for binary-compatible changes
446 };
447 
448 template< class W, class C > EQFABRIC_INL
449 std::ostream& operator << ( std::ostream&, const Channel< W, C >& );
450 }
451 }
452 
453 #endif // EQFABRIC_CHANNEL_H
uint32_t buffer
buffer as passed to glDrawBuffer()
Definition: renderContext.h:62
const PixelViewport & getPixelViewport() const
A zoom specification with methods for manipulation.
Definition: zoom.h:34
uint32_t getDrawable() const
Use an FBO for depth values.
IAttribute
Possible values for integer attributes.
Definition: iAttribute.h:30
Use an FBO for stencil values.
EQFABRIC_INL uint64_t getCapabilities() const
Zoom zoom
up/downsampling wrt to dest
Definition: renderContext.h:60
const Frustumf & getPerspective() const
uint32_t getPhase() const
static EQFABRIC_INL const std::string & getSAttributeString(const SAttribute attr)
A fractional viewport with methods for manipulation.
Definition: viewport.h:34
Holds a subpixel decomposition specification along with some methods for manipulation.
Definition: subPixel.h:42
Defines which parts of the color buffer are to be written.
Definition: colorMask.h:34
const PixelViewport & getNativePixelViewport() const
Range range
database-range wrt to dest channel
Definition: renderContext.h:58
uint32_t getReadBuffer() const
bool hasFixedViewport() const
Viewport vp
fractional viewport wrt dest view
Definition: renderContext.h:55
static EQFABRIC_INL const std::string & getIAttributeString(const IAttribute attr)
IAttribute
Integer attributes for a channel.
Drawable
The drawable format defines the components used as an alternate drawable for this channel...
A visitor to traverse leaf nodes of a graph.
Definition: admin/types.h:32
const ColorMask & getDrawBufferMask() const
Pixel pixel
pixel decomposition wrt to dest
Definition: renderContext.h:53
W Parent
The parent window type.
uint32_t period
DPlex period.
Definition: renderContext.h:64
uint32_t getTaskID() const
vmml::vector< 4, int > Vector4i
A four-component integer vector.
Definition: vmmlib.h:44
EQFABRIC_INL void setNearFar(const float nearPlane, const float farPlane)
Set the near and far planes for this channel.
SubPixel subpixel
subpixel decomposition wrt to dest
Definition: renderContext.h:59
const SubPixel & getSubPixel() const
const Vector2i & getPixelOffset() const
Get the channel's current position wrt the destination channel.
EQFABRIC_INL void setMaxSize(const Vector2i &size)
Eye
Eye pass bit mask for which is enabled.
Definition: fabric/eye.h:33
ColorMask bufferMask
color mask for anaglyph stereo
Definition: renderContext.h:69
uint32_t phase
DPlex phase.
Definition: renderContext.h:65
virtual bool useOrtho() const
Select perspective or orthographic rendering.
Use a send token for output frames (OFF, ON)
EQFABRIC_INL int32_t getIAttribute(const IAttribute attr) const
uint32_t getPeriod() const
Matrix4f orthoTransform
orthographic frustum transform
Definition: renderContext.h:48
const Viewport & getViewport() const
Holds a pixel decomposition specification with methods for manipulation.
Definition: pixel.h:40
const W * getWindow() const
vmml::matrix< 4, 4, float > Matrix4f
A 4x4 float matrix.
Definition: vmmlib.h:41
const Vector4i & getOverdraw() const
Matrix4f headTransform
frustum transform for modelview
Definition: renderContext.h:47
const Matrix4f & getOrthoTransform() const
Return the orthographic view matrix.
Use the window's frame buffer.
LeafVisitor< C > Visitor
The channel visitor type.
EQFABRIC_INL Channel(W *parent)
Construct a new channel.
Use an FBO for color values.
const Zoom & getZoom() const
Eye eye
current eye pass
Definition: renderContext.h:66
Vector2i offset
absolute position wrt dest channel
Definition: renderContext.h:57
Frustumf ortho
ortho frustum for projection matrix
Definition: renderContext.h:45
const Range & getRange() const
const Matrix4f & getHeadTransform() const
Return the view matrix.
const Frustumf & getFrustum() const
Base data transport class for channels.
uint32_t getDrawBuffer() const
vmml::frustum< float > Frustumf
A frustum definition.
Definition: vmmlib.h:52
PixelViewport pvp
pixel viewport of channel wrt window
Definition: renderContext.h:52
const Pixel & getPixel() const
Statistics gathering mode (OFF, FASTEST [ON], NICEST)
virtual EQFABRIC_INL ~Channel()
Destruct the channel.
Internal base class for all distributed, inheritable Equalizer objects.
Definition: object.h:41
EQFABRIC_INL void setCapabilities(const uint64_t bitmask)
Set the capabilities supported by the channel.
Holds a 2D pixel viewport with methods for manipulation.
Definition: pixelViewport.h:34
A fractional database range with methods for manipulation.
Definition: range.h:30
EQFABRIC_INL std::string getSAttribute(const SAttribute attr) const
const Frustumf & getOrtho() const
const Matrix4f & getPerspectiveTransform() const
Return the perspective view matrix.
vmml::vector< 2, int > Vector2i
A two-component integer vector.
Definition: vmmlib.h:42
Frustumf frustum
frustum for projection matrix
Definition: renderContext.h:44
EQFABRIC_INL VisitorResult accept(Visitor &visitor)
Perform a depth-first traversal of this channel.