Support for SpaceNavigator in OpenGLUT and FreeGLUT

Questions and answers about 3Dconnexion devices on UNIX and Linux.

Moderator: Moderators

Post Reply
mfalda
Posts: 4
Joined: Sat Mar 28, 2009 9:31 am

Support for SpaceNavigator in OpenGLUT and FreeGLUT

Post by mfalda »

I have added the support for SpaceNavigator in Linux OpenGLUT and FreeGLUT (see the Windows counterpart of this forum for the Windows version). You can find the precompiled libraries here:
I have sent the code to the FreeGLUT developers, in the hope that they will include it in future versions and they will add OSX support.

In practice, I have implemented two call-backs that were void in the original libraries:

Code: Select all

void glutSpaceballButtonFunc(int button, int state);
and

Code: Select all

void glutSpaceballMotionFunc(int tx, int ty, int tz, int rx, int ry, int rz);
In this way, you can write an application using a code as simple as:

Code: Select all

#include <GL> 
#include <stdio> 

void sbButton(int button, int state) 
{ 
   printf("%d, %d\n", button, state); 
} 

void sbMotion(int tx, int ty, int tz, int rx, int ry, int rz) 
{ 
   printf("%d, %d, %d, %d, %d, %d\n", tx, ty, tz, rx, ry, rz); 
} 

int main(int argc, char** argv) 
{ 
   glutInit(&argc, argv); 
   glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); 
   glutInitWindowSize (500, 500); 
   glutInitWindowPosition (100, 100); 
   glutCreateWindow (argv[0]); 
   glutSpaceballButtonFunc (sbButton); 
   glutSpaceballMotionFunc (sbMotion); 
   glutMainLoop(); 
   return 0; 
}
Bryan
Moderator
Moderator
Posts: 443
Joined: Thu Dec 07, 2006 1:37 pm
Location: Rochester NY

Support for SpaceNavigator in OpenGLUT and FreeGLUT

Post by Bryan »

Dear mfalda,

Thank you for your contribution to the Open Source community. It's great to see people contribute like this.

Sincerely,
Bryan
Post Reply