Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

can't get GLUT_ACTIVE_CTRL to work on linux ?

197 views
Skip to first unread message

mas...@yahoo.com

unread,
Aug 7, 2006, 2:03:06 AM8/7/06
to
Hi guys

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;
}
}

Leclerc

unread,
Aug 7, 2006, 4:06:04 AM8/7/06
to

> 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

John Irwin

unread,
Aug 7, 2006, 12:51:46 PM8/7/06
to

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.

mas...@yahoo.com

unread,
Aug 7, 2006, 6:42:52 PM8/7/06
to
Thanks a lot John...
That seems to be it indeed, I'll try to use another version or use
something else to catch key events.
cheers, mark
0 new messages