GLUTMOUSEFUNC(3)

πŸ“¦
version 3.8.0 Β· 2 versions
, in centos-stream 10, centos-stream 9, fedora 43, fedora 44, opensuse-leap 16.0

✨ GLUTMOUSEFUNC(3) ✨

okay bestie, so this is a page from the OpenGLUT manual β€” specifically the input section of the OpenGLUT library. It's literally all about one little function that tells your window "hey, when somebody clicks, here's who to call." πŸ’–


πŸŽ€ NAME πŸŽ€

glutMouseFunc β€” sets the mouse-button callback for the current window.

πŸ“š LIBRARY πŸ“š

OpenGLUT β€” the input girlies section πŸ’…

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <openglut.h>

void
glutMouseFunc(void( *callback )( int button, int state, int x, int y ));

🌸 PARAMETERS 🌸

  • callback β€” your lil client hook for mouse-buttons. This is the function that gets called when stuff happens. It's giving "you handle this, bestie" energy.

πŸ‘‘ DESCRIPTION πŸ‘‘

So here's the tea: whenever a mouse button gets pressed or released inside an OpenGLUT window, OpenGLUT is like "wait, does this window have a mouse-button (Mouse) callback registered?" And if the answer is yes, it hands the whole event over to your handler. No cap.

  • button is the button number, and it starts counting from 0. Zero-based, iconic, we love a consistent index. πŸ”₯
  • state is either GLUT_UP or GLUT_DOWN β€” it tells you the button's new state, like a vibe check for the click.
  • the other parameters are literally just the mouse coordinates.

Mouse wheel motion can get reported as buttons too. And if you don't request otherwise, a wheel spun forward will act like a button clicking down, immediately followed by clicking up β€” like a lil tap tap. 🫢 Spinning that same wheel backward will act like a different button clicking. And the mouse wheel pseudo-buttons get added after all the real buttons, so they're always at the end of the lineup, periodt.

While the button is held and the mouse is dragged, you receive mouse-motion events (glutMotionFunc()), even if the mouse is dragged out of the window. Yeah, it tracks you across the whole screen, main character energy fr fr.

This callback is bound to the current window. πŸ’–

πŸ’€ CAVEATS πŸ’€

Reporting the wheel as buttons is actually inherited from X. freeglut added code to support this on WIN32. OpenGLUT inherited that support from freeglut. So it's a whole family tree situation, iykyk. 🌈

Old GLUT defines the symbols GLUT_LEFT_BUTTON, GLUT_RIGHT_BUTTON, and GLUT_MIDDLE_BUTTON. However β€” and this is important bestie β€” mice can have more than 3 buttons, so these symbols are deprecated. Like, don't build your whole personality on them. 😭

Windows created via glutCreateMenuWindow() always cascade keyboard and mouse events to their parent. Always. No exceptions, that's just how they move. ✨

πŸ” SEE ALSO πŸ”


and that's the whole page, bestie!! this one's marked UNDATED and it lives in the UNTITLED() corner of the manual β€” so like, no date, no title, just vibes and a mouse callback. go slay some click events πŸ’…βœ¨πŸŽ€πŸ¦‹