private DepthStencilState(GraphicsDevice device, DepthStencilStateDescription depthStencilStateDescription) : base(device) { Description = depthStencilStateDescription; depthFunction = Description.DepthBufferFunction.ToOpenGLDepthFunction(); }
/// <summary> /// Initializes a new instance of the <see cref="DepthStencilState"/> class. /// </summary> /// <param name="depthEnable">if set to <c>true</c> [depth enable].</param> /// <param name="depthWriteEnable">if set to <c>true</c> [depth write enable].</param> /// <param name="name">The name.</param> private DepthStencilState(GraphicsDevice device, DepthStencilStateDescription depthStencilStateDescription) : base(device) { Description = depthStencilStateDescription; CreateNativeDeviceChild(); }
/// <summary> /// Initializes a new instance of the <see cref="IDepthStencilState"/> class. /// </summary> /// <param name="graphicsDevice">The graphics device.</param> /// <param name="description">The description.</param> public static DepthStencilState New(GraphicsDevice graphicsDevice, DepthStencilStateDescription description) { return(new DepthStencilState(graphicsDevice, description)); }
// For FakeDepthStencilState. protected DepthStencilState(DepthStencilStateDescription description) { Description = description; }
public override void Load() { base.Load(); skyboxEffect = this.EffectSystemOld.BuildEffect("Skybox") .Using(new StateShaderPlugin() { RenderPassPlugin = this, UseDepthStencilState = true }) .Using(new BasicShaderPlugin( new ShaderMixinSource() { Mixins = new List<ShaderClassSource>() { new ShaderClassSource("SkyBox")}, Compositions = new Dictionary<string, ShaderSource>() { {"color", SkyBoxColor}} }) { RenderPassPlugin = this }) .InstantiatePermutation(); if (OfflineCompilation) return; Parameters.AddSources(MainPlugin.ViewParameters); var zBackgroundValue = MainTargetPlugin.ClearDepth; // Generates a quad for post effect rendering (should be utility function) var vertices = new[] { -1.0f, 1.0f, zBackgroundValue, 1.0f, 1.0f, 1.0f, zBackgroundValue, 1.0f, -1.0f, -1.0f, zBackgroundValue, 1.0f, 1.0f, -1.0f, zBackgroundValue, 1.0f, }; Parameters.RegisterParameter(EffectPlugin.DepthStencilStateKey); Parameters.Set(TexturingKeys.Sampler, GraphicsDevice.SamplerStates.LinearWrap); // Use the quad for this effectMesh var quadData = new Mesh(); quadData.Draw = new MeshDraw { DrawCount = 4, PrimitiveType = PrimitiveType.TriangleStrip, VertexBuffers = new[] { new VertexBufferBinding(Buffer.Vertex.New(GraphicsDevice, vertices), new VertexDeclaration(VertexElement.Position<Vector4>()), 4) } }; RenderPass.StartPass += (context) => { // Setup the Viewport context.GraphicsDevice.SetViewport(MainTargetPlugin.Viewport); // Setup the depth stencil and main render target. context.GraphicsDevice.SetRenderTarget(MainTargetPlugin.DepthStencil, MainTargetPlugin.RenderTarget); }; RenderPass.EndPass += (context) => context.GraphicsDevice.UnsetRenderTargets(); var skyboxMesh = new EffectMesh(skyboxEffect, quadData).KeepAliveBy(this); // If the main target plugin is not clearing anything, we assume that this is the job of the skybox plugin if (!MainTargetPlugin.EnableClearTarget && !MainTargetPlugin.EnableClearDepth) { var description = new DepthStencilStateDescription().Default(); description.DepthBufferFunction = CompareFunction.Always; var alwaysWrite = DepthStencilState.New(GraphicsDevice, description); skyboxMesh.Parameters.Set(EffectPlugin.DepthStencilStateKey, alwaysWrite); } else { skyboxMesh.Parameters.Set(EffectPlugin.DepthStencilStateKey, MainTargetPlugin.DepthStencilState); } skyboxMesh.Parameters.AddSources(this.Parameters); RenderSystem.GlobalMeshes.AddMesh(skyboxMesh); }
protected override void LoadContent() { base.LoadContent(); // create effect and geometric primitives Batch = new UIBatch(GraphicsDevice); // create depth stencil states var depthStencilDescription = new DepthStencilStateDescription(true, true) { StencilEnable = true, FrontFace = new DepthStencilStencilOpDescription { StencilDepthBufferFail = StencilOperation.Keep, StencilFail = StencilOperation.Keep, StencilPass = StencilOperation.Keep, StencilFunction = CompareFunction.Equal }, BackFace = new DepthStencilStencilOpDescription { StencilDepthBufferFail = StencilOperation.Keep, StencilFail = StencilOperation.Keep, StencilPass = StencilOperation.Keep, StencilFunction = CompareFunction.Equal }, }; KeepStencilValueState = DepthStencilState.New(GraphicsDevice, depthStencilDescription); depthStencilDescription.FrontFace.StencilPass = StencilOperation.Increment; depthStencilDescription.BackFace.StencilPass = StencilOperation.Increment; IncreaseStencilValueState = DepthStencilState.New(GraphicsDevice, depthStencilDescription); depthStencilDescription.FrontFace.StencilPass = StencilOperation.Decrement; depthStencilDescription.BackFace.StencilPass = StencilOperation.Decrement; DecreaseStencilValueState = DepthStencilState.New(GraphicsDevice, depthStencilDescription); // set the default design of the UI elements. var designsTexture = TextureExtensions.FromFileData(GraphicsDevice, DefaultDesigns.Designs); Button.PressedImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default button pressed design", designsTexture) { Borders = 8 * Vector4.One, Region = new RectangleF(71, 3, 32, 32)}); Button.NotPressedImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default button not pressed design", designsTexture) { Borders = 8 * Vector4.One, Region = new RectangleF(3, 3, 32, 32) }); Button.MouseOverImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default button overred design", designsTexture) { Borders = 8 * Vector4.One, Region = new RectangleF(37, 3, 32, 32) }); EditText.ActiveImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default edit active design", designsTexture) { Borders = 12 * Vector4.One, Region = new RectangleF(105, 3, 32, 32) }); EditText.InactiveImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default edit inactive design", designsTexture) { Borders = 12 * Vector4.One, Region = new RectangleF(139, 3, 32, 32) }); EditText.MouseOverImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default edit overred design", designsTexture) { Borders = 12 * Vector4.One, Region = new RectangleF(173, 3, 32, 32) }); ToggleButton.CheckedImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default toggle button checked design", designsTexture) { Borders = 8 * Vector4.One, Region = new RectangleF(71, 3, 32, 32) }); ToggleButton.UncheckedImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default toggle button unchecked design", designsTexture) { Borders = 8 * Vector4.One, Region = new RectangleF(3, 3, 32, 32) }); ToggleButton.IndeterminateImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default toggle button indeterminate design", designsTexture) { Borders = 8 * Vector4.One, Region = new RectangleF(37, 3, 32, 32) }); Slider.TrackBackgroundImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default slider track background design", designsTexture) { Borders = 14 * Vector4.One, Region = new RectangleF(207, 3, 32, 32) }); Slider.TrackForegroundImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default slider track foreground design", designsTexture) { Borders = 0 * Vector4.One, Region = new RectangleF(3, 37, 32, 32) }); Slider.ThumbImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default slider thumb design", designsTexture) { Borders = 4 * Vector4.One, Region = new RectangleF(37, 37, 16, 32) }); Slider.MouseOverThumbImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default slider thumb overred design", designsTexture) { Borders = 4 * Vector4.One, Region = new RectangleF(71, 37, 16, 32) }); Slider.TickImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default slider track foreground design", designsTexture) { Region = new RectangleF(245, 3, 3, 6) }); Slider.TickOffsetPropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(13f); Slider.TrackStartingOffsetsrPropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new Vector2(3)); }
public DepthStencilState(GraphicsDevice device, DepthStencilStateDescription description) : base(device) { throw new NotImplementedException(); }
public FakeDepthStencilState(DepthStencilStateDescription description) : base(description) { }