Results 1 to 2 of 2

Thread: understanding GL_LINES

  1. #1
    DanUK
    Guest

    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. #2
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,161

    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

Similar Threads

  1. glDrawArrays(GL_LINES)
    By jonpb1 in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 12-17-2012, 08:00 PM
  2. GL_LINES on different positions
    By Thomas Alton in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 12-22-2011, 01:17 PM
  3. GL_LINES looks weird
    By Troxtril in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 10-01-2008, 07:19 AM
  4. GL_LINES
    By Luca in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 10-06-2002, 09:18 AM
  5. GL_LINES
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-30-2001, 07:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean