I want to create a triangle using three different points on the SurfaceView using OpenGL. Line indications between the points with one color and fill the triangle with different color. I want to pull those points from existing place to the user desired positions (where ever he wants) on the surface.

How can I do this?

  • 2
    \$\begingroup\$ You need to tell us what you've tried already and why it doesn't work. You have to give us some starting point to work with. Help us help you. \$\endgroup\$
    – House
    Commented Jul 3, 2012 at 13:30

2 Answers 2


I recommend you to start with this tutorial and it's next parts.

Steps for your apps:

  1. update positions of points
  2. render triangle between these points - set fill color
  3. render lines between these points - set line color and width
  4. render touch points or circles - set point size and color

Tutorials that might help you with OpenGL ES 2:

That's all to your question: How to draw lines between user draggable points?

If you want to know how to drag points ask another question like How to drag points? [tags: android, input].


Without any previous research done, I can only provide a basic guideline:

  1. Verify if the mouse click is on a point.
  2. Verify mouse position while mouse button is pressed.
  3. Draw line at every rendering based on mouse position while mouse button is pressed.
  4. When mouse is released, stop listening to mouse position and store new point position.

Hope this helps!

  • \$\begingroup\$ It's Android, so there's no mouse. Additionally, while accurate, this is so high level it's unlikely to be useful. \$\endgroup\$
    – House
    Commented Jul 3, 2012 at 15:17
  • 1
    \$\begingroup\$ Mouse and touch are pretty much the same in this case. \$\endgroup\$
    – Luke B.
    Commented Jul 12, 2012 at 21:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .