User Tools

Site Tools


Lab4: Unbuffered and Buffered Input

As you saw in Lab 3 you can use the Object Oriented Input System (OIS) to interface with a range of input devices in Ogre 3D. OIS comes with a number of classes (e.g. OIS::Keyboard, OIS::Mouse and OIS::Joystick) that represent different kinds of devices and through those you can access what the user is doing.

OIS provides two very different ways to understand what the input devices are doing:

  • Unbuffered Input: You ask the device for its current state directly. For example, every pass through the game loop, you check to see if a certain button is in a down state. Notice that you only see the state as it is when you perform the call - if the state was different for a brief moment between calls (e.g. while you were busy doing something else during the frame), you will not notice that brief change.
  • Buffered Input: You register your class as an event listener and implement methods that get called when certain device events occur. Notice that these events are at a slightly higher level than the “raw states”, for example, here you can receive a call when a button gets pressed (i.e. when the state of the button changes from up to down). Another useful fact about this mode is that no events get lost, i.e. they are all queued up, even while the system is busy doing something else, like rendering.

Make sure you understand the difference between these two modes by first completing Lab 3, paying attention to how the unbuffered mouse button input required you to look at the first time you saw a button down state and then ignore subsequent button down states in order to see it as a single press.

Then continue with Basic Tutorial 5: Buffered Input and make sure to understand how you are now dealing with somewhat “more meaningful” events, such as the key or mouse button pressed event.

/var/www/ · Last modified: 2012/02/23 12:20 by hannes

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki