rosjava / android_core

Android libraries for rosjava
145 stars 166 forks source link

GL_LINE_STRIP instead of GL_LINES inside drawLines() method? #305

Closed stringnotfound1 closed 5 years ago

stringnotfound1 commented 5 years ago

I think it would make sense to use GL_LINE_STRIP as the draw mode inside the drawLines() method of Vertices. Short explanation: GL_LINES only draws a line between every two vertices while GL_LINE_STRIP draws a line between every specified vertex. Link to documentation.

I've attached two pictures to show a comparison:

GL_LINES: lines

GL_LINE_STRIP: line_strip

gxshao commented 5 years ago

Could you please share the code about this continuous line?thank you

stringnotfound1 commented 5 years ago

I only changed one line inside the drawLines method that can be found inside the Vertices class :

 public static void drawLines(GL10 gl, FloatBuffer vertices, Color color, float width) {
    vertices.mark();
    color.apply(gl);
    gl.glLineWidth(width);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertices);
    // GL_LINE_STRIP instead of GL_LINES
    gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, countVertices(vertices, 3)); 
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    vertices.reset();
  }

Does that answer your question?

gxshao commented 5 years ago

absolutely bro.. thanks a lot.

jubeira commented 5 years ago

Thanks @stringnotfound1, closed in #307.