Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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. – Byte56 Jul 3 '12 at 13:30

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].

share|improve this answer

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!

share|improve this answer
It's Android, so there's no mouse. Additionally, while accurate, this is so high level it's unlikely to be useful. – Byte56 Jul 3 '12 at 15:17
Mouse and touch are pretty much the same in this case. – Luke B. Jul 12 '12 at 21:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.