1

I am trying to make a grid with OpenGL ES 2.0 for Android. What I am trying to understand is whether extra vertices use more memory even if they're not drawn on the screen. For example, I am drawing a line which is three times longer than visible area. I am using this Line class - https://stackoverflow.com/a/16223456/1621987.

mLine = new Line();
mLine.setVertices(0f, -10f, 0f, 0f, 10f, 0f);
...
GLES20.glDrawArrays(GLES20.GL_LINES, 0, vertexCount);

Is it efficient to do it performance and memory wise?

Community
  • 1
  • 1
  • 1
    Not exactly the same question, but this is similar to http://stackoverflow.com/questions/23186192/texture-partially-off-screen-performance-difference. – Reto Koradi Jul 11 '15 at 21:51

1 Answers1

1

Lines that are too long for their vertices to be seen, but are still partially visible, will be clipped to the window, that is, their ends will be clipped away if they're out of sight. Lines totally outside the window will be culled and not sent to the rasterizer to be drawn at all. For OpenGL to determine this, though, each line must be sent to the graphics pipeline. (Of course, it's also possible to omit such lines to keep them from being drawn, if your code determines beforehand that they won't be seen.)

Thus, this is not so much a matter of using less memory as it is of eliminating unnecessary work.

Peter O.
  • 32,158
  • 14
  • 82
  • 96