0

I've to draw squre using a lines, which will look like as following url.

http://www.thinkingwriting.qmul.ac.uk/wishees/tutorials/square.gif

Could you please tell me how to draw it in android using opengls GL_LINES or GL_LINES_STRIP

andr
  • 15,970
  • 10
  • 45
  • 59
Vishwanath Deshmukh
  • 619
  • 1
  • 10
  • 32

1 Answers1

3

This is fairly simple, assuming you already have a working OpenGL context:

  • Set up an orthogonal projection
  • Build a vertex buffer containing the vertices of your square
  • When it comes time to render, set line rendering attributes (e.g. glLineWidth)
  • Render the vertex buffer using GL_LINE_LOOP or GL_LINES (depending how you set up your vertices)

Take a look at this introduction to vertex buffers to get an idea of where to start. There are some much simpler tutorials but this one offers more background than most.

ravuya
  • 8,586
  • 4
  • 30
  • 33