Ois buffer and non-buffer input mode

Source: Internet
Author: User

Many people on the Internet have said this kind of problem, but I always think some of them are inappropriate. So I tried it myself.


Below are the notes:


1. Only buffer Io can be used for keylistener/mouselistener,

That is, the listener set by keyboard: seteventcallback.

2. When I/O is buffered, two events are detected: pressing and releasing.

3. Separation of Io events and frame rendering facilitates management, but easily leads to redundancy.

You can set mylistenerdata to a friend of the listener to share data (such as frame | key | mouselistener) and encapsulate attributes in mylistenerdata.

4. Implementation class:

Mylistenerdata: data related to control attributes (note that this is control information, not entity information)

Mykeylistener: operations related to key control

Mymouselistener: operations related to mouse control

Myframelistener: operations related to rendering of each frame


If the keyboard is set to non-buffered, the listener set for keyboard: seteventcallback () does not work. Similarly, if you set the mouse to be unbuffered, the mouse callback function will also fail. In this way, only related control operations can be performed in real rendering, which may lead to unclear Design of classes.


Because the mouse-and-mouse listener always detects the button status, the process changes such as movement and rotation, and the instantaneous changes such as button switching are different from the processing of non-buffering and frame rendering events. Therefore, the mouse listener always processes the press and release events to change the status. Unlike the frame event, you only need to consider whether to press the key. For this reason, three different time states of framestated/framerenderingqueued/frameended are available for processing. For example, if a variable needs to be 1 when the mouse moves, otherwise it is 0, you can set 1 in mousemoved and 0 in framerendingqueued, I don't know if the next frame of the mouse is still moving.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.