Esempio n. 1
0
 internal void OnDestroyDevice()
 {
     if (m_drawingEffectGroup != null)
     {
         m_drawingEffectGroup.OnDestroyDevice();
     }
     m_drawingEffectGroup.OnEndDevice();
     m_drawingEffectGroup = null;
 }
Esempio n. 2
0
        public int SetDrawingEffectGroup(IDrawingEffectGroup spDERL)
        {
            if (spDERL == null)
            {
                return(-1);
            }

            if (m_drawingEffectGroup != null)
            {
                throw new Exception("'m_spDERLib'既に登録済みです。");
            }
            m_drawingEffectGroup = spDERL;

            return(0);
        }
Esempio n. 3
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="commandBufferMax"></param>
        /// <param name="threadNum"></param>
        public MCBatchDrawingMgr(Application app, int commandBufferMax = 10000, int threadNum = 1)
        {
            App         = app;
            m_numberMgr = new MCNumberMgr(32767);

            // 描画コマンド
            m_DCommandRunNum    = 0;
            m_DCRegNum          = 0;
            m_commandBufferMax  = commandBufferMax;
            m_aDrawCommand      = new MCDrawBase[commandBufferMax];
            m_aDrawComandTarget = new MCDrawBase[commandBufferMax];
            m_aDCTmp00          = new MCDrawBase[commandBufferMax];

            //----
            m_threadNum = threadNum;

            //
            m_drawingEffectGroup = null;

            m_isAllDrawing = false;
        }
        /// <summary>
        /// デバイスの作成
        /// </summary>
        private void CrateDevice()
        {
            // デバイスコールバック内からこれを呼び出すことはできません
            if (DXState.InsideDeviceCallback)
            {
                throw new Exception("CreateDevice 既に作成済み");
            }

            DXState.DeviceObjectsCreated = true;

            if (IsCreate)
            {
                return;
            }
            DesignModeTitle = "デザインモード";

            SharpDX.Direct3D11.Device device;
            SwapChain swapChain;

            m_app.SetSwapChainDesc(new SwapChainDescription()
            {
                BufferCount       = 2,
                ModeDescription   = new ModeDescription(Width, Height, new Rational(60, 0), Format.R8G8B8A8_UNorm),
                IsWindowed        = true,
                OutputHandle      = Handle,
                SampleDescription = new SampleDescription(1, 0),
                SwapEffect        = SwapEffect.Discard,
                Usage             = Usage.RenderTargetOutput
            });
            // デバイスとスワップチェーンの作成
            SharpDX.Direct3D11.Device.CreateWithSwapChain(
                DriverType.Hardware,
                DeviceCreationFlags.BgraSupport,
                //DeviceCreationFlags.None,
                new[] { SharpDX.Direct3D.FeatureLevel.Level_11_0 },
                m_app.SwapChainDesc,
                out device,
                out swapChain
                );
            //SharpDX.Direct3D11.Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, m_app.SwapChainDesc, out device, out swapChain);

            // すべてのWindowsイベントを無視する
            m_app.SetFactory(swapChain.GetParent <SharpDX.DXGI.Factory>());
            m_app.Factory.MakeWindowAssociation(Handle, WindowAssociationFlags.IgnoreAll);

            m_app.SetDXDevice(device);
            m_app.SetImmediateContext(m_app.DXDevice.ImmediateContext);
            m_app.SetSwapChain(swapChain);

            ResizeDXGIBuffers(Width, Height);

            #region 管理の作成 & 初期化
            /////////////////////////////////////////////////////
            // イメージ
            m_app.SetImageMgr(new MCImageMgr(m_app));
            // ブレンドステート
            m_app.SetBlendStateMgr(new MCBlendStateMgr(m_app));
            // レイアウト
            m_app.SetLayoutMgr(new MCInputLayoutMgr(m_app));
            // メッシュ
            m_app.SetMeshMgr(new MCMeshMgr(m_app));
            // HLSL
            m_app.SetHLSLMgr(new DXHLSLMgr(m_app));
            // スプライト
            m_app.SetSpriteMgr(new MCSpriteMgr(m_app));
            // エフェクト
            m_app.SetBatchDrawingMgr(new MCBatchDrawingMgr(m_app));
            // カメラ
            m_app.SetCameraMgr(new MCCameraMgr(m_app));
            // ASCII
            m_app.SetAsciiStringDraw(new AsciiStringDraw(m_app));

            App = m_app;
            //---------------------------------------------------------------------
            IDrawingEffectGroup deg = null;
            if (EffectGroupID == DefaultDrawingEffectGroup.DrawingEffectGroupID)
            {
                deg = new DefaultDrawingEffectGroup(m_app);
                m_app.AsciiText.DefaultEffectID = (int)DrawingCommand.Default.DCRL.CONST_SPRITE;
            }
            if (EffectGroupID == SimpleDrawingEffectGroup.DrawingEffectGroupID)
            {
                deg = new SimpleDrawingEffectGroup(m_app);
                m_app.AsciiText.DefaultEffectID = (int)DrawingCommand.SimpleDC.DCRL.DEFAULT;
            }
            else
            {
                throw new Exception("存在しない EffectGroupID( " + EffectGroupID + " ) の設定");
            }
            /////////////////////////////////////////////////////
            // イメージ
            m_app.ImageMgr?.OnCreateDevice(m_app.DXDevice);
            // ブレンドステート
            m_app.BlendStateMgr?.OnCreateDevice(m_app.DXDevice);
            // レイアウト
            m_app.LayoutMgr?.OnCreateDevice(m_app.DXDevice);
            // メッシュ
            m_app.MeshMgr?.OnCreateDevice(m_app.DXDevice);
            // HLSL
            m_app.HLSLMgr?.OnCreateDevice(m_app.DXDevice);
            // スプライト
            m_app.SpriteMgr?.OnCreateDevice(m_app.DXDevice);
            // エフェクト
            m_app.BatchDrawingMgr?.SetDrawingEffectGroup(deg);
            m_app.BatchDrawingMgr?.OnCreateDevice(m_app.DXDevice);
            // カメラ
            m_app.CameraMgr?.OnCreateDevice(m_app.DXDevice);
            // ASCII
            m_app.AsciiText?.OnCreateDevice(m_app.DXDevice);
            #endregion

            // デバイス作成の呼び出し
            OnCrateDevice();
            IsCreate = true;
            DXState.DeviceCreated = true;
        }