Support for SpaceNavigator in OpenGLUT and FreeGLUT

Questions and answers about 3Dconnexion devices on UNIX/Linux

Moderator: Moderators

Support for SpaceNavigator in OpenGLUT and FreeGLUT

Postby mfalda » Fri Aug 14, 2009 11:38 am

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;
}
mfalda
 
Posts: 4
Joined: Sat Mar 28, 2009 9:31 am

Support for SpaceNavigator in OpenGLUT and FreeGLUT

Postby Bryan » Thu Aug 20, 2009 3:35 pm

Dear mfalda,

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

Sincerely,
Bryan
Bryan
Moderator
Moderator
 
Posts: 429
Joined: Thu Dec 07, 2006 1:37 pm
Location: Rochester NY


Return to UNIX and Linux Discussion Forum

Who is online

Users browsing this forum: No registered users and 0 guests