How to make basic line segments in LWJGL/OpenGL

jumps4fun picture jumps4fun · Feb 11, 2012 · Viewed 7.4k times · Source

I am in the process of learning LWJGL and also OpenGL. I have done the tutorials on quads, and also succesfully drawn polygons on a display. I am trying to draw lines using the same methods, but the lines are not created, or they are made invisible, possibly with a pixel width of 0? I have googled for an answer or a tutorial, but so far all of them seems to claim that I am doing the right thing. my method is as follows:

private void drawLine(Point point, Joint Point2) {
    GL11.glColor3f(0.0f, 1.0f, 0.2f);
    GL11.glBegin(GL11.GL_LINE);

    GL11.glVertex2d(point.getX(), point.getY());
    GL11.glVertex2d(point2.getX(), point2.getY());
    GL11.glEnd();
}

I also tried to put this one in the middle, but no effect.

GL11.glLineWidth(3.8f);

Answer

jumps4fun picture jumps4fun · Mar 17, 2014

As stated in the comments, The answer was that GL11.GL_LINE is not accepted as a constant in this case. GL11.LINE_STRIP however works like a charm.