The code works with GLUT_ACTIVE_ALT but not with CTRL or any other
special key... When I ouput the result of glutGetModifiers I get a
value only with the Alt key is used... The code is compiled under
linux. Any idea ? Thank you
else if ( key == 's' )
{
int mod = glutGetModifiers();
if ( mod == GLUT_ACTIVE_ALT ) // GLUT_ACTICE_CTRL doesn't work !?
{
sis->m_pointSize = std::max( 1.0, sis->m_pointSize - 1.0 );
}
else
{
sis->m_pointSize += 1.0;
}
}
> if ( mod == GLUT_ACTIVE_ALT ) // GLUT_ACTICE_CTRL doesn't work !?
This is the error. You should test modifiers using 'bitwise and', i.e.
if (mod & GLUT_ACTIVE_ALT) {
// do something
}
if (mod & GLUT_ACTIVE_CTRL) {
// do something else
}
best regards,
Gordan
I wouldn't consider the original code to be in error, though the
alternative you have suggested is useful, particularly if more than two
modifier keys are depressed at the same time.
The original code should work and I suspect there's a bug in the
implementation of GLUT that you are using. I vaguely remember a similar
problem with glutGetModifiers I had with some code I wrote many years
ago. This was using the original GLUT (Windows version) which I've since
abandoned in favour of openglut. You may want to take a look at an
alternative GLUT implementation -- if there's a Linux version.
John Irwin.