update BasicStencil

refresh2
cosmonaut 2024-02-23 10:59:38 -08:00
parent d6ec93525e
commit 94438c8991
1 changed files with 14 additions and 13 deletions

View File

@ -8,7 +8,7 @@ namespace MoonWorks.Test
{ {
private GraphicsPipeline maskerPipeline; private GraphicsPipeline maskerPipeline;
private GraphicsPipeline maskeePipeline; private GraphicsPipeline maskeePipeline;
private Buffer vertexBuffer; private GpuBuffer vertexBuffer;
private Texture depthStencilTexture; private Texture depthStencilTexture;
public BasicStencilGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true) public BasicStencilGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
@ -29,7 +29,7 @@ namespace MoonWorks.Test
pipelineCreateInfo.DepthStencilState = new DepthStencilState pipelineCreateInfo.DepthStencilState = new DepthStencilState
{ {
StencilTestEnable = true, StencilTestEnable = true,
FrontStencilState = new StencilOpState StencilState = new StencilOpState
{ {
Reference = 1, Reference = 1,
WriteMask = 0xFF, WriteMask = 0xFF,
@ -42,7 +42,7 @@ namespace MoonWorks.Test
pipelineCreateInfo.DepthStencilState = new DepthStencilState pipelineCreateInfo.DepthStencilState = new DepthStencilState
{ {
StencilTestEnable = true, StencilTestEnable = true,
FrontStencilState = new StencilOpState StencilState = new StencilOpState
{ {
Reference = 0, Reference = 0,
CompareMask = 0xFF, CompareMask = 0xFF,
@ -60,13 +60,11 @@ namespace MoonWorks.Test
TextureFormat.D16S8, TextureFormat.D16S8,
TextureUsageFlags.DepthStencilTarget TextureUsageFlags.DepthStencilTarget
); );
vertexBuffer = Buffer.Create<PositionColorVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 6);
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer(); var resourceInitializer = new ResourceInitializer(GraphicsDevice);
cmdbuf.SetBufferData(
vertexBuffer, vertexBuffer = resourceInitializer.CreateBuffer(
new PositionColorVertex[] [
{
new PositionColorVertex(new Vector3(-0.5f, 0.5f, 0), Color.Yellow), new PositionColorVertex(new Vector3(-0.5f, 0.5f, 0), Color.Yellow),
new PositionColorVertex(new Vector3(0.5f, 0.5f, 0), Color.Yellow), new PositionColorVertex(new Vector3(0.5f, 0.5f, 0), Color.Yellow),
new PositionColorVertex(new Vector3(0, -0.5f, 0), Color.Yellow), new PositionColorVertex(new Vector3(0, -0.5f, 0), Color.Yellow),
@ -74,9 +72,12 @@ namespace MoonWorks.Test
new PositionColorVertex(new Vector3(-1, 1, 0), Color.Red), new PositionColorVertex(new Vector3(-1, 1, 0), Color.Red),
new PositionColorVertex(new Vector3(1, 1, 0), Color.Lime), new PositionColorVertex(new Vector3(1, 1, 0), Color.Lime),
new PositionColorVertex(new Vector3(0, -1, 0), Color.Blue), new PositionColorVertex(new Vector3(0, -1, 0), Color.Blue),
} ],
BufferUsageFlags.Vertex
); );
GraphicsDevice.Submit(cmdbuf);
resourceInitializer.Upload();
resourceInitializer.Dispose();
} }
protected override void Update(System.TimeSpan delta) { } protected override void Update(System.TimeSpan delta) { }
@ -93,9 +94,9 @@ namespace MoonWorks.Test
); );
cmdbuf.BindGraphicsPipeline(maskerPipeline); cmdbuf.BindGraphicsPipeline(maskerPipeline);
cmdbuf.BindVertexBuffers(vertexBuffer); cmdbuf.BindVertexBuffers(vertexBuffer);
cmdbuf.DrawPrimitives(0, 1, 0, 0); cmdbuf.DrawPrimitives(0, 1);
cmdbuf.BindGraphicsPipeline(maskeePipeline); cmdbuf.BindGraphicsPipeline(maskeePipeline);
cmdbuf.DrawPrimitives(3, 1, 0, 0); cmdbuf.DrawPrimitives(3, 1);
cmdbuf.EndRenderPass(); cmdbuf.EndRenderPass();
} }
GraphicsDevice.Submit(cmdbuf); GraphicsDevice.Submit(cmdbuf);