# The Industry's Foundation for High Performance Graphics

1. ## understanding GL_LINES

Hi,

Im having some troble figuring out why I cant seem to draw triangles with GL_LINES, I feel as though I am very close with the code below:

Code :
```void DrawWireframe()
{
int i = 0;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_LINES);
glColor3f(1.0, 1.0, 0.0);
//for (int i = 0; i < nbTriangles; i++)
//{
glVertex3f(vertices[triangles[i*3]*3], vertices[triangles[i*3]*3+1], vertices[triangles[i*3]*3+2]);
glVertex3f(vertices[triangles[i+1*3]*3], vertices[triangles[i+1*3]*3+1], vertices[triangles[i+1*3]*3+2]);
glVertex3f(vertices[triangles[i+2*3]*3], vertices[triangles[i+2*3]*3+1], vertices[triangles[i+2*3]*3+2]);
glVertex3f(vertices[triangles[i*3]*3], vertices[triangles[i*3]*3+1], vertices[triangles[i*3]*3+2]);
//}
glEnd();
}```

Im trying to draw the wire frame of the standford bunny from its .ply format. The triangles array contains the index for the vertex of each each triangle, and vertices contains the vertexs. I've commented out the loop to try and draw one triangle, as far as I can see im drawing unique pairs for each vertices, can anyone explain to me why this is wrong and only draws 2 lines?

thanks

2. ## Re: understanding GL_LINES

glVertex3f(vertices[triangles[i+1*3]*3],
Who knows what you have in your vertices[triangles] arrays?
Are you sure you should be indexing them in that way though...
i+1*3 --> should this be (i*3)+1

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•