Hi, i have a problem when using GL_LINE_STRIP that causes the line strips not to fill in all the way and leave gaps
Here is a picture of what this graph should look like (using the old version of the program before switching to JOGL):
http://amath.colorado.edu/jjj/MVT_good.jpg
But this is what it looks like using JOGL. You can kind of see how there are little gaps in the line, and there shouldn’t be.
http://amath.colorado.edu/jjj/MVT_bad.jpg
the code that creates this in JOGL is shown below:
public void display(GLAutoDrawable gld) {
GL gl = gld.getGL();
setCamera(gl);
gl.glViewport(10,10,getWidth()-20,getHeight()-20);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );
gl.glEnable(GL.GL_POLYGON_SMOOTH);
glDraw(gl);
} // display()
public void glDraw(GL gl) {
for(int i=0;i<graphicsList.size();i++)
if(graphicsList.getGraphicsObject(i) != null)
graphicsList.getGraphicsObject(i).glDraw(gl);
}
and then the glDraw method of the class that draws the line (one of the graphicsObjects in the graphicsList) is shown here:
public void glDraw(GL gl) {
super.glDraw(gl);
System.out.println("Line2D");
float red = lineColor.getRed()/256f;
float green = lineColor.getGreen()/256f;
float blue = lineColor.getBlue()/256f;
gl.glColor3f(red,green,blue);
gl.glBegin(GL.GL_LINE_STRIP);
gl.glVertex2d(data[0].getX(),data[0].getY());
for (int i=1; i< data.length; i++) {
if(!undefined(data[i], data[i-1]) && !coversAsymptote(asymptotes, data[i], data[i-1]))
gl.glVertex2d(data[i].getX(),data[i].getY());
else {
gl.glEnd();
gl.glBegin(GL.GL_LINE_STRIP);
}
}
gl.glEnd();
}
data here is an array of points, and the coversAsymptote method just checks to make sure the graph doesn’t have an asymptote (so it doesn’t try to draw them… this graph doesn’t have an asymptote so the else clause of the if statement is never called here, you might as well ignore it for purposes of this example)
You might ask why i’m using JOGL then to try and get the graphics working back like they already used to work… the answer is 3D of course JOGL will be much faster and better and easier than the way we currently do it (our own 3D graphics engine just using AWT) but right now we’ve gotta get our 2D stuff working too.
any help or advice is appreciated