本文整理汇总了C++中Viewport::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Viewport::GetSize方法的具体用法?C++ Viewport::GetSize怎么用?C++ Viewport::GetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Viewport
的用法示例。
在下文中一共展示了Viewport::GetSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
//Render
void TileMapScene::Render( Point2Df& offset, const Viewport& viewport )
{
// If there is no map set, we can either assert, or we can ignore this
// and pretend the developer had other plans. We'll give the developer
// the benefit of the doubt, and just return from this method without
// doing anything...
if ( mPrimaryTileSet == 0 )
return;
glEnable( GL_TEXTURE_2D );
// Go over the tile maps and calculate their offsets, then render the map.
TileSetMultiSet::const_iterator mapIter = mTileSets.begin();
Point2D viewSize = viewport.GetSize();
Point2D primaryMapSize = mPrimaryTileSet->GetMapSize();
offset.x = Math::Clamp( offset.x, viewSize.x - primaryMapSize.x, 0 );
offset.y = Math::Clamp( offset.y, viewSize.y - primaryMapSize.y, 0 );
for ( mapIter; mapIter != mTileSets.end(); mapIter++ )
{
// Calculate the ratio between the current map and the primary map
Point2D curMapSize = mapIter->GetMapSize();
Real ratioX = 1.0, ratioY = 1.0;
if ( curMapSize.x != viewSize.x && primaryMapSize.x != viewSize.x )
ratioX = ( primaryMapSize.x - viewSize.x ) / Real( curMapSize.x - viewSize.x );
if ( curMapSize.y != viewSize.y && primaryMapSize.y != viewSize.y )
ratioY = ( primaryMapSize.y - viewSize.y ) / Real( curMapSize.y - viewSize.y );
// Calculate the offset of the current map using the offset for the
// primary map and the ratios
Point2Df curOffset( offset.x / ratioX, offset.y / ratioY );
curOffset.y = Math::Clamp( curOffset.y, viewSize.y - curMapSize.y, 0 );
mapIter->Render( curOffset, viewport );
}
glDisable( GL_TEXTURE_2D );
}