MAC OSX Fullscreen

Here’s a strange one. I’ve developed a game on the PC and just tested it on a MAC. It works fine, except when I press F1 to toggle into Fullscreen mode, the screen spins around and around like crazy. Toggling back from fullscreen does not stop the spinning. You have to stop the game and restart.

Anyone else seen this? I’ve basically used the fillscreen code from one of the tutorials. Is there a fix?

thanks

Chris

That’s really strange…wait, you said OSX, nevermind then.

Really helpful. What should anyone do without that kind of comments. :slight_smile:

EDIT:

Maybe provide the code you use for fullscreen? :slight_smile:

Sorry, couldn’t resist.

I just forgot to write this. I did come here to help :slight_smile:

Hi

AWT full screen mode is semi-broken on all major operating systems:

  • it doesn’t work at all under Windows with some graphics cards when the Direct3D pipeline is enabled
  • it doesn’t work at all under GNU Linux with some desktop managers including KDE (since its forth version)
  • it doesn’t work sometimes under Mac

Please just tell us which version of Mac OS X and Java you use. NEWT (JogAmp native windowing system) works just fine under these operating systems :slight_smile:

Its OSX 10.6 on a laptop. Everything else runs fine. The mouse is a bit too sensitive, but that is fixable.

Here is the code. Like I said, I think it is straight from the tutorial:

/**
* Set the display mode to be used
*
* @param width The width of the display required
* @param height The height of the display required
* @param fullscreen True if we want fullscreen mode
*/
private void setDisplayMode(int width, int height, boolean fullscreen) {

	// return if requested DisplayMode is already set
        if ((Display.getDisplayMode().getWidth() == width) && 
		(Display.getDisplayMode().getHeight() == height) && 
		(Display.isFullscreen() == fullscreen)) {
		return;
	}
	
	try {
		DisplayMode targetDisplayMode = null;
		
		if (fullscreen) {
			DisplayMode[] modes = Display.getAvailableDisplayModes();
			int freq = 0;
			
			for (int i=0;i<modes.length;i++) {
				DisplayMode current = modes[i];
				
				if ((current.getWidth() == width) && (current.getHeight() == height)) {
					if ((targetDisplayMode == null) || (current.getFrequency() >= freq)) {
						if ((targetDisplayMode == null) || (current.getBitsPerPixel() > targetDisplayMode.getBitsPerPixel())) {
							targetDisplayMode = current;
							freq = targetDisplayMode.getFrequency();
						}
					}

					// if we've found a match for bpp and frequency against the 
					// original display mode then it's probably best to go for this one
					// since it's most likely compatible with the monitor
					if ((current.getBitsPerPixel() == Display.getDesktopDisplayMode().getBitsPerPixel()) &&
					    (current.getFrequency() == Display.getDesktopDisplayMode().getFrequency())) {
						targetDisplayMode = current;
						break;
					}
				}
			}
		} else {
			targetDisplayMode = new DisplayMode(width,height);
		}
		
		if (targetDisplayMode == null) {
			System.err.println("Failed to find valid mode: "+width+"x"+height+" fs="+fullscreen);
			return;
		}

		Display.setDisplayMode(targetDisplayMode);
		Display.setFullscreen(fullscreen);
		
	} catch (LWJGLException e) {
		System.err.println("Unable to setup mode "+width+"x"+height+" fullscreen="+fullscreen + e);
	}
}

Fullscreen Mode on OS X is a major pain. Even if you get it to work on OS 10.6 it might not work on OS 10.8.

This works, then just scale your surface to have the resolution you prefer:

window.setLocation(0, 0);
window.setSize(Toolkit.getDefaultToolkit().getScreenSize().width, Toolkit.getDefaultToolkit().getScreenSize().height);