How to track multi-touch using FreeGLUT or GLUT?

Viewed 60

I'm trying to track multi-touch in FreeGLUT

When I just tracked one point, I used glutMouseFunc().

I heard that I cannot track many mice in GLUT, and in FreeGLUT I can.

So here are my questions:

  1. How can I track multiple touches in FreeGLUT?

  2. Could you show me some examples or explain the process?

1 Answers

Use the glutMulti*Func() callback setters:

// glutEntryFunc()
void glutMultiEntryFunc( void (* callback)( int, int ) );

// glutMouseFunc()
void glutMultiButtonFunc( void (* callback)( int, int, int, int, int ) );

// glutMotionFunc()
void glutMultiMotionFunc( void (* callback)( int, int, int ) );

// glutPassiveMotionFunc()
void glutMultiPassiveFunc( void (* callback)( int, int, int ) );

Documentation (doc source):

These functions work like their non-multi variants, with an additional 'deviceid' parameter describing the current input device (mouse or finger).

Exception: in MultiButtonFunc, the order of callback parameters is different (x,y,button,state instead of button,state,x,y).

Currently, under X11, the non-multi callback variants are also called on X11 for each event.

Currently, under windows, the first (oldest) touch point also controls the mouse cursor, which triggers the non-multi callbacks as usual.

All these functions have user-data callback functions.

The FreeGLUT Git repository has a multi-touch demo.

Related