How can I customize the OpenGL mapping (a window created by OpenGL) to maximize?

I would like my OpenGL screen to be maximum.

I can force users to do this manually if I setResizeable(true) , and then force the players to click the maximize button, which like the tester mentioned is a pain and an unnecessary step for users.

I can set the display size to the same size as the players screen, but it looks weird and I'm not looking for full screen mode.

Obviously, I can full screen and set the display size already, but at the moment I can not find any method that actually allows me to actually maximize the display.

If you do not understand the difference between full-screen and maximized ( Discussion of metadata overflow ), then here is the description Maximized , and here is the description Full-screen .

+4
source share
3 answers

Set the display parent to a Canvas attached to a JFrame , and then set the maximum JFrame .

Example:

 JFrame frame = new JFrame(); Canvas canvas = new Canvas(); frame.add(canvas); frame.setVisible(true); try { Display.setParent(canvas); Display.create(); } catch (LWJGLException e) { e.printStackTrace(); } frame.setExtendedState(JFrame.MAXIMIZED_BOTH); 
+1
source

It is too long to be a comment, so I will post it here first:

Maximum mode:

when calling CreateWindow or CreateWindowEx use WS_MAZIMIZE .

  hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, g_szClassName, "The title of my window", WS_MAZIMIZE, CW_USEDEFAULT, CW_USEDEFAULT, 240, 120, NULL, NULL, hInstance, NULL); 

This thread may be of interest if you use GLUT.

The offer here was

I think you can maximize the window by setting the display location to 0px, 0px and get the DisplayMode desktop through Display.getDesktopDisplayMode (), and then set this DisplayMode as the new DisplayMode.

Full screen mode:

setDisplayModeAndFullscreen

 public static void setDisplayModeAndFullscreen(DisplayMode mode) throws LWJGLException 
  • Set the context mode.
  • If the context is not created using create (), the mode will be applied when calling create ().
  • If mode.isFullscreenCapable() is true , the context will become a full-screen context, and the display mode will switch to the mode specified by getDisplayMode() .
  • If mode.isFullscreenCapable() is false , the context will become a window context with the dimensions specified in the mode returned by getDisplayMode(). . The custom cursor position is also reset.

Options:

 mode - The new display mode to set. Must be non-null. Throws: LWJGLException - If the mode switch fails. 

Found it here .

I also found this one that seems to give a list of arrays with possible screen modes, but I'm not sure if

+4
source

You can resize the LWJGL window with Display.setDisplayModeAndFullscreen(DisplayMode mode) , as mentioned by jbutler483.

But there is a trick. There are three ways to get these display modes:

If you use the constructor, you can customize this mode to your liking, but these modes are set to isFullscreenCapable () == false '.

If you want to switch to full screen mode, you should use 'getAvailableDisplayModes ()' and select the one that has 'isFullscreenCapable () == true'. This is the only way to get full screen.

Last but not least, you can use 'getDesktopDisplayMode' to get a mode that is suitable for the desktop. I have never tested if this can enable full screen mode.

+3
source

All Articles