Equalizer  1.6.1
include/eq/fabric/channel.h
1 
2 /* Copyright (c) 2010-2013, Stefan Eilemann <eile@equalizergraphics.com>
3  * 2010, Cedric Stalder <cedric.stalder@gmail.com>
4  *
5  * This library is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU Lesser General Public License version 2.1 as published
7  * by the Free Software Foundation.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef EQFABRIC_CHANNEL_H
20 #define EQFABRIC_CHANNEL_H
21 
22 #include <eq/fabric/object.h> // base class
23 #include <eq/fabric/paths.h>
24 #include <eq/fabric/renderContext.h> // member
25 #include <eq/fabric/types.h>
26 
27 namespace eq
28 {
29 namespace fabric
30 {
32  template< class W, class C > class Channel : public Object
33  {
34  public:
36  typedef W Parent;
37 
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,
103  const float farPlane);
104 
109  uint32_t getDrawable() const { return _drawable; }
110 
118  EQFABRIC_INL VisitorResult accept( Visitor& visitor );
119 
121  EQFABRIC_INL VisitorResult accept( Visitor& visitor ) const;
122 
131  EQFABRIC_INL void setCapabilities( const uint64_t bitmask );
132 
134  EQFABRIC_INL uint64_t getCapabilities() const;
135 
137  EQFABRIC_INL void setMaxSize( const Vector2i& size );
138 
139  void setOverdraw( const Vector4i& overdraw );
140  const Vector2i& getMaxSize() const { return _maxSize; }
141 
143  EQFABRIC_INL ChannelPath getPath() const;
144 
145  EQFABRIC_INL virtual void backup();
146  EQFABRIC_INL virtual void restore();
147 
148 
160  uint32_t getDrawBuffer() const { return _context->buffer; }
161 
163  uint32_t getReadBuffer() const { return _context->buffer; }
164 
167  { return _context->bufferMask; }
168 
173  const PixelViewport& getPixelViewport() const { return _context->pvp; }
174 
183  virtual bool useOrtho() const { return false; }
184 
189  const Frustumf& getFrustum() const
190  { return useOrtho() ? getOrtho() : getPerspective(); }
191 
196  const Frustumf& getPerspective() const { return _context->frustum; }
197 
202  const Frustumf& getOrtho() const { return _context->ortho; }
203 
213  const Matrix4f& getHeadTransform() const
215 
226  { return _context->headTransform; }
227 
238  { return _context->orthoTransform; }
239 
244  const Viewport& getViewport() const { return _context->vp; }
245 
250  const Range& getRange() const { return _context->range; }
251 
256  const Pixel& getPixel() const { return _context->pixel; }
257 
262  const SubPixel& getSubPixel() const { return _context->subpixel; }
263 
268  const Zoom& getZoom() const { return _context->zoom; }
269 
274  uint32_t getPeriod() const { return _context->period; }
275 
280  uint32_t getPhase() const { return _context->phase; }
281 
292  const Vector2i& getPixelOffset() const { return _context->offset; }
293 
295  Eye getEye() const { return _context->eye; }
296 
298  const Vector4i& getOverdraw() const { return _context->overdraw; }
299 
301  uint32_t getTaskID() const { return _context->taskID; }
303 
306  // Note: also update string array initialization in channel.cpp
309  {
314  IATTR_LAST,
315  IATTR_ALL = IATTR_LAST + 5
316  };
317 
319  EQFABRIC_INL int32_t getIAttribute( const IAttribute attr ) const;
321  EQFABRIC_INL static const std::string& getIAttributeString(
322  const IAttribute attr );
324 
325  virtual bool omitOutput() const { return false; }
326  virtual void output( std::ostream& ) const {}
327 
328  protected:
330  EQFABRIC_INL Channel( W* parent );
331 
333  Channel( const Channel& from );
334 
336  EQFABRIC_INL virtual ~Channel();
337 
339  EQFABRIC_INL virtual void serialize( co::DataOStream& os,
340  const uint64_t dirtyBits );
342  EQFABRIC_INL virtual void deserialize( co::DataIStream& is,
343  const uint64_t dirtyBits );
344 
346  EQFABRIC_INL virtual void setDirty( const uint64_t bits );
347 
348  void setDrawable( const uint32_t drawable );
349 
353  void overrideContext( RenderContext& context ) { _context = &context; }
354 
356  void resetRenderContext() { _context = &_data.nativeContext; }
357 
359  const RenderContext& getContext() const { return *_context; }
360 
362  const RenderContext& getNativeContext() const
363  { return _data.nativeContext; }
365 
367  void setIAttribute( const IAttribute attr, const int32_t value )
368  { _iAttributes[attr] = value; setDirty( DIRTY_ATTRIBUTES ); }
369 
371  virtual ChangeType getChangeType() const { return UNBUFFERED; }
372 
373  enum DirtyBits
374  {
375  DIRTY_ATTRIBUTES = Object::DIRTY_CUSTOM << 0, // 64
376  DIRTY_VIEWPORT = Object::DIRTY_CUSTOM << 1, // 128
377  DIRTY_MEMBER = Object::DIRTY_CUSTOM << 2, // 256
378  DIRTY_FRUSTUM = Object::DIRTY_CUSTOM << 3, // 512
379  DIRTY_CAPABILITIES = Object::DIRTY_CUSTOM << 4, // 1024
380  DIRTY_CHANNEL_BITS =
381  DIRTY_ATTRIBUTES | DIRTY_VIEWPORT | DIRTY_MEMBER |
382  DIRTY_FRUSTUM | DIRTY_OBJECT_BITS
383  };
384 
386  virtual uint64_t getRedistributableBits() const
387  { return DIRTY_CHANNEL_BITS; }
388 
389  virtual void updateCapabilities() {};
390 
391  private:
393  W* const _window;
394 
395  struct BackupData
396  {
397  BackupData() : capabilities( LB_BIT_ALL_64 ), fixedVP( true ) {}
398 
400  RenderContext nativeContext;
401 
403  uint64_t capabilities;
404 
406  bool fixedVP;
407  }
408  _data, _backup;
409 
411  RenderContext* _context;
412 
414  int32_t _iAttributes[IATTR_ALL];
415 
417  uint32_t _drawable;
418 
420  Vector2i _maxSize;
421 
422  struct Private;
423  Private* _private; // placeholder for binary-compatible changes
424  };
425 
426  template< class W, class C > EQFABRIC_INL
427  std::ostream& operator << ( std::ostream&, const Channel< W, C >& );
428 }
429 }
430 
431 #endif // EQFABRIC_CHANNEL_H
Internal base class for all distributed, inheritable Equalizer objects.
Definition: object.h:39
IAttribute
Possible values for integer attributes.
Definition: iAttribute.h:30
virtual EQFABRIC_INL ~Channel()
Destruct the channel.
A fractional database range with methods for manipulation.
Definition: range.h:30
W Parent
The parent window type.
Eye eye
current eye pass
Definition: renderContext.h:66
Use an FBO for color values.
EQFABRIC_INL void setCapabilities(const uint64_t bitmask)
Set the capabilities supported by the channel.
Base data transport class for channels.
Viewport vp
fractional viewport wrt dest view
Definition: renderContext.h:55
LeafVisitor< C > Visitor
The channel visitor type.
Use an FBO for depth values.
EQFABRIC_INL void setMaxSize(const Vector2i &size)
const Viewport & getViewport() const
vmml::vector< 4, int > Vector4i
A four-component integer vector.
Definition: vmmlib.h:42
Vector2i offset
absolute position wrt dest channel
Definition: renderContext.h:57
const W * getWindow() const
Holds a pixel decomposition specification with methods for manipulation.
Definition: pixel.h:39
const Matrix4f & getOrthoTransform() const
Return the orthographic view matrix.
const Frustumf & getPerspective() const
SubPixel subpixel
subpixel decomposition wrt to dest
Definition: renderContext.h:59
const Vector2i & getPixelOffset() const
Get the channel&#39;s current position wrt the destination channel.
Range range
database-range wrt to dest channel
Definition: renderContext.h:58
Use the window&#39;s frame buffer.
Eye
Eye pass bit mask for which is enabled.
Definition: fabric/eye.h:32
Holds a subpixel decomposition specification along with some methods for manipulation.
Definition: subPixel.h:41
ColorMask bufferMask
color mask for anaglyph stereo
Definition: renderContext.h:69
uint32_t phase
DPlex phase.
Definition: renderContext.h:65
const Matrix4f & getHeadTransform() const
Return the view matrix.
Use a send token for output frames (OFF, ON)
const PixelViewport & getNativePixelViewport() const
const Range & getRange() const
uint32_t period
DPlex period.
Definition: renderContext.h:64
virtual bool useOrtho() const
Select perspective or orthographic rendering.
EQFABRIC_INL VisitorResult accept(Visitor &visitor)
Perform a depth-first traversal of this channel.
const Matrix4f & getPerspectiveTransform() const
Return the perspective view matrix.
const Zoom & getZoom() const
const ColorMask & getDrawBufferMask() const
const SubPixel & getSubPixel() const
EQFABRIC_INL uint64_t getCapabilities() const
Holds a 2D pixel viewport with methods for manipulation.
Definition: pixelViewport.h:34
IAttribute
Integer attributes for a channel.
vmml::matrix< 4, 4, float > Matrix4f
A 4x4 float matrix.
Definition: vmmlib.h:39
PixelViewport pvp
pixel viewport of channel wrt window
Definition: renderContext.h:52
Matrix4f headTransform
frustum transform for modelview
Definition: renderContext.h:47
Frustumf frustum
frustum for projection matrix
Definition: renderContext.h:44
EQFABRIC_INL void setNearFar(const float nearPlane, const float farPlane)
Set the near and far planes for this channel.
EQFABRIC_INL Channel(W *parent)
Construct a new channel.
Defines which parts of the color buffer are to be written.
Definition: colorMask.h:33
Pixel pixel
pixel decomposition wrt to dest
Definition: renderContext.h:53
A zoom specification with methods for manipulation.
Definition: zoom.h:34
Zoom zoom
up/downsampling wrt to dest
Definition: renderContext.h:60
const PixelViewport & getPixelViewport() const
static EQFABRIC_INL const std::string & getIAttributeString(const IAttribute attr)
vmml::frustum< float > Frustumf
A frustum definition.
Definition: vmmlib.h:50
Frustumf ortho
ortho frustum for projection matrix
Definition: renderContext.h:45
Matrix4f orthoTransform
orthographic frustum transform
Definition: renderContext.h:48
A fractional viewport with methods for manipulation.
Definition: viewport.h:36
A visitor to traverse leaf nodes of a graph.
Definition: leafVisitor.h:28
Drawable
The drawable format defines the components used as an alternate drawable for this channel...
const Frustumf & getFrustum() const
const Frustumf & getOrtho() const
const Vector4i & getOverdraw() const
const Pixel & getPixel() const
Statistics gathering mode (OFF, FASTEST [ON], NICEST)
EQFABRIC_INL int32_t getIAttribute(const IAttribute attr) const
uint32_t buffer
buffer as passed to glDrawBuffer()
Definition: renderContext.h:62
Use an FBO for stencil values.
vmml::vector< 2, int > Vector2i
A two-component integer vector.
Definition: vmmlib.h:40