LWJGL Forum

Programming => OpenGL => Topic started by: gareth on March 27, 2006, 16:44:24

Title: getting the location of the native display?
Post by: gareth on March 27, 2006, 16:44:24
Is there any way of doing this?
Title: hmmmmmm...
Post by: Fool Running on March 27, 2006, 18:24:33
What exactly do you mean by "the location of" the display?
Do you mean if the top, left of the screen is (0, 0) for primary and (1281, 30) for the secondary?
If so, you can do that in Java by getting the displays:

       GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
       GraphicsDevice[] devices = env.getScreenDevices();
Title: getting the location of the native display?
Post by: gareth on March 27, 2006, 19:35:37
I mean the location of the native window, that you can set with Display.setLocation(...)
Title: hmmmmmmm...
Post by: Fool Running on March 27, 2006, 20:50:43
Oh :lol:
It doesn't look like it :?
Someone else can chime in here :D

Out of curiosity, why do you need it?
Title: getting the location of the native display?
Post by: elias4444 on March 28, 2006, 18:37:56
Sorry... I've been a slacker and haven't been hanging around the forums lately. :P

Here's what I use to center an lwjgl window on the screen:

int tempxloc = (Display.getDisplayMode().getWidth() - WIDTH)/2;
int tempyloc = (Display.getDisplayMode().getHeight() - HEIGHT)/2;
Display.setLocation(tempxloc,tempyloc);


I should note however, that I've never been able to get this to work on Linux - although it does work great on Windows.
Title: Re: getting the location of the native display?
Post by: Romain33 on November 27, 2008, 16:57:29
Hi all !

I also need to know if there is way to get the location of the native display.

I would like to know this data to save it and create the window at the same position the next time I run my program.

Thanks :)
Title: Re: getting the location of the native display?
Post by: Aivi on November 28, 2008, 16:52:57
At start you load data, which is empty, because it wasnt create never before.So you set default position and save somewhere (to file maybe), and every next set you save position again and next start you read this data. Its simple.
Title: Re: getting the location of the native display?
Post by: Romain33 on December 01, 2008, 14:16:01
Hi Aivi !

I well understood the main way to do this  :)

My question is how can I get the location of the display as I did not see any "getLocation()" method (only getWidth() or getHeight() in DisplayMode class :-\ )

I hope my problem is a clearer for you now  ;D
Title: Re: getting the location of the native display?
Post by: Jerome on December 12, 2008, 15:52:38

Hello everybody,

Is there a solution for this problem??
When the user moves the window by clicking on it top bar, can we receive the mouse events somewhere? How can we know that the window has moved??

Is it impossible to do that with LWJGL?  :'(

Thanks in advance for your answer !  ;)
Title: Re: getting the location of the native display?
Post by: Jerome on January 02, 2009, 16:23:23


Could someone please help us??

:'(

Title: Re: getting the location of the native display?
Post by: wolf_m on January 02, 2009, 19:15:19
Quote from: Blobby on January 02, 2009, 16:23:23


Could someone please help us??

:'(


Currently, you can only get the location of the native window with your own code or workarounds, as I understand it.

For example, you could use an AWTGLCanvas in a Swing window and use Swing's capability of reporting where the window is. Or you could write native code to fetch window dragging operations and / or the window location at shutdown. I'm sure there are multiple other ways.

I totally agree that it's a useful feature; however, it's not an OpenGL feature. OpenGL doesn't bother with window locations, the mouse and so forth. So this is a feature that belongs to the utilities portion of LWJGL at max.

The last time I checked, windowed mode isn't supported anyway, so you'll just have to pray or bug the core team on IRC.