예제 #1
0
        /// <summary>
        /// Tells the camera the current available space for displaying your game.  The camera will then build the largest rectangle that maintains a certain aspect ratio.
        /// Returns true iff the supplied display sizes are different from what was previously stored.
        /// </summary>
        public Boolean UpdateDisplayInformation(Int32 displayWidth, Int32 displayHeight)
        {
            Boolean displayChanged = false;

            if (m_currentFullDisplayHeight != displayHeight || m_currentFullDisplayWidth != displayWidth)
            {
                displayChanged             = true;
                m_currentFullDisplayWidth  = displayWidth;
                m_currentFullDisplayHeight = displayHeight;
                Position displayPosition = new Position(displayWidth / 2, displayHeight, displayWidth, displayHeight);

                Math2d.GetLargestRectangleThatFits(AspectRatio, displayPosition, out m_displayTargetPosition);

                // First, determine the scale factor from the logical viewport to the display viewport.
                // So if the display window is actually 8 times the size of the logical window, you'll have to scale everything by 8
                m_currentScale = m_displayTargetPosition.Width / m_logicalPosition.Width;
            }
            return(displayChanged);
        }