What is the best approach for drawing a Line with a specific texture?
Right now I’m attempting to draw a Line with a texture by simply drawing lines instead of another Primitive.
setupMandatoryHandlers(shader);
GLES20.glEnableVertexAttribArray(positionHandler);
GLES20.glVertexAttribPointer(positionHandler, COORDS, GLES20.GL_FLOAT, false, STRIDE, vertexBuffer);
if (texture != null)
setupTextureData();
GLES20.glUniform4fv(colorHandler, 1, color, 0);
GLES20.glUniformMatrix4fv(MVPMatrixHandle, 1, false, orthoMatrix, 0);
GLES20.glDrawElements(drawType, indices.length, GLES20.GL_UNSIGNED_SHORT, indexBuffer);
GLRenderer.CheckGLError("Draw Elements");
GLES20.glDisableVertexAttribArray(positionHandler);
if (texture != null)
GLES20.glDisableVertexAttribArray(texCoordHandler);
Is this the most efficient way of drawing lines with textures or should I be looking somewhere else? Should I use glDrawArrays instead of glDrawElements for lines?
To draw a texture on a line you either have to use
PointSpritesor draw small textured Quads. In my case I usedTriangle_Stripsand textured those because the line in my case could be small and still look exactly like a line.If anyone has a better solution or has implemented the above feel free to post an answer!