Example #1
0
 public TexturedQuad(VirtualTexture texture)
 {
     Texture = texture;
     UVBounds = new Rectangle(0, 0, texture != null ? texture.Width : 0, texture != null ? texture.Height : 0);
     ColorToAdd = Color.Transparent;
     ColorToModulate = Color.White;
     ColorScale = Vector4.One;
     BlendState = BlendState.AlphaBlend;
     Flags |= TextureQuadFlags.OffsetByHalfTexel;
 }
Example #2
0
        public void Draw(VirtualTexture cardFrameTexture, Vector3 pileSize, Matrix transform)
        {
            if (cardFrameTexture == null)
            {
                throw new ArgumentNullException("cardFrameTexture");
            }

            PInvokes.D3d9.BeginPixEvent(0, "PileRenderer.Draw");

            var device = GameApp.Instance.GraphicsDevice;

            var oldBlendState = device.BlendState;
            var oldDepthState = device.DepthStencilState;
            var oldRasterizerState = device.RasterizerState;

            device.SetVertexBuffer(m_pileVertices);
            device.Indices = m_pileIndices;
            device.BlendState = BlendState.Opaque;
            device.DepthStencilState = DepthStencilState.Default;
            device.RasterizerState = RasterizerState.CullCounterClockwise;

            m_paramTransform.SetValue(transform);
            m_paramPileSize.SetValue(pileSize);
            var oneOverWidth = 1.0f / cardFrameTexture.XnaTexture.Bounds.Width;
            var oneOverHeight = 1.0f / cardFrameTexture.XnaTexture.Bounds.Height;
            m_paramUVAdjust.SetValue(new Vector4(
                cardFrameTexture.Bounds.Width * oneOverWidth,
                cardFrameTexture.Bounds.Height * oneOverHeight,
                cardFrameTexture.Bounds.Left * oneOverWidth,
                cardFrameTexture.Bounds.Top * oneOverHeight));
            m_paramColorBias.SetValue(Vector4.Zero);
            m_paramColorScale.SetValue(Vector4.One);
            m_paramTexture.SetValue(cardFrameTexture.XnaTexture);

            foreach (var pass in m_effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 8, 0, 10);
            }

            device.BlendState = oldBlendState;
            device.DepthStencilState = oldDepthState;
            device.RasterizerState = oldRasterizerState;

            PInvokes.D3d9.EndPixEvent();
        }