Originally Posted by
Master674
Doesn't work at all for me. stuff is behind everything.
Care to explain how you did this exactly ?
Edit: Actually it's not really behind everything but draws as if the Near / FarClip values would be incorrect when they aren't.
Edit2: Viewport MaxZ is different in EndScene than in the function I used to draw in, fixed it. Problem is it overlaps Interface :C
Code:
Device.SetTransform(TransformState.World, Matrix.Translation(myPos.X, myPos.Y, myPos.Z));
ColoredVertex[] triangleVerts = new[]
{
new ColoredVertex(new Vector3(0f, 0f, 5f), Color.Red.ToArgb()),
new ColoredVertex(new Vector3(5f, -5f, 0f), Color.Blue.ToArgb()),
new ColoredVertex(new Vector3(-5f, 5f, 0f), Color.Green.ToArgb())
};
var vp = Device.Viewport;
vp.MinZ = 0f;
vp.MaxZ = 0.94f;
Device.Viewport = vp;
var oldDecl = Device.VertexDeclaration;
Device.VertexDeclaration = ColoredVertex.GetDecl(Device);
Device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, triangleVerts);
Device.VertexDeclaration = oldDecl;
This is being called from EndScene.
Code:
Device.SetTransform(TransformState.View, View);
Device.SetTransform(TransformState.Projection, Projection);
Device.SetTransform(TransformState.World, Matrix.Identity);
Device.VertexShader = null;
Device.PixelShader = null;
//// Required to enabled 3D drawing
Device.SetRenderState(RenderState.ColorWriteEnable, ColorWriteEnable.All);
//// Lighting / Alpha Stuff
Device.SetRenderState(RenderState.Lighting, false);
Device.SetRenderState(RenderState.CullMode, Cull.None);
Device.SetRenderState(RenderState.AlphaBlendEnable, true);
Device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha);
Device.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
// Depth
Device.SetRenderState(RenderState.ZEnable, true);
Device.SetRenderState(RenderState.ZWriteEnable, true);
Device.SetRenderState(RenderState.ZFunc, Compare.LessEqual);
Device.SetTextureStageState(0, TextureStage.ColorOperation, TextureOperation.Disable);
Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Disable);
Device.SetTextureStageState(0, TextureStage.ColorArg2, TextureArgument.Texture);