I want to draw the Silverlight-PhoneApplicationPage and its controls on top of some squares which I draw as TriangleStrips.
The other way around is works perfectly fine, but the squares are drawn on top of my controls - I do something like this in my Draw-function:
private void OnDraw(object sender, GameTimerEventArgs e)
{
// Clean up device
graphicsDevice.Clear(Microsoft.Xna.Framework.Color.Black);
graphicsDevice.BlendState = BlendState.AlphaBlend;
RasterizerState stat = new RasterizerState();
stat.CullMode = CullMode.None;
graphicsDevice.RasterizerState = stat;
// Draw Silverlight UI element to Texture
elementRenderer.Render();
// Draw Silverlight UI element
spriteBatch.Begin();
spriteBatch.Draw(elementRenderer.Texture, Vector2.Zero, Microsoft.Xna.Framework.Color.White);
spriteBatch.End();
effect.Texture = tex;
effect.TextureEnabled = true;
effect.World = BillboardMatrix;
effect.View = view;
effect.Projection = projection;
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Apply();
graphicsDevice.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleStrip, vertices, 0, 2);
}
}
If I try to draw the spriteBatch after the Triangles I get this error: "NotSupportedException - XNA Framework Reach profile requires TextureAddressMode to be Clamp when using texture sizes that are not powers of two."
private void OnDraw(object sender, GameTimerEventArgs e)
{
// Clean up device
graphicsDevice.Clear(Microsoft.Xna.Framework.Color.Black);
graphicsDevice.BlendState = BlendState.AlphaBlend;
RasterizerState stat = new RasterizerState();
stat.CullMode = CullMode.None;
graphicsDevice.RasterizerState = stat;
// Draw Silverlight UI element to Texture
elementRenderer.Render();
effect.Texture = tex;
effect.TextureEnabled = true;
effect.World = BillboardMatrix;
effect.View = view;
effect.Projection = projection;
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Apply();
graphicsDevice.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleStrip, vertices, 0, 2);
}
// Draw Silverlight UI element
spriteBatch.Begin();
spriteBatch.Draw(elementRenderer.Texture, Vector2.Zero, Microsoft.Xna.Framework.Color.White);
spriteBatch.End();
}
I also tried to set graphicsDevice.SamplerStates[i] = SamplerState.LinearClamp;
but it didn't work. What am I doing wrong?