protected override void Destroy() { DestroyPlatformDevice(); // Notify listeners if (Disposing != null) { Disposing(this, EventArgs.Empty); } SamplerStates.Dispose(); BlendStates.Dispose(); RasterizerStates.Dispose(); DepthStencilStates.Dispose(); if (DepthStencilBuffer != null) { DepthStencilBuffer.Dispose(); } primitiveQuad.Dispose(); SamplerStates = null; BlendStates = null; RasterizerStates = null; DepthStencilStates = null; base.Destroy(); }
protected void SetDepthStencilState(DepthStencilStates state) { if (CurrentDepthStencilState == (int)state) { return; } GetContext.OutputMerger.SetDepthStencilState( GetSharedItems.GetDepthStencilState(state), 0x00); CurrentDepthStencilState = (int)state; }
/// <summary> /// Initializes a new instance of the <see cref="GorgonRenderable"/> class. /// </summary> /// <param name="gorgon2D">Gorgon 2D interface.</param> /// <param name="name">The name.</param> /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="name"/> parameter is NULL (Nothing in VB.Net). /// <para>-or-</para> /// <para>Thrown when the <paramref name="gorgon2D"/> parameter is NULL.</para> /// </exception> /// <exception cref="System.ArgumentException">Thrown when the <paramref name="name"/> parameter is an empty string.</exception> protected GorgonRenderable(Gorgon2D gorgon2D, string name) : base(name) { GorgonDebug.AssertNull(gorgon2D, "gorgon2D"); Gorgon2D = gorgon2D; CullingMode = CullingMode.Back; AlphaTestValues = GorgonRangeF.Empty; DepthStencil = new DepthStencilStates(); Blending = new BlendState(); TextureSampler = new TextureSamplerState(); BaseVertexCount = 0; }
internal static void Init() { Logger.Info("GraphicsManager initializing."); // Direct3D11 Init --- ResizeNextFrame = true; Factory = new FactoryDXGI(); ImagingFactory = new FactoryWIC(); Factory2D = new FactoryD2D(FactoryType.MultiThreaded, Engine.IsDebug ? DebugLevel.Error : DebugLevel.None); DirectWriteFactory = new FactoryDW(SharpDX.DirectWrite.FactoryType.Shared); CreateDevices(RenderSettings.GraphicsAdapter); Brushes = new MemoizingMRUCache <Colour, SolidColorBrush>( (colour, _) => new SolidColorBrush(Context2D, (Color4)colour) { Opacity = colour.A }, int.MaxValue, brush => brush.Dispose()); // ------------------------------------ Engine.HandleSet += hwnd => { var camera = Game.Workspace.CurrentCamera; camera.RenderHandle = hwnd; }; if (Engine.Handle != IntPtr.Zero) { var camera = Game.Workspace.CurrentCamera; camera.RenderHandle = Engine.Handle; } SamplerStates.Load(); Shaders.Init(); BlendStates.Load(); DepthStencilStates.Load(); RasterizerStates.Load(); //StandardConstants = new ConstantBuffer<StandardConstantData>(); StandardShader = Shaders.Get("Standard"); MainPass = StandardShader.GetPass(); LightingShader = Shaders.Get("Lighting"); LightingPass = LightingShader.GetPass(); PostProcessShader = Shaders.Get("PostProcess"); SkyboxShader = Shaders.Get("Skybox"); SkyboxPass = SkyboxShader.GetPass(); AdornShader = Shaders.Get("Adorn"); AALinePass = AdornShader.GetPass("AALine"); AdornSelfLitPass = AdornShader.GetPass("AdornSelfLit"); Shadows.Init(); // ------------------ IsInitialized = true; Initialized?.Invoke(); Initialized = null; //PixHelper.AllowProfiling(Engine.IsDebug); Logger.Info("Renderer initialized."); }