viewport.cpp

00001 
00002 /* Copyright (c) 2008-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 #include "viewport.h"
00019 
00020 #include <eq/client/pixelViewport.h>
00021 
00022 EQ_EXPORT const eq::Viewport eq::Viewport::FULL;
00023 
00024 namespace eq
00025 {
00026 void Viewport::applyView( const Viewport& segmentVP, const Viewport& viewVP,
00027                       const PixelViewport& pvp, const Vector4i& overdraw )
00028 {
00029     // part of view covered by segment
00030     Viewport contribution( segmentVP );
00031     contribution.intersect( viewVP );
00032     contribution.transform( viewVP );
00033         
00034     // extend by overdraw percentage
00035     EQASSERT( pvp.hasArea( ));
00036 
00037     const float xDelta(( static_cast< float >( overdraw.x() + pvp.w ) /
00038                          static_cast< float >( pvp.w ) - 1.0f ) * 
00039                        contribution.w );
00040     contribution.x -= xDelta;
00041     contribution.w += (( static_cast< float >( overdraw.z() + pvp.w ) /
00042                          static_cast< float >( pvp.w ) - 1.0f ) * 
00043                        contribution.w ); 
00044     contribution.w += xDelta;
00045 
00046     const float yDelta(( static_cast< float >( overdraw.y() + pvp.h ) /
00047                          static_cast< float >( pvp.h ) - 1.0f ) *
00048                        contribution.h ); 
00049     contribution.y -= yDelta;
00050     contribution.h += (( static_cast< float >( overdraw.w() + pvp.h ) /
00051                          static_cast< float >( pvp.h ) - 1.0f ) *
00052                        contribution.h ); 
00053     contribution.h += yDelta;
00054     
00055     x = contribution.x + x * contribution.w;
00056     y = contribution.y + y * contribution.h;
00057     w *= contribution.w;
00058     h *= contribution.h;
00059 }
00060 
00061 
00062 }
Generated on Mon Aug 10 18:58:41 2009 for Equalizer 0.9 by  doxygen 1.5.8