Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am fairly new to using Quads, so I'm not sure how I can properly describe this issue in all honesty or to even hazard a guess as to why it's happening, so I have a screenshot to illustrate. image of red and while lines, with a white dotted line connecting two

So the white lines are actually Quads, the Red lines are just rectangles. So if you can see the issue, for some reason every "now & again" I will get this issue were I get this somewhat looking "dotted line" which will sometimes be a full end-to-end line.

I'm not too sure what's causing this issue, I have a feeling it has something to-do with the way I'm drawing the quads, I don't think it's an incorrect vertices purely because the because of the thickness of the line, this leads me to believe it's the rendering;

effect.CurrentTechnique.Passes[0].Apply();
device.DrawUserPrimitives<VertexPositionColorTexture>(PrimitiveType.TriangleStrip, vertices, 0, totalNumberOfQuads);

This is the order I'm adding the vertices:

  1. Top Left Segment Corner
  2. Top Right Segment Corner
  3. Bottom Left Segment Corner
  4. Bottom Right Segment Corner

Edit: So after getting the vertices in the correct order, things are now even stranger, as this is an image of the current out-put;

enter image description here

Here's my Current Code, including the rendering: http://pastebin.com/yK5yBZy0

share|improve this question
    
I think you made a typo when saying the red lines were just rectangles, I assume you mean triangles? Since rectangles are quads. (but not all quads are rectangles!) –  Byte56 Apr 16 '12 at 16:28
    
No, i use a 2D "DrawLine" function via SpriteBatch to draw those, just for a debug purpose to see what the issue was. –  dan369 Apr 16 '12 at 16:38
    
If you pack the vertices for quads, then draw them like triangles, you're going to have a bad time. –  Byte56 Apr 16 '12 at 18:22
    
gotcha - dl.dropbox.com/u/13874083/screenshots/screen120416-193701.png. Well thanks for your help :), i did actually in the end up using the TriangleLists using the clockwise winding on the indices. :D. Thanks again –  dan369 Apr 16 '12 at 18:38

1 Answer 1

up vote 3 down vote accepted

Keep in mind that the order you insert your vertices into your array matters too. Additionally, it looks like you're drawing a PrimitiveType.TriangleStrip, not quads. It looks like XNA doesn't have a primitive type for quads. You can index them yourself though, as seen in this tutorial..

If you're using triangles (or quads) to draw lines like your image shows, you can have the issue you're experiencing by essentially having a line that has zero height, or close to zero. I imagine this could happen if you're arranging your vertices for quads but then drawing them as triangle strips. So either use the tutorial I mentioned above, or use triangle strips like in this tutorial.

EDIT

The vertices for quads (and triangles) should be defined in clockwise order. Your order is wrong for quads. image of triangle with clockwise arrow

You should swap the last two with each other OR the first two with each other, if you want clockwise order. Ensure that you also look at the tutorial I linked. It will describe the proper way to draw the quads.

share|improve this answer
    
Well this is how i am arranging the vertices, from the Top-Left first, then to the Top Right & Then the bottom 2. Like so - pastebin.com/vthKVgKY And yes, it seems so, looking at the vertices, and some of the distance between them is small. –  dan369 Apr 16 '12 at 16:09
    
Well, i've changed the order of the vertices as you can see here and have the defined my own indexes to use when drawing, as so; pastebin.com/yK5yBZy0. But here's the output: dl.dropbox.com/u/13874083/screenshots/screen120416-174023.png. –  dan369 Apr 16 '12 at 16:38
    
As for drawing with TriangleLists, that looked even worse. So i'd like to stick with using TriangleSTripes if that's at all possible. You can see in the image it still resembles the sorta output i'd like. But i get that "tearing" like effect :/ –  dan369 Apr 16 '12 at 16:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.