LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: moci on January 20, 2012, 12:08:40

Title: Mouse static "get" values, persistent during current logic/draw cycle(?)
Post by: moci on January 20, 2012, 12:08:40
Hi,

I'm currently working on a 3D editor and am planning on calling the Mouse properties on multiple locations in the code. Because I would like to keep my code as clean and separated as possible.

The problem is that the current implementations of "getXXX" are based on a per call basis. If component A wants to know the delta of X it would call "Mouse.getDX()", if then component B wants to also know the delta of X it will not get the same delta but 0. Because the mouse did not move between the two calls.

It would make sense to keep the delta values (or any other information) persistent during the same cycle. I could easily solve this by using another wrapper around the Mouse object but it would be nice to see this in the library itself.

If my thinking is wrong, please let me know!
Title: Re: Mouse static "get" values, persistent during current logic/draw cycle(?)
Post by: Fool Running on January 20, 2012, 13:57:25
Try looking at the Mouse event queue. It basically keeps the values the same until you call Mouse.next(). Look at this example (it's for the Keyboard class, but it applies to the Mouse class as well): http://www.lwjgl.org/wiki/index.php?title=LWJGL_Basics_2_(Input) (http://www.lwjgl.org/wiki/index.php?title=LWJGL_Basics_2_(Input))