This is the basic problem, that I can only test whether the Ctrl key is or isn't pressed when another key is pressed and thus fires the keyboard callback. So, is there a way to detect key up and key down events on the Ctrl key (without any other keys being typed) in a platform independent GLUT-ish way?ĮDIT: The keyboard callback is not fired (at least for a default setup) when the Ctrl key is pressed. When receiving an event through your keyup callback, set keystates key false. When receiving an event through your keydown callback, set keystates key true. Create a bool keystates 256 array to store the state of the keyboard keys. When a new window is created, no special callback is initially registered and special key strokes in the Passing NULLto glutSpecialFuncdisables the generation of special callbacks. E.g. The xand ycallback parameters indicate the mouse in window relative coordinates when the key was pressed. Note: In KeyDown/KeyUp messages, the virtual key code must be passed (that is, a VK constant), while in xx(SYS)CHAR messages the ASCII character (or the UTF8 character for IntfUTF8KeyPress) must be sent. The ability to move the paddle left and right Pressed buttons can be defined and initialized with boolean variables like in the example. is a GLUTKEY constant for the special key pressed. I need to know whether or not the Ctrl key is pressed at a point in my main loop, but GLUT_ACTIVE_CTRL doesn't seem to work in this context. Use glutKeyboardUpFunc to register a callback listening to keyup events. Two functions handling the keydown and keyup events the code that will be run when the buttons are pressed. This will be what we are mainly focused on in this tutorial. Then more importantly it has the InitializeExtensions, InitializeOpenGL, and Shutdown function. It has the regular constructor, copy constructor, and destructor. In all four of the keyboard messages discussed so far, the wParam parameter contains the virtual-key code of the key. The OpenGL specification usually defines the behavior of commands such that they will execute in the order given, and that every subsequent command must behave as if all prior commands. The class definition for the OpenGLClass is kept as simple as possible here. WMKEYUP WMSYSKEYUP If you hold down a key long enough to start the keyboards repeat feature, the system sends multiple key-down messages, followed by a single key-up message. Regardless: Quote: but with this function I can only detect one key being pressed at a time. This macro only works, apparently, within a keyboard or mouse callback function. Synchronization is the process of ensuring that the OpenGL rendering pipeline has fully issued or executed the commands that you have given it. void key (unsigned char k, int x, int y) which is posted to OpenGL in : glutKeyboardFunc (key) Note that this is actually a question about Glut, which is only tangentially related to OpenGL. I've found a lot of information about using GLUT to detect whether the Ctrl key is pressed using the GLUT_ACTIVE_CTRL macro. 7.9 glutSpecialFunc glutSpecialFunc sets the special keyboard callback for the current window.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |