/// <summary>
        /// スワップチェーンが変更された時に呼び出される
        /// </summary>
        /// <param name="device"></param>
        /// <param name="swapChain"></param>
        /// <param name="desc">変更後のスワップチェーン情報</param>
        public override void OnSwapChainResized(SharpDX.Direct3D11.Device device, SwapChain swapChain, SwapChainDescription desc)
        {
            if (!m_isCreated)
            {
                return;
            }
            int mx = (int)(System.Math.Max(desc.ModeDescription.Width, desc.ModeDescription.Height));
            int r  = 2;

            while ((r *= 2) < mx)
            {
                ;
            }
            if (r != m_mainTxLenght)
            {
                m_mainTxLenght = r;

                //=====================================
                // テクスチャー作成
                if (m_hPrintSTx == null)
                {
                    MCPrintScreenTexture.Create(App, "PrintScreen", m_mainTxLenght, m_mainTxLenght, out m_hPrintSTx);
                    if (m_hPrintSTx is null)
                    {
                        throw new Exception("DEDefaultSprite  PrintScreen 作成失敗");
                    }
                }
                else
                {
                    m_hPrintSTx.ReSize2D(m_mainTxLenght, m_mainTxLenght);
                }

                //=====================================
                // カメラの作成
                if (m_hTxCamera == null)
                {
                    if (m_isConstCoordinate)
                    {
                        CreateViewTextureCamera("FixedCameraSprite");
                    }
                    else
                    {
                        SetCurrentBaseCamera(App.CameraMgr.Get4VCameraNo(0));
                    }
                }
                else
                {
                    MCTextureCamera hTmp = (MCTextureCamera)m_hTxCamera;
                    hTmp.SetTextureSize(m_mainTxLenght, m_mainTxLenght);
                }
            }

            // ビューポートの設定
            GetCurrentViewPort(out m_aVP);
        }
Beispiel #2
0
        /// <summary>
        /// スワップチェーンが変更された時に呼び出される
        /// </summary>
        /// <param name="device"></param>
        /// <param name="swapChain"></param>
        /// <param name="desc">変更後のスワップチェーン情報</param>
        public override void OnSwapChainResized(SharpDX.Direct3D11.Device device, SwapChain swapChain, SwapChainDescription desc)
        {
            if (!m_isCreated)
            {
                return;
            }
            int mx = (int)(System.Math.Max(desc.ModeDescription.Width, desc.ModeDescription.Height));
            int r  = 2;

            while ((r *= 2) < mx)
            {
                ;
            }
            if (r != m_mainTxLenght)
            {
                m_mainTxLenght = r;

                //=====================================
                // テクスチャー作成
                if (m_hTx == null)
                {
                    MCPrintScreenTexture.Create(App, "2d_mapchip", m_mainTxLenght, m_mainTxLenght, out m_hTx);
                }
                else
                {
                    m_hTx.ReSize2D(m_mainTxLenght, m_mainTxLenght);
                }
                RawViewportF[] v;
                GetCurrentViewPort(out v);
                if (m_drawSprite == null)
                {
                    m_sprite              = (MCSprite)m_spriteRegister.CreateSpriteFromTextureName("mapchip", 0, 0, m_mainTxLenght, m_mainTxLenght, 0, 0);
                    m_drawSprite          = m_spriteRegister.CreateDrawSprite(m_sprite);
                    m_drawSprite.Effect   = (int)DCRL.DEF_SPRITE;
                    m_drawSprite.Position = new MCVector3(
                        (float)System.Math.Ceiling((m_mainTxLenght - v[0].Width) * -0.5f),
                        (float)System.Math.Ceiling((m_mainTxLenght - v[0].Height) * 0.5f), 0
                        );
                }
                else
                {
                    MCRect rc = new MCRect();
                    rc.SetXYWH(0, 0, m_mainTxLenght, m_mainTxLenght);
                    m_sprite.ResetRect(rc);

                    m_drawSprite.Position = new MCVector3(
                        (float)System.Math.Ceiling((m_mainTxLenght - v[0].Width) * -0.5f),
                        (float)System.Math.Ceiling((m_mainTxLenght - v[0].Height) * 0.5f), 0
                        );
                }

                //=====================================
                // カメラの作成
                if (m_hTxCamera == null)
                {
                    CreateViewTextureCamera("MpachipCamera");
                }
                else
                {
                    MCTextureCamera hTmp = (MCTextureCamera)m_hTxCamera;
                    hTmp.SetTextureSize(m_mainTxLenght, m_mainTxLenght);
                }
            }

            // ビューポートの設定
            GetCurrentViewPort(out m_aVP);
        }