Why does a triangle have 6 vertices?

I’m drawing learning a bit of LWJGL and I’ve made it up to the point where I draw a triangle with a FloatBuffer. The tutorial sets up the triangle’s vertices like this:


vertices.put(new float[] {
	+0.0f, +0.8f,    // Top Vertex
	+0.8f, -0.8f,    // Bottom-right vertex
	-0.8f, -0.8f     // Bottom-left vertex
});

If IRL math a triangle only has three vertices, why do they have 6 in LWJGL?

An x and a y coordinate…

dont forget z coordinate, i think ;D

Which one would be the X,Y,Z coord? The first number or the second?

You’re drunk Jacob, go home. Don’t know if you’re trolling or what.

If you’re not, each of those pairs are an x and a y coordinate.


{ x1, y1,
  x2, y2,
  x3, y3 }

No z coord as long as its 2D…
It’s xy xy xy.

EDIT: Slyth.

The key to OpenGL is that it doesn’t know what your vertices are part of. You have to tell it.

If you say it’s a triangle with 2-dimensional points, the vertices will be (0, 0.8), (0.8, -0.8), and (-0.8, -0.8).

If you take the same data and say it’s a line with 3-dimensional points, it will be from (0, 0.8, 0.8) to (-0.8, -0.8, -0.8).

Edit: Note to self: Disable smileys when you have an 8 followed by a parenthesis.

Following what Slyth said, visualize it like this:


vertices.put(new float[] {
    (+0.0f, +0.8f), <- 1st with X/Y coords
    (+0.8f, -0.8f), <- 2nd with X/Y coords
    (-0.8f, -0.8f) <- 3rd with X/Y coords
});

You have 3 vertices, so each individual vertex will have its own X and Y coordinates. That’s why you’re passing in 6 values.

  • Jev

Wow, I feel a bit dumb now. Haha I’ve been programming all night perhaps it’s time to take a nap. :stuck_out_tongue: Thanks for letting me know. Haha

goodnight. :wink:

I prefer something to look at, so here’s my basic diagram of this subject.

For starters, here’s an ASCII triangle.
.
/
.___.

Each vertex (which I represented with a period) has x and y values. Since there are 3 vertices in a triangle, there are 6 x and y coordinates. Here’s what the triangle would look like on grid paper:

Make sense?