/// <summary> /// Dispose element /// </summary> public void Dispose() { _rasterState.Dispose(); _blendState.Dispose(); _depthState.Dispose(); _samplerState.Dispose(); _backbufferView.Dispose(); _zbufferView.Dispose(); _swapchain.Dispose(); _deviceContext.Dispose(); _device.Dispose(); }
public void Dispose() { if (!disposed) { disposed = true; Background.Dispose(); CompressToSwap.Dispose(); SphereRenderer.Dispose(); CapsuleRenderer.Dispose(); BoxRenderer.Dispose(); TriangleRenderer.Dispose(); MeshRenderer.Dispose(); UILineRenderer.Dispose(); GlyphRenderer.Dispose(); dsv.Dispose(); depthBuffer.Dispose(); rtv.Dispose(); colorBuffer.Dispose(); resolvedSRV.Dispose(); resolvedRTV.Dispose(); resolvedColorBuffer.Dispose(); rasterizerState.Dispose(); opaqueDepthState.Dispose(); opaqueBlendState.Dispose(); a2cBlendState.Dispose(); uiDepthState.Dispose(); uiBlendState.Dispose(); Shapes.Dispose(); } }
public void VisualTestScissorTestEnable(bool scissorTestEnable) { PrepareFrameCapture(); var cube = new Colored3DCubeComponent(gd); cube.LoadContent(); var rasterizerstate = new RasterizerState { ScissorTestEnable = scissorTestEnable }; gd.RasterizerState = rasterizerstate; var viewport = gd.Viewport; gd.ScissorRectangle = new Rectangle(0, 0, viewport.Width / 2, viewport.Height / 2); cube.Draw(); CheckFrames(); cube.UnloadContent(); rasterizerstate.Dispose(); }
internal static void Dispose() { _font = null; _fontSmall = null; _uiSpritesheet = null; _uiStylesheet = null; Stylesheet.Current = null; _whiteRegion = null; if (_white != null) { _white.Dispose(); _white = null; } if (_uiBitmap != null) { _uiBitmap.Dispose(); _uiBitmap = null; } if (_uiRasterizerState != null) { _uiRasterizerState.Dispose(); _uiRasterizerState = null; } }
void IDisposable.Dispose() { VS.Dispose(); GS_Tri.Dispose(); PS.Dispose(); RS.Dispose(); }
public void Dispose() { _constants.Dispose(); if (m_ds != null) { m_ds.Dispose(); m_ds = null; } if (m_rs != null) { m_rs.Dispose(); m_rs = null; } if (m_ss != null) { m_ss.Dispose(); m_ss = null; } if (m_srv != null) { m_srv.Dispose(); m_srv = null; } if (Shader != null) { Shader.Dispose(); Shader = null; } }
public void VisualTestDepthClipEnable(bool depthClipEnable) { PrepareFrameCapture(); var cube = new Colored3DCubeComponent(gd) { CubePosition = new Vector3(0, 0, 3) }; cube.LoadContent(); var rasterizerstate = new RasterizerState { DepthClipEnable = depthClipEnable }; gd.RasterizerState = rasterizerstate; cube.Draw(); CheckFrames(); cube.UnloadContent(); rasterizerstate.Dispose(); }
public void Dispose() { s_vb.Dispose(); s_ib.Dispose(); s_material.Dispose(); s_wireframeRasterizerState.Dispose(); }
public void Dispose() { if (!disposed) { disposed = true; Background.Dispose(); CompressToSwap.Dispose(); SphereRenderer.Dispose(); CapsuleRenderer.Dispose(); UILineRenderer.Dispose(); GlyphRenderer.Dispose(); depthBuffer.Dispose(); dsv.Dispose(); colorBuffer.Dispose(); rtv.Dispose(); rasterizerState.Dispose(); opaqueDepthState.Dispose(); opaqueBlendState.Dispose(); uiDepthState.Dispose(); uiBlendState.Dispose(); } }
public void Dispose() { RasterizerState?.Dispose(); DepthStencilState?.Dispose(); BlendState?.Dispose(); OpenTK.Graphics.OpenGL4.GL.DeleteProgramPipeline(_nativePipeline); }
public void Dispose() { VertexShader?.Dispose(); PixelShader?.Dispose(); RasterizerState?.Dispose(); DepthStencilState?.Dispose(); BlendState?.Dispose(); }
public override void Dispose() { renderTargets.Dispose(); if (rasterizerState != null) { rasterizerState.Dispose(); } }
/// <inheritdoc /> /// <summary> /// </summary> public void Dispose() { ImGui.DestroyContext(Context); Effect?.Dispose(); RasterizerState?.Dispose(); VertexBuffer?.Dispose(); IndexBuffer?.Dispose(); }
/// <summary> /// Initialise the device and set up a render window /// </summary> public static RenderForm InitD3D( out SlimDX.Direct3D11.Device device, out SwapChain swapChain, out RenderTargetView renderView) { var form = new RenderForm("Solar simulation"); form.Width = 1080; form.Height = 1080; var desc = new SwapChainDescription() { BufferCount = 1, ModeDescription = new ModeDescription(form.ClientSize.Width, form.ClientSize.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm), IsWindowed = true, OutputHandle = form.Handle, SampleDescription = new SampleDescription(1, 0), SwapEffect = SwapEffect.Discard, Usage = Usage.RenderTargetOutput }; SlimDX.Direct3D11.Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.Debug, desc, out device, out swapChain); Factory factory = swapChain.GetParent <Factory>(); factory.SetWindowAssociation(form.Handle, WindowAssociationFlags.IgnoreAll); RasterizerStateDescription rsd = new RasterizerStateDescription() { CullMode = CullMode.None, DepthBias = 0, DepthBiasClamp = 0.0f, FillMode = FillMode.Solid, IsAntialiasedLineEnabled = false, IsDepthClipEnabled = false, IsFrontCounterclockwise = false, IsMultisampleEnabled = false, IsScissorEnabled = false, SlopeScaledDepthBias = 0.0f }; RasterizerState rs = RasterizerState.FromDescription(device, rsd); device.ImmediateContext.Rasterizer.State = rs; Texture2D backBuffer = Texture2D.FromSwapChain <Texture2D>(swapChain, 0); renderView = new RenderTargetView(device, backBuffer); device.ImmediateContext.OutputMerger.SetTargets(renderView); device.ImmediateContext.Rasterizer.SetViewports(new Viewport(0, 0, form.ClientSize.Width, form.ClientSize.Height, 0.0f, 1.0f)); rs.Dispose(); backBuffer.Dispose(); return(form); }
// todo public static void draw_ellipse(Vector2 pos, Vector2 exct, float theta) { Microsoft.Xna.Framework.Color fc = FinalizeColor(DrawColor); int vertexCount = 40; VertexPositionColor[] vertices = new VertexPositionColor[vertexCount]; //Drawing an Ellipse with its major axis parallel to the x-axis. Rotation can be applied to change this. Vector3 position = Vector3.One; const float max = MathHelper.Pi; //2 * max since we're moving from -Pi to +Pi in the loop. float step = 2 * max / (float)vertexCount; int i = 0; //Optional Axis and angle rotation for the ellipse (See later notes): //Vector3 axis = new Vector3(0, 0, -1); float angle = MathHelper.ToRadians(theta); for (float t = -max; t <= max; t += step) { //Formula shamelessly taken from wikipedia position = new Vector3(exct.X + pos.X * (float)Math.Cos((double)t), exct.Y + pos.Y * (float)Math.Sin((double)t), 0f); //Optional Rotation for the Ellipse: position = Vector3.Transform(position, Matrix.CreateFromAxisAngle(new Vector3(0, 0, angle), angle)); vertices[i] = new VertexPositionColor(position, fc); i++; } //Optional Rotation for the Ellipse: //then add the first vector again so it's a complete loop (sounds familiar) position = new Vector3(exct.X + pos.X * (float)Math.Cos((double)-max), exct.Y + pos.Y * (float)Math.Sin((double)-max), 0f); position = Vector3.Transform(position, Matrix.CreateFromAxisAngle(new Vector3(0, 0, angle), angle)); vertices[vertexCount - 1] = new VertexPositionColor(position, fc); vb = new DynamicVertexBuffer(sb.GraphicsDevice, typeof(VertexPositionColor), vertices.Length, BufferUsage.WriteOnly); vb.SetData <VertexPositionColor>(vertices.ToArray()); sb.GraphicsDevice.SetVertexBuffer(vb); RasterizerState rasterizerState = new RasterizerState(); rasterizerState.CullMode = CullMode.None; rasterizerState.MultiSampleAntiAlias = true; rasterizerState.FillMode = FillMode.Solid; sb.GraphicsDevice.RasterizerState = rasterizerState; foreach (EffectPass pass in be.CurrentTechnique.Passes) { pass.Apply(); sb.GraphicsDevice.DrawPrimitives(PrimitiveType.LineStrip, 0, (vertices.Length - 1)); } vb.Dispose(); rasterizerState.Dispose(); }
public override void DestroyDeviceObjects() { _shaderSet.Dispose(); _vb.Dispose(); _ib.Dispose(); _gridTexture.Dispose(); _textureBinding.Dispose(); _rasterizerState.Dispose(); }
public void Dispose() { _vb.Dispose(); _ib.Dispose(); _material.Dispose(); _worldBuffer.Dispose(); _inverseTransposeWorldBuffer.Dispose(); s_wireframeRasterizerState.Dispose(); }
public void Dispose() { _rasterizerWireframe?.Dispose(); _rotationHelperGeometry?.Dispose(); _cylinder?.Dispose(); _cube?.Dispose(); _cone?.Dispose(); _torus?.Dispose(); }
///<summary>Disposes all resources owned by this RenderContext.</summary> public void Dispose() { _defaultDepthStencilState.Dispose(); _defaultRasterizerState.Dispose(); _additiveBlend?.Dispose(); _overrideBlend?.Dispose(); _alphaBlend?.Dispose(); PlatformDispose(); }
public void Dispose() { _vb?.Dispose(); _ib?.Dispose(); _material?.Dispose(); _texture?.Dispose(); _textureBinding?.Dispose(); _wireframeState?.Dispose(); }
public void Dispose() { SwapChain.Dispose(); RenderTargetView.Dispose(); DepthStencilState.Dispose(); DepthStencilView.Dispose(); DepthStencilTexture.Dispose(); RasterizerState.Dispose(); }
public void Dispose() { inputLayout.Dispose(); rasterizerState.Dispose(); texture.Dispose(); textureTargetView.Dispose(); resolveTexture.Dispose(); stagingTexture.Dispose(); }
public void Dispose() { RsDebug?.Dispose(); _rsCw?.Dispose(); _rsCcw?.Dispose(); LightRenderer.Dispose(); LightMapRenderer.Dispose(); ShadowRenderer.Dispose(); }
public void Dispose() { rasterizerState.Dispose(); depthStencilView.Dispose(); depthStencilBuffer.Dispose(); renderTargetView.Dispose(); swapChain.Dispose(); device.Dispose(); }
protected override void Dispose(bool disposing) { if (disposing) { _rasterizerWireframe?.Dispose(); _plane?.Dispose(); _wadRenderer?.Dispose(); } base.Dispose(disposing); }
public override void DestroyDeviceObjects() { _shaderSet.Dispose(); _cubemapTexture.Dispose(); _cubemapBinding.Dispose(); _vb.Dispose(); _ib.Dispose(); _viewMatrixBuffer.Dispose(); _rasterizerState.Dispose(); }
private void Dispose(bool disposing) { if (mState != null) { mState.Dispose(); mState = null; } mContext = null; }
public void Dispose() { // Release all resources figures.Dispose(); if (ctx != null) { ctx.ClearState(); ctx.Flush(); ctx.Dispose(); } if (il != null) { il.Dispose(); } if (effect != null) { effect.Dispose(); } if (hmd != null) { keyboard.Dispose(); directInput.Dispose(); mtex.Dispose(); layers.Dispose(); eye_texes[0].Dispose(); eye_texes[1].Dispose(); default_rasterizer_state.Dispose(); default_depth_stencil_state.Dispose(); default_blend_state.Dispose(); ztex_view.Dispose(); ztex.Dispose(); buf0_view.Dispose(); buf0.Dispose(); swap_chain.Dispose(); dxgi_factory.Dispose(); // Disposing the device, before the hmd, will cause the hmd to fail when disposing. // Disposing the device, after the hmd, will cause the dispose of the device to fail. // It looks as if the hmd steals ownership of the device and destroys it, when it's shutting down. // device.Dispose(); hmd.Dispose(); } oculus.Dispose(); }
public void Dispose() { if (!disposed) { OnDisposed(); colors.Dispose(); fillState.Dispose(); wireframeState.Dispose(); disposed = true; } }
protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { ScissorTestEnable.Dispose(); } disposedValue = true; } }
/// <summary> /// Renders the mesh with the specified transformation. This alternate render method /// supplements the base class rendering to provide part-by-part texturing support. /// </summary> /// <param name="modelTransform"></param> public void Render(Matrix3D modelTransform) { // setup rasterization RasterizerDescription rasterizerDescription = new RasterizerDescription() { FillMode = FillMode.Solid, CullMode = CullMode.Back, FrontCounterclockwise = false, DepthBias = 0, DepthBiasClamp = 0, SlopeScaledDepthBias = 0, DepthClipEnable = true, ScissorEnable = false, MultisampleEnable = true, AntiAliasedLineEnable = true }; try { solidRasterizerState = this.manager.device.CreateRasterizerState(rasterizerDescription); rasterizerDescription.FillMode = FillMode.Wireframe; wireframeRasterizerState = this.manager.device.CreateRasterizerState(rasterizerDescription); base.Render(modelTransform.ToMatrix4x4F()); } finally { if (solidRasterizerState != null) { solidRasterizerState.Dispose(); solidRasterizerState = null; } if (wireframeRasterizerState != null) { wireframeRasterizerState.Dispose(); wireframeRasterizerState = null; } currentRasterizerState = null; } }
protected void InitOnce() { var shaderdeffile = Manager.Files.Get(@"Shaders\DeferredRendering.hlsl", false); var bbuffer = new byte[shaderdeffile.Length]; shaderdeffile.Read(bbuffer,0, bbuffer.Length); shaderdeffile.Dispose(); var bytecode = ShaderBytecode.Compile(bbuffer, "fx_5_0"); bbuffer = null; _effect = new Effect(D3DDevice, bytecode); bytecode.Dispose(); _composeTechnique = _effect.GetTechniqueByName("Compose"); _composePass = _composeTechnique.GetPassByIndex(0); var vertices = new DataStream(20 * 4, true, true); vertices.Write(new Vector3(-1f, -1f, -1f)); vertices.Write(new Vector2(0f,1f)); vertices.Write(new Vector3(-1f, 1f, -1f)); vertices.Write(new Vector2(0f, 0f)); vertices.Write(new Vector3(1f, -1f, -1f)); vertices.Write(new Vector2(1f, 1f)); vertices.Write(new Vector3(1f, 1f, -1f)); vertices.Write(new Vector2(1f, 0f)); vertices.Position = 0; _composeVertices = new Buffer(D3DDevice, vertices, 20 * 4, ResourceUsage.Default, BindFlags.VertexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0); _composeVerticesBB = new VertexBufferBinding(_composeVertices, 20, 0); vertices.Dispose(); _composeLayout = new InputLayout(D3DDevice, _composePass.Description.Signature, new[] { new InputElement("POSITION", 0, Format.R32G32B32_Float, 0), new InputElement("TEXCOORD", 0, Format.R32G32_Float, 0) }); var sampleMode = SamplerState.FromDescription(D3DDevice, new SamplerDescription() { AddressU = TextureAddressMode.Clamp, AddressV = TextureAddressMode.Clamp, AddressW = TextureAddressMode.Clamp, BorderColor = new Color4(0, 0, 0, 0), Filter = Filter.MinLinearMagMipPoint, ComparisonFunction = Comparison.Always, MipLodBias = 0f, MaximumAnisotropy = 8, MinimumLod = 0f, MaximumLod = float.MaxValue }); _effect.GetVariableByName("composeSampler").AsSampler().SetSamplerState(0, sampleMode); sampleMode.Dispose(); _effect.GetVariableByName("composeFlags").AsScalar().Set( Manager.Opts.Get<bool>("rndr_rawGBufferView")?0x1:0 ); NotifyHandlers.Add(Manager.Opts.RegisterChangeNotification("rndr_rawGBufferView", delegate(string key, object value) { Output.BeginInvoke((Action)delegate { if ((bool)value) _effect.GetVariableByName("composeFlags").AsScalar().Set(_effect.GetVariableByName("composeFlags").AsScalar().GetInt() | 0x1); else _effect.GetVariableByName("composeFlags").AsScalar().Set(_effect.GetVariableByName("composeFlags").AsScalar().GetInt() & (int.MaxValue - 0x1)); }); })); NotifyHandlers.Add(Manager.Opts.RegisterChangeNotification("rndr_nearPlane", delegate { Output.BeginInvoke((Action)ResetDevice); })); NotifyHandlers.Add(Manager.Opts.RegisterChangeNotification("rndr_farPlane", delegate { Output.BeginInvoke((Action)ResetDevice); })); SceneRasterizer = RasterizerState.FromDescription(D3DDevice, new RasterizerStateDescription() { FillMode = (Manager.Opts.Get<bool>("rndr_wireframe") ? FillMode.Wireframe : FillMode.Solid), CullMode = (Manager.Opts.Get<bool>("rndr_cull") ? CullMode.Back : CullMode.None) }); _composeRasterizer = RasterizerState.FromDescription(D3DDevice, new RasterizerStateDescription() { FillMode = FillMode.Solid, CullMode = CullMode.Back }); var bsd = new BlendStateDescription(); bsd.RenderTargets[0].BlendEnable = true; bsd.RenderTargets[0].SourceBlend = BlendOption.SourceAlpha; bsd.RenderTargets[0].DestinationBlend = BlendOption.InverseSourceAlpha; bsd.RenderTargets[0].BlendOperation = BlendOperation.Add; bsd.RenderTargets[0].SourceBlendAlpha = BlendOption.One; bsd.RenderTargets[0].DestinationBlendAlpha = BlendOption.Zero; bsd.RenderTargets[0].BlendOperationAlpha = BlendOperation.Add; bsd.RenderTargets[0].RenderTargetWriteMask = ColorWriteMaskFlags.All; Context.OutputMerger.BlendState = BlendState.FromDescription(D3DDevice, bsd); NotifyHandlers.Add(Manager.Opts.RegisterChangeNotification("rndr_wireframe", delegate(string key, object value) { Output.BeginInvoke((Action)delegate { var oldcullmode = CullMode.Back; if (SceneRasterizer != null) { oldcullmode = SceneRasterizer.Description.CullMode; SceneRasterizer.Dispose(); } SceneRasterizer = RasterizerState.FromDescription(D3DDevice, new RasterizerStateDescription() { FillMode = (((bool)value) ? FillMode.Wireframe : FillMode.Solid), CullMode = oldcullmode }); }); })); NotifyHandlers.Add(Manager.Opts.RegisterChangeNotification("rndr_cull", delegate(string key, object value) { Output.BeginInvoke((Action)delegate { var oldfillmode = FillMode.Solid; if (SceneRasterizer != null) { oldfillmode = SceneRasterizer.Description.FillMode; SceneRasterizer.Dispose(); } SceneRasterizer = RasterizerState.FromDescription(D3DDevice, new RasterizerStateDescription() { FillMode = oldfillmode, CullMode = (((bool)value) ? CullMode.Back : CullMode.None) }); }); })); Context.OutputMerger.DepthStencilState = DepthStencilState.FromDescription(D3DDevice, new DepthStencilStateDescription() { IsDepthEnabled = true, DepthWriteMask = DepthWriteMask.All, DepthComparison = Comparison.Less, IsStencilEnabled = false, }); _camIncorporeal = Manager.Opts.Get<bool>("rndr_incorporeal"); NotifyHandlers.Add(Manager.Opts.RegisterChangeNotification("rndr_incorporeal", delegate(string key, object value) { _camIncorporeal = (bool)value; })); ViewerLocation = new Vector3(-1, 1, -1); ViewerLookAt = new Vector3(0, 0, 0); ViewerUpVector = Vector3.UnitY; _camLocationIncorporeal = new Vector3(-1, 1, -1); _camLookAtIncorporeal = new Vector3(0, 0, 0); _camUpVectorIncorporeal = Vector3.UnitY; ViewerFrustum = new Frustum(); _fpsTimer = new HTimer(); _fpsRingbuffer = new double[60]; _fpsRingbufferIndex = 0; }