コード例 #1
0
void CCCameraBase::setupViewport(float x, float y, float width, float height, const int frameBufferID)
{
    this->frameBufferID = frameBufferID;
    
    viewportX = x;
    viewportY = y;
    viewportX2 = x+width;
    viewportY2 = y+height;
    viewportWidth = width;
    viewportHeight = height;
    invViewportWidth = 1.0f / viewportWidth;
    invViewportHeight = 1.0f / viewportHeight;
    
    if( frameBufferID == -1 )
    {
        const CCTarget<float> &orientation = CCAppManager::GetOrientation();
        if( orientation.target == 270.0f )
        {
            CCSwapFloat( x, y );
            CCSwapFloat( width, height );
            x = 1.0f - width - x;
        }
        else if( orientation.target == 90.0f )
        {
            CCSwapFloat( x, y );
            CCSwapFloat( width, height );
            y = 1.0f - height - y;
        }
        else if( orientation.target == 180.0f )
        {
            x = 1.0f - width - x;
            y = 1.0f - height - y;
        }
        else
        {
        }
    }
    
    const float invY = ( 1.0f-height ) - y;
    
    const float frameBufferWidth = gEngine->renderer->frameBufferManager.getWidth( frameBufferID );
    const float frameBufferHeight = gEngine->renderer->frameBufferManager.getHeight( frameBufferID );
    const float definedWidth = width * frameBufferWidth;
    const float definedHeight = height * frameBufferHeight;
    viewport[0] = x * frameBufferWidth;
    viewport[1] = invY * frameBufferHeight;
    viewport[2] = definedWidth;
    viewport[3] = definedHeight;
    
    aspectRatio = definedWidth / definedHeight;
    
    setPerspective( perspective );
}
コード例 #2
0
void CCRenderer::correctOrientation(float &x, float &y)
{
    if( orientation.target == 270.0f )
    {
        CCSwapFloat( x, y );
        x = 1.0f - x;
        y = 1.0f - y;
    }
    else if( orientation.target == 90.0f )
    {
        CCSwapFloat( x, y );
    }
    else if( orientation.target == 180.0f )
    {
        x = 1.0f - x;
    }
    else
    {
        y = 1.0f - y;
    }
}