Hello Guest

Starting window maximized (GLFW)

  • 7 Replies
  • 8938 Views
Starting window maximized (GLFW)
« on: November 07, 2016, 15:54:09 »
Anyone successfully get a window opened in maximized state? When I try this, the window starts with the size of a maximized window, but it's top left corner is near the center of the screen. Windows 10 seems a bit confused--once I drag the title bar, it pops back to the width and height I used to create the window. I've tried setting the position to (0, 0), but setting the position has no effect on where the pseudo maximized window appears.

GLFW.glfwDefaultWindowHints();
GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE);
GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, GLFW.GLFW_TRUE);
GLFW.glfwWindowHint(GLFW.GLFW_MAXIMIZED, GLFW.GLFW_TRUE);

//snip (color, alpha, depth, stencil hints)

GLFW.glfwWindowHint(GLFW.GLFW_DECORATED, GLFW.GLFW_TRUE);
windowHandle = GLFW.glfwCreateWindow(800, 600, "title", 0, 0);   
GLFW.glfwMakeContextCurrent(windowHandle);
GLFW.glfwShowWindow(windowHandle);   


*

Kai

Re: Starting window maximized (GLFW)
« Reply #1 on: November 07, 2016, 18:41:09 »
Yes, I have that exact problem with the exact symptoms (near center and popping back to default size when dragged), too, on Windows 7. To solve it, show the window in normal (not maximized) mode first, and immediately after the call to glfwShowWindow() do a call to glfwMaximizeWindow(window). This fixed it for me.
« Last Edit: November 07, 2016, 21:12:58 by Kai »

*

Online spasi

  • *****
  • 2261
    • WebHotelier
Re: Starting window maximized (GLFW)
« Reply #2 on: November 07, 2016, 19:09:19 »
I just tried the above code and it works fine for me (Windows 10, LWJGL 3.1.0).

Could you share more information about your systems? Do you have multiple monitors? Is the taskbar autohidden? Any weird setting in your GPU drivers? Using a custom window manager? Using multiple virtual desktops?

*

Kai

Re: Starting window maximized (GLFW)
« Reply #3 on: November 07, 2016, 21:16:27 »
For me it's:
- Stock Nvidia driver 375.63 on Windows 7 x64 (as well as older 369.26, I just upgraded, but issue persists)
- issue happens on integrated laptop display as well as external monitor (both operated in "show only on that monitor" mode, respectively)
- default graphics driver settings (by installation)
- no custom settings to the Windows desktop environment (taskbar stays put)

EDIT: With GLFW natively (git commit 8210f89b127a7c085ec38ba4342602da6b298244) everything runs fine and there is no issue with the window not being maximized.
« Last Edit: November 07, 2016, 21:40:33 by Kai »

*

Online spasi

  • *****
  • 2261
    • WebHotelier
Re: Starting window maximized (GLFW)
« Reply #4 on: November 07, 2016, 21:50:18 »
How do you launch the LWJGL app? If from an IDE, could you try from the command line?

*

Kai

Re: Starting window maximized (GLFW)
« Reply #5 on: November 07, 2016, 21:59:56 »
I just "patched" the lwjgl-glfw-3.1.1-SNAPSHOT-natives-windows.jar with the glfw3.dll (renamed to glfw.dll) built from the latest GLFW with:
- cmake -DUSE_MSVC_RUNTIME_LIBRARY_DLL=OFF -DBUILD_SHARED_LIBS=ON .. -G "Visual Studio 14 2015 Win64"
- MSBuild /p:Configuration=MinSizeRel /p:Platform=x64 GLFW.sln

And also tried to run a single jar containing everything with the Getting Started example from the lwjgl.org site from the command line via:
- java -jar out.jar

No luck. When using Java, it persistently shows the (supposedly maximized) window always near the center of the screen and (somewhat grown towards the lower right out of the screen).

When I just modify a native GLFW example program, it works. Just not with Java.

*

Kai

Re: Starting window maximized (GLFW)
« Reply #6 on: November 07, 2016, 22:05:29 »
Oh, stupid me.... I was having this code in it:
Code: [Select]
// Get the resolution of the primary monitor
GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
// Center our window
glfwSetWindowPos(
window,
(vidmode.width() - WIDTH) / 2,
(vidmode.height() - HEIGHT) / 2
);
Without it, everything's fine, obviously. :)

I'm pretty sure this is the same for cypherdare.

Re: Starting window maximized (GLFW)
« Reply #7 on: November 09, 2016, 02:39:51 »
I didn't think I was doing that, but on third look, yes I was.  :-[

Thanks for the help.