18 #ifndef EQFABRIC_VIEWPORT_H
19 #define EQFABRIC_VIEWPORT_H
21 #include <eq/fabric/api.h>
22 #include <eq/fabric/types.h>
23 #include <lunchbox/debug.h>
33 std::ostream& operator << ( std::ostream& os,
const Viewport& vp );
42 Viewport() : x(0.0f), y(0.0f), w(1.0f), h(1.0f) {}
45 explicit Viewport(
const float x_,
const float y_,
46 const float w_,
const float h_ )
47 : x(x_), y(y_), w(w_), h(h_) {}
51 : x( from[0] ), y( from[1] ), w( from[2] ), h( from[3] ) {}
60 LBASSERTINFO(
isValid(), *
this);
61 LBASSERTINFO( rhs.
isValid(), rhs );
73 x = ( x - rhs.
x ) / rhs.
w;
74 y = ( y - rhs.
y ) / rhs.
h;
83 return ( x==rhs.
x && y==rhs.
y && w==rhs.
w && h==rhs.
h);
92 return ( x!=rhs.
x || y!=rhs.
y || w!=rhs.
w || h!=rhs.
h);
101 {
return ( x>=0.0f && y>=0.0f && w>=0.0f && h>=0.0f ); }
108 bool hasArea()
const {
return (w>0.0f && h>0.0f); }
140 const float sEx =
static_cast< float >( x +
w );
141 const float sEy =
static_cast< float >( y +
h );
142 const float dEx =
static_cast< float >( rhs.
x + rhs.
w );
143 const float dEy =
static_cast< float >( rhs.
y + rhs.
h );
145 x = LB_MAX( x, rhs.
x );
146 y = LB_MAX( y, rhs.
y );
147 w = LB_MIN( sEx, dEx ) -
x;
148 h = LB_MIN( sEy, dEy ) -
y;
156 x = LB_MIN( x, rhs.
x );
157 y = LB_MIN( y, rhs.
y );
189 inline std::ostream& operator << ( std::ostream& os,
const Viewport& vp )
191 os <<
"[ " << vp.
x <<
" " << vp.
y <<
" " << vp.
w <<
" " << vp.
h <<
" ]";
207 #endif // EQFABRIC_VIEWPORT_H
static const Viewport FULL
A full viewport.
Viewport(const float x_, const float y_, const float w_, const float h_)
Construct a fractional viewport with default values.
bool operator==(const Viewport &rhs) const
bool operator!=(const Viewport &rhs) const
Viewport getCoverage(const Viewport &with) const
Compute the coverage of another viewport on this viewport.
vmml::vector< 4, int > Vector4i
A four-component integer vector.
void invalidate()
Make the viewport invalid.
void unite(const Viewport &rhs)
Create the union of the two viewports.
void applyView(const Viewport &segmentVP, const Viewport &viewVP, const PixelViewport &pvp, const Vector4i &overdraw)
Apply the view coverage to this viewport.
Viewport(const Vector4f &from)
Construct a fractional viewport from a Vector4f.
void intersect(const Viewport &rhs)
Create the intersection of the two viewports.
Holds a 2D pixel viewport with methods for manipulation.
void transform(const Viewport &rhs)
Transform this viewport into the rhs viewport space.
Viewport()
Construct a full fractional viewport.
void apply(const Viewport &rhs)
Apply (accumulate) another viewport.
vmml::vector< 4, float > Vector4f
A four-component float vector.
A fractional viewport with methods for manipulation.