DanUK

11-21-2011, 09:42 AM

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:

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

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:

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