internal static void DrawQuad(float x, float y, float w, float h) { //RC.Context.PixelShader.Set(m_blitTextureShader); RC.DeviceContext.VertexShader.Set(m_screenVertexShader); RC.DeviceContext.InputAssembler.InputLayout = m_inputLayout; var mapping = MyMapping.MapDiscard(m_quadBuffer.Buffer); var tmpFormat = new MyVertexFormatPosition2Texcoord(new Vector2(x, y), new Vector2(0, 0)); mapping.WriteAndPosition(ref tmpFormat); tmpFormat = new MyVertexFormatPosition2Texcoord(new Vector2(x + w, y + h), new Vector2(1, 1)); mapping.WriteAndPosition(ref tmpFormat); tmpFormat = new MyVertexFormatPosition2Texcoord(new Vector2(x, y + h), new Vector2(0, 1)); mapping.WriteAndPosition(ref tmpFormat); tmpFormat = new MyVertexFormatPosition2Texcoord(new Vector2(x, y), new Vector2(0, 0)); mapping.WriteAndPosition(ref tmpFormat); tmpFormat = new MyVertexFormatPosition2Texcoord(new Vector2(x + w, y), new Vector2(1, 0)); mapping.WriteAndPosition(ref tmpFormat); tmpFormat = new MyVertexFormatPosition2Texcoord(new Vector2(x + w, y + h), new Vector2(1, 1)); mapping.WriteAndPosition(ref tmpFormat); mapping.Unmap(); RC.DeviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; RC.DeviceContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(m_quadBuffer.Buffer, m_quadBuffer.Stride, 0)); RC.DeviceContext.Draw(6, 0); }
internal static void DrawQuad(float x, float y, float w, float h, VertexShaderId?customVertexShader = null) { //RC.Context.PixelShader.Set(m_blitTextureShader); VertexShaderId usedVertexShader; if (!customVertexShader.HasValue) { usedVertexShader = m_screenVertexShader; } else { usedVertexShader = customVertexShader.Value; } RC.VertexShader.Set(usedVertexShader); RC.SetInputLayout(m_inputLayout); var mapping = MyMapping.MapDiscard(m_quadBuffer.Buffer); var tmpFormat = new MyVertexFormatPosition2Texcoord(new Vector2(x, y), new Vector2(0, 0)); mapping.WriteAndPosition(ref tmpFormat); tmpFormat = new MyVertexFormatPosition2Texcoord(new Vector2(x + w, y + h), new Vector2(1, 1)); mapping.WriteAndPosition(ref tmpFormat); tmpFormat = new MyVertexFormatPosition2Texcoord(new Vector2(x, y + h), new Vector2(0, 1)); mapping.WriteAndPosition(ref tmpFormat); tmpFormat = new MyVertexFormatPosition2Texcoord(new Vector2(x, y), new Vector2(0, 0)); mapping.WriteAndPosition(ref tmpFormat); tmpFormat = new MyVertexFormatPosition2Texcoord(new Vector2(x + w, y), new Vector2(1, 0)); mapping.WriteAndPosition(ref tmpFormat); tmpFormat = new MyVertexFormatPosition2Texcoord(new Vector2(x + w, y + h), new Vector2(1, 1)); mapping.WriteAndPosition(ref tmpFormat); mapping.Unmap(); RC.SetPrimitiveTopology(PrimitiveTopology.TriangleList); RC.SetVertexBuffer(0, m_quadBuffer.Buffer, m_quadBuffer.Stride); RC.Draw(6, 0); }