Hello Guest

LWJGL 3: modifided window

  • 2 Replies
  • 6542 Views
LWJGL 3: modifided window
« on: March 12, 2015, 21:10:16 »
I'm currently working on making an editor.
And was troubeling with some UI things and was thinking about making a cool/ nice looking window like spotify does.
So i got everything working fine, but then i forgot that the x and y positions you get from the mouse is from the game and not from the window.
So it was glitching out.

Video: https://www.youtube.com/watch?v=xVHmm1q_STA

So what i wanted to know is:
is there a way to get the x and y or deltaX and deltaY of you mouse on windows.
is there a better way to get a nice looking window without using undecorated
and any things on top of that that can be better in code or looking ?

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: LWJGL 3: modifided window
« Reply #1 on: March 12, 2015, 22:21:06 »
Hey GoldDiggerTh,

Interesting glitch, could you post the code you're using?

Re: LWJGL 3: modifided window
« Reply #2 on: March 12, 2015, 22:46:07 »
it's more or less as a bug cause as i said it uses screen x and y position.

but here you go:

Code: [Select]
for setting position of the screen on the monitor:
private static int lastX =0, lastY =0;
public static void setPosition(int x, int y){
lastX =x;
lastY =y;
glfwSetWindowPos(getWindow(), x, y);
}

this is the code for the taskbar/titlebar:
boolean hover =PandaInput.cursorWithin(0, height-24, width, 24); //this gives bool if a mouse is inside a box (like a button)
if(hover && Cursor.isButtonDown(0)) move =true;
if(!Cursor.isButtonDown(0)) move =false;
if(move){
int x =(int)Math.floor(PandaInput.getMouseDeltaX());
int y =(int)Math.floor(PandaInput.getMouseDeltaY());
if(x !=0 || y !=0)
setPosition(lastX +x, lastY -y);
}

hopefully that will do it.