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; }
/// <summary> /// Draw something that needs all the drawing is registered /// </summary> public void DrawAllResources(TexturedBufferHitChecker hitChecker) { //foreach (var edgeDrawable in this.edgeDrawables) //{ // if (edgeDrawable.Visibility) edgeDrawable.DrawEdge(); //} foreach (var drawableGroup in this.drawableGroups) { drawableGroup.DrawAll(); this._context.BlendingManager.SetBlendState(BlendStateManager.BlendStates.Alignment); } //foreach (var groundShadowDrawable in this.groundShadowDrawables) //{ // if (groundShadowDrawable.Visibility) groundShadowDrawable.DrawGroundShadow(); //} hitChecker.CheckTarget(); }
public TextureTargetContext(RenderContext context, MatrixManager matrixManager, Size size, SampleDescription sampleDesc) : base(context) { HitChecker = new TexturedBufferHitChecker(context, this); context.Timer = new MotionTimer(context); Device device = context.DeviceManager.Device; // サイズを設定(ターゲットは初期化しない) this.size = size; // マルチサンプルの設定(ターゲットも初期化する) this.SampleDesc = sampleDesc; // その他設定 this.MatrixManager = matrixManager; this.WorldSpace = new WorldSpace(context); fpsCounter = new FPSCounter(); SetViewport(); HitChecker = new TexturedBufferHitChecker(Context, this); }
/// <summary> /// 登録されているすべての描画の必要があるものを描画します /// </summary> public void DrawAllResources(TexturedBufferHitChecker hitChecker) { foreach (var edgeDrawable in edgeDrawables) { if (edgeDrawable.Visibility) { edgeDrawable.DrawEdge(); } } foreach (var drawableGroup in drawableGroups) { drawableGroup.DrawAll(); _context.BlendingManager.SetBlendState(BlendStateManager.BlendStates.Alignment); } foreach (var groundShadowDrawable in groundShadowDrawables) { if (groundShadowDrawable.Visibility) { groundShadowDrawable.DrawGroundShadow(); } } hitChecker.CheckTarget(); }