Jump to content
  • Advertisement
Sign in to follow this  
nickme

opengl: how to detect double click?

This topic is 2502 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement

No - OpenGL is for graphics only, not input.

Perhaps you mean GLUT or something similar instead?


yes, i meant glut

thanks

Share this post


Link to post
Share on other sites

GLUT doesn't provide double click detection out of the box. You need to manually time single clicks to detect a double click. This is another thread discussing this idea.


hi,
thanks for the reply. i wonder can i get the coordinate (window x & y values) where the double clicks occurred? i need that info for my program to work.
thanks

Share this post


Link to post
Share on other sites
hi,

how do i differentiate a single click and a double click?

let's see my subroutine for handling mouse click:

void mouseButton(int button, int state, int x, int y) {
switch (button) {
case GLUT_LEFT_BUTTON:
if (state == GLUT_UP) {
xpos = W[C].l+(GLdouble)x*deltax-0.5*swx_size,
ypos = W[C].t-(GLdouble)y*deltay-0.5*swy_size;
move_cursor();
}
break;
default:
break;}
}

i am complete lost in implementing glutTimerFunc(). i am still looking at other's tutorials. i only want to execute move_cursor() when there is a single click and execute Zoom_in() when it is a double click. where should i place glutTimerFunc()? before move_cursor()?

thanks

Share this post


Link to post
Share on other sites
Generally speaking, a "single click" event will always be fired off before the "double click" event. In Actionscript 3, a double click causes two events to be fired, what you need to do is code in such away that the action being done on the single click even naturally flows into the double click event. For example, single clicking a unit may select that particular one but double click it will select all units of that type. The flow works naturally as the first click event will select it and then the double click event will notice that the unit is selected and then search the rest of the game world for units of the same type to select.

Share this post


Link to post
Share on other sites
hi,

another related problem. when i pressed an arrow key, the response was almost immediate, but when i click the mouse button, there was a delay. is it my applicaton or glut's problem?

i still working on the double click. i will post when something happened.

thanks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!