user4586864
user4586864

Reputation: 29

detect mouse clicks in OpenGL in C

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.

Upvotes: 0

Views: 930

Answers (2)

CroCo
CroCo

Reputation: 5741

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

}

Upvotes: 1

Danil Prokhorenko
Danil Prokhorenko

Reputation: 1104

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.

Upvotes: 0

Related Questions