Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Making lines in opengl

  1. #1

    Making lines in opengl

    How do I make just single lines in opengl?
    I thought of making a sort wired plane with lines. like this (psuedo code):
    for(0;i<=20;i++)
    {
    glBegin(GL_<???> ); //lines?
    glVertex3f(0, i, 0);
    glEnd();
    }

    Or how to do it? thanks.
    regards Nergal

  2. #2

    Re: Making lines in opengl

    Lines are made up of 2 vertex points so something like the following would be more like it...

    to draw a single line...
    glBegin(GL_LINES);
    glVertex3f(x1,y1,z1); glVertex3f(x2,y2,z2);
    glEnd();

    to draw multiple lines...
    glBegin(GL_LINES);
    for (i=0;i<maxi;i++)
    {
    glVertex3f(x1[i],y1[i],z1[i]);
    glVertex3f(x2[i],y2[i],z2[i]);
    }
    glEnd();

    Hope that helps you in some way

    Tina
    Learning OpenGL while working on sourceforge projects:
    https://sourceforge.net/projects/simulant/ and
    https://sourceforge.net/projects/projectnova/

  3. #3
    Guest

    Re: Making lines in opengl

    Use GL_LINE_LOOP if you want to make wireframe polygons.

Posting Permissions

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