student
student

Reputation:

draw by mouse in openGL

How do you draw a polygon by mouse with openGL in C++?

Upvotes: 2

Views: 2411

Answers (3)

Rolf Rander
Rolf Rander

Reputation: 3321

Assuming this is homework, and that you want to try to figure this out for yourself before looking at someone else's solution, take a moment to think about:

  • How do you know when the user push a button?
  • What are the mouse coordinates at that time?
  • How do you translate the mouse coordinates to the world coordinates of your GL-model?
  • How do you figure out which vertex to move? (or add)
  • How do you move the vertex?
  • How do you redraw?
  • What is the connection between model and view?

Upvotes: 5

Marc Charbonneau
Marc Charbonneau

Reputation: 40507

Start by conditioning the mouse to recognize the shape of a polygon and be able to complete one it sees on a computer screen. You can use operant conditioning (by rewarding the mouse with a food pellet) to train it to an acceptable level of proficiency.

Upvotes: 12

mmr
mmr

Reputation: 14919

Maybe go to class, pay attention, and learn what the teacher says? Or look at the NeHe tutorials, which you can find through five minutes of using the almighty Google?

Upvotes: 4

Related Questions