Mouse-related questions

Started by PeterM, August 10, 2004, 08:10:48

Previous topic - Next topic

PeterM

Hello,

I am new to LWJGL and while connecting my GUI framework to it I have found some things which seem a little strange to me. Could someone verify if I'm right about these things? I am using the latest 0.9 Windows release, not the latest CVS version.

1. Mouse movement is independent of system mouse movement because it uses DirectInput. Because of this, I absolutely have to grab the mouse and draw my own cursor (or set a native one) if I want the user to click on stuff in my window. If I don't, I have no idea where the cursor actually is.

2. The origin of the window is the bottom-left. This is confusing because the other 2D libraries I've used set the origin at the top-left of the window.

3. I still receive mouse button events when clicking outside my window. I would say this is a bug.

Apart from these things I am more than amazed by the library - it's really nice to use.

Peter

cfmdobbie

It's a while since I played with the mouse input side of things, so I'll leave that to someone more qualified.  But I can answer number two:

Yep, the window origin is bottom-left.  This is an OpenGL/3D thing rather than any attempt to deliberately confuse you!  The x-axis increases towards the right, the y-axis points up, and the z-axis comes straight out of the screen towards you.  When you deal with 2D elements in a 3D application, it's usually just assumed that z=0, so you'll be using the x and y axes as above.  Also, you'll find that all textures, bitmaps etc all treat the lower-left corner as the origin.

2D windowing systems treat the upper-left as the origin because that way they resemble the layout of western writing.  3D systems have no such parallel, and their axes are chosen for mathematical rather than for familiarity reasons.

Honestly - you'll get used to it.  A lower-left 2D origin in a 3D system makes perfect sense once you understand how it all comes together.
ellomynameis Charlie Dobbie.

PeterM

Thanks for the explanation Charlie. It does make sense from an OpenGL point of view. I've been using it for a while with C++. It just caught me off guard!  :lol: