Пример #1
0
        protected void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    this.Context = null;
                }

                if (WorldSpace != null)
                {
                    WorldSpace.Dispose();
                    WorldSpace = null;
                }

                DisposeTargetViews();
                if (RenderTarget != null && !RenderTarget.Disposed)
                {
                    RenderTarget.Dispose();
                }
                if (DepthTarget != null && !DepthTarget.Disposed)
                {
                    DepthTarget.Dispose();
                }
                HitChecker.Dispose();
                disposed = true;
            }
        }
Пример #2
0
        public ScreenContext(Control owner, RenderContext context, MatrixManager manager) : base(context)
        {
            Device            device     = context.DeviceManager.Device;
            SampleDescription sampleDesc = new SampleDescription(1, 0);

            SwapChain = new SwapChain(context.DeviceManager.Factory, device, getSwapChainDescription(owner, sampleDesc));
            //ラスタライザの設定
            //深度ステンシルバッファの初期化
            using (Texture2D depthBuffer = new Texture2D(device, getDepthBufferTexture2DDescription(owner, sampleDesc)))
            {
                DepthTargetView = new DepthStencilView(device, depthBuffer);
            }
            //レンダーターゲットの初期化
            using (Texture2D renderTexture = Resource.FromSwapChain <Texture2D>(SwapChain, 0))
            {
                RenderTargetView = new RenderTargetView(device, renderTexture);
            }
            WorldSpace    = new WorldSpace(context);
            BindedControl = owner;
            MatrixManager = manager;
            PanelObserver = new PanelObserver(owner);
            SetViewport();
            HitChekcer = new TexturedBufferHitChecker(Context, this);
            HitChekcer.Resize(owner.ClientSize);
            owner.MouseMove += owner_MouseMove;
            owner.MouseDown += owner_MouseDown;
            owner.MouseUp   += owner_MouseUp;
        }
Пример #3
0
 /// <summary>
 /// WorldSpaceの内容を描画します.
 /// </summary>
 public void Render()
 {
     if (WorldSpace == null || WorldSpace.IsDisposed)
     {
         return;
     }
     Context.SetRenderScreen(this);
     Context.ClearScreenTarget(BackgroundColor);
     Context.Timer.TickUpdater();
     fpsCounter.CountFrame();
     MoveCameraByCameraMotionProvider();
     WorldSpace.DrawAllResources(HitChecker);
     Context.DeviceManager.Context.Flush();
 }
Пример #4
0
 public override void Dispose()
 {
     if (WorldSpace != null)
     {
         WorldSpace.Dispose();
     }
     if (RenderTargetView != null && !RenderTargetView.Disposed)
     {
         RenderTargetView.Dispose();
     }
     if (DepthTargetView != null && !DepthTargetView.Disposed)
     {
         DepthTargetView.Dispose();
     }
     if (SwapChain != null && !SwapChain.Disposed)
     {
         SwapChain.Dispose();
     }
     HitChekcer.Dispose();
 }