LWJGL / lwjgl

[LEGACY] LWJGL 2.X - The Lightweight Java Game Library.
http://legacy.lwjgl.org/
547 stars 207 forks source link

[Mac OS X] Toggle Native Fullscreen Programmatically #83

Open ezfe opened 10 years ago

ezfe commented 10 years ago

Per #45 native fullscreen is supported in the sense that the buttons show up, however Minecraft cannot use native fullscreen from a key command because they have no way to toggle it from a code viewpoint.

Grum (from Mojang) wants a way to toggle fullscreen with code, so they can stop using the Minecraft Fullscreen on Mac O SX

kappaOne commented 10 years ago

The reason toggling the OS X Fullscreen API through the LWJGL API wasn't implemented was because at the time I couldn't come up with a clean way to do it. However it is possible since the functionality is already implemented internally and its just a matter of exposing it in a nice way through the LWJGL API.

There are a few things to keep in mind, OS X's Fullscreen API (despite its name) is not really proper native fullscreen, it just resizes the window to the screen resolution, hides the borders and puts it in its own workspace. For this reason the game window needs to be resizable to use this API hence the game will also need to handle resizing. Further its an OS X 10.7+ API and therefore not available on OS X 10.5 and 10.6.

As for implementing such functionality it could be done in a number ways, some options include:

1) Add a LWJGL switch (VM parameter) which toggles OS X's Fullscreen API so that any call to Display.setFullscreen(boolean) (on OS X 10.7+) will simply just toggle the Fullscreen API and the native fullscreen mode will be ignored and not used in this mode.

2) Add a new API to LWJGL's Display just for this functionality, however this is a platform specific API while Display is suppose to be a generic cross platform API.

Don't think the above options are particularly nice or clean way to implement this functionality. Got any other idea's or preferences on how to implement this?

ezfe commented 10 years ago

1) I'm not particularly well versed with Java terminology, however I take it a VM parameter means it is set at runtime, no? If I'm interpreting this incorrectly, and your saying that at any point, when the program wishes to toggle fullscreen, it will use the OS X Fullscreen and the Java fullscreen will only be used when that isn't available?

2) I think it should be available to people as needed. If this is the only viable option, I think it should be done.

If 1) is in fact a runtime option that can't be modified later on, than my preference would be that when the game wishes to toggle fullscreen, if it has enabled the double arrows, it uses the OS X fullscreen.

grum commented 10 years ago

I vote for 1!

b23prodtm commented 10 years ago

Hi, I'm able to get in fullscreen mode with the current modification I'm suggesting as a PR https://github.com/LWJGL/lwjgl/pull/94 with just a compatible DisplayMode and the Display.setFullscreen(true) method call within a Swing Thread. It relies on the canvas Display.setParent() mode. Can someone accordingly test it ? @b23prodtm

fenhl commented 8 years ago

Any updates on this?

kappaOne commented 8 years ago

The focus is now on LWJGL3 (which already has or will have this feature) therefore not likely to be added to LWJGL2 now, unless of course someone submits a patch.