1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| int screenWidth = 600; int screenHeight = 400; int nsqr = 40; int hsqr = nsqr/2; int xcoor = screenWidth / 2; int ycoor = screenHeight / 2;
public void drawQuad() { GL11.glColor3f(0.5f,0.5f,1.0f); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(xcoor-hsqr,ycoor-hsqr); GL11.glVertex2f(xcoor+hsqr,ycoor-hsqr); GL11.glVertex2f(xcoor+hsqr,ycoor+hsqr); GL11.glVertex2f(xcoor-hsqr,ycoor+hsqr); GL11.glEnd();
}
public void detectMouse() { if(Mouse.isButtonDown(0)) { xcoor = Mouse.getX(); ycoor = Mouse.getY(); drawQuad(); } } |
Basically, when I click the left mouse button, it should draw a square (40x40. Mouse pointer at the center of the square).
The location when it comes to the x coordinate is fine; however, at the y coordinate, it's all messed up.
Let's say that if I clicked at the lower half of the screen, the square will appear at the upper half like a mirror.