Certain grid lines not rendering as expected
Posted
by
row1
on Game Development
See other posts from Game Development
or by row1
Published on 2013-07-01T12:41:44Z
Indexed on
2013/07/01
16:31 UTC
Read the original article
Hit count: 202
xna-4.0
|windows-phone-7
I am drawing a simple quad (a triangle strip with 4 vertices) as the floor and then drawing an 8x8 grid over top (a collection of vertex pairs for a line list). The vertical grid lines work fine (apart from being very aliased), but some of the horizontal lines do not get rendered. The grid renders fine if I do not draw the quad.
foreach (EffectPass pass in _Effect.CurrentTechnique.Passes)
{
pass.Apply();
CurrentGraphicsDevice.SetVertexBuffer(_VertexFloorBuffer);
_Engine.CurrentGraphicsDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
//Some of the horizontal lines seems to disappear if we draw the above quad.
CurrentGraphicsDevice.SetVertexBuffer(_VertexGridBuffer);
CurrentGraphicsDevice.DrawPrimitives(PrimitiveType.LineList, 0, _VertexGridBuffer.VertexCount / 2);
}
What could be causing these lines to not be rendered?
Update: I added the below code after I draw my quad and grid and it started working. But I am not sure why that works as I thought this code was to draw the WPF controls
elementRenderer.Render();
spriteBatch.Begin();
spriteBatch.Draw(elementRenderer.Texture, Vector2.Zero, Color.White);
spriteBatch.End();
© Game Development or respective owner