Mouse X and Y are way off.

Here is my code:


        public static Rectangle rect = new Rectangle(Mouse.getX(), Display.getHeight() - Mouse.getY() - 1, 1, 1);
	
	public static void update(Input input) {
		rect.setX(Mouse.getX());
		rect.setY(Display.getHeight() - Mouse.getY() - 1);
	}

It then says that the mouses x and y are about 500 pixels away on the X coord from the mouse cursor. Whats the whole reason for this?

Try setting the Y to

Mouse.getY()/ Display.getHeight()

instead of subtracting.

Do you have your glOrtho setup to be from 0 to 1 or from 0 to the number of pixels?

fyi, this only works with a orthogonal projection (-1, 1, -1, 1, n, f)

OP, have you tried printing the mouse coordinates to the console? Can you show us exactly how it reacts to your mouse movement? Or what the mouse’s coordinates are at the four corners of the screen would do just fine. Also, we need more information, like what libraries you’re using, the window’s properties (resolution & fullscreen). Stuff like that. :wink:

Im using slick and 0, 0 is at the upper left. And the problem is just that the x is about 500 pixels away from the mouse, CONSTANTLY! I don’t understand why it is a steady 500 pixels off.

If it’s ignorant to resolution, maybe do [icode]mouse.x = Mouse.getX() + 500;[/icode]

sounds like you are getting the absolute screen coordinates of the mouse and not within the relative zero point of the window