0

Is there any way that I can detect mouse click position by not using glutMouseFunc()?

All examples that I found online getting mouse click by using glutMouseFunc(). However, I don't want the detect mouse click function always active. I want to record the mouse click position only after user selects a certain option in the menu. To be exact, I want to record 4 mouse click positions, after user selects an option in the menu.

  • 3
    Write the condition you wanted into`glutMouseFunc`. FYI there is no real computational cost to `glutMouseFunc`. – Mikhail Oct 24 '15 at 16:22

2 Answers2

1

First of all, OpenGL has nothing to do with the mouse callback. It is Graphics library. For your ultimate goal, basically as @Mikhail suggested, you insert a conditional statement inside your glutMouseFunc, therefore,

void mouse_callback(){

if ( command_seleteced == true )
   store mouse position

}
CroCo
  • 5,531
  • 9
  • 56
  • 88
0

I read documentation about glutMouseFunc() here. If you want handle mouse event with 4 different function in the different time you can call glutMouseFunc with NULL and then call glutMouseFunc with another function. From documentation:

Passing NULL to glutMouseFunc disables the generation of mouse callbacks.

If you want handle different mouse event in the same time then you must write one function with all these conditions.

Danil Prokhorenko
  • 1,052
  • 1
  • 10
  • 26