当前位置: 首页>>代码示例>>C++>>正文


C++ Viewport::GetSize方法代码示例

本文整理汇总了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 );
    }
开发者ID:allan-simon,项目名称:pharaoh-game-engine,代码行数:37,代码来源:PgeTileMapScene.cpp


注:本文中的Viewport::GetSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。