Loading... |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Hi, I want to center a window that I've created with Newt on the screen.
I can probably use the Window.setTopLevelPosition or Window.setPosition methods.. though I need to determine the actual resolution of the screen, so that I can center the window, e.g. screenResolutionX/2, screenResolutionY/2.. How can I find the screen resolution? Thank you, Stephen |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
On 10/10/2012 06:36 AM, Stephen [via jogamp] wrote:
> Hi, I want to center a window that I've created with Newt on the screen. > > I can probably use the Window.setTopLevelPosition or Window.setPosition > methods.. though I need to determine the actual resolution of the screen, so > that I can center the window, e.g. screenResolutionX/2, screenResolutionY/2.. > > How can I find the screen resolution? > Use the window's Screen reference. There you find ScreenMode .. etc .. ~Sven |
Loading... |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Thank you Sven!
I used getRotatedWidth/getRotatedHeight and used newWidth = (screenWidth / 2) - (windowWidth / 2) and same thing for height. Thank you again, ~Stephen |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
I also have had that problem, if i use GLWindow.
First after a setVisible(true) the correct screen coordinates can get from getScreen().getWidth() and getScreen().getHeight(), so i must use Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
On 10/16/2012 12:30 AM, adi [via jogamp] wrote:
> I also have had that problem, if i use GLWindow. > > First after a setVisible(true) the correct screen coordinates can > get from getScreen().getWidth() and getScreen().getHeight(), > so i must use > Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); > You can also create a NEWT Screen via NEWT factory and force it's instantiation by issuing 'addReference()' ! This is due to our lazy initialization .. You then can reuse that Screen instance for GLWindow, after which initialization (setVisible() ) I would 'removeReference()' to give the GLWindow the 'right' to destroy it later on. ~Sven |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Thanks.
Do you mean that ??: Display myDisplay = NewtFactory.createDisplay(NativeWindowFactory.TYPE_DEFAULT, "MySreen"); int undefined = myDisplay.addReference(); Screen myScreen = NewtFactory.createScreen(myDisplay, undefined ); |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
On 10/16/2012 11:16 AM, adi [via jogamp] wrote:
> Thanks. > > Do you mean that ??: > > Display myDisplay = > NewtFactory.createDisplay(NativeWindowFactory.TYPE_DEFAULT, "MySreen"); > int undefined = myDisplay.addReference(); > Screen myScreen = NewtFactory.createScreen(myDisplay, undefined ); addReference() returns the ref-count .., see following code-snippet: final com.jogamp.newt.Display dpy = NewtFactory.createDisplay(null); final com.jogamp.newt.Screen scrn = NewtFactory.createScreen(dpy, 0); scrn.addReference(); // gain ref-count 0 -> 1, which actually creates native resource // now you can query details // like int width = scrn.* whatever .. final GLWindow win = GLWindow.create(scrn, new GLCapabilities(null)); win.setSize(width,height); win.setVisible(true); scrn.removeReference(); // release count 2 -> 1 ... win.destroy(); // will also destroy scrn .. +++ Note: You can use your IDE (eclipse, ..) and open the JOGL project, go to Screen.addReference() and click: 'Open Call Hierarchy' This will show you a list of callers .. and hence examples. ~Sven |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Thanks! That works.
|
Free forum by Nabble | Edit this page |