Screen res code:  How portable is this?

I’m running my J3d app on Windoze using the Java3d OpenGL version. When all the resources are loaded it goes to full screen mode and changes the resolution


/*
 * ChangeRes.java
 *
 */

import java.awt.*; 
import javax.swing.*; 
import java.awt.image.BufferStrategy;
/**
 *
 * @author  Tim Bennett
 */
public class ChangeRes {
    
    public ChangeRes() {
        
        GraphicsDevice dev = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
        GraphicsConfiguration gc = dev.getDefaultConfiguration();
        DisplayMode mode = new DisplayMode(800, 600, 32, DisplayMode.REFRESH_RATE_UNKNOWN);
        JFrame frame = new JFrame(gc);
        frame.setUndecorated(true);
        frame.setIgnoreRepaint(true);
        frame.show();
        dev.setFullScreenWindow(frame);
        if(dev.isDisplayChangeSupported()) dev.setDisplayMode(mode);
        BufferStrategy bufferStrategy = frame.getBufferStrategy();
        
    }
    
    public static void main( String[] args ) {
        new ChangeRes();
    }
    
}


This works fine for me but will this work just as well on other platforms or with the DirectX version of Java3d? The reason I ask is I saw a post from soneone who said he had used a similiar method and it worked with OpenGL and not DirectX.

Thanks 8)

It works fine for us. We don’t do exactly the same thing, but close enough.

If it doesn’t work on DX version of J3D, then it maybe a JDK issue not correctly talking with the Win32 APIs. I vaguely recall seeing a bug note on fullscreen mode having issues in erlier versions of JDK 1.4.x Are you using the latest 1.4.2? I have that on my machine and it’s working fine (this is how we support the Elumens domes products in our software)

Thanks for trying it, I’ve found it works with 1.4.1 and 1.4.2 and OpenGL

I thought full-screen exclusive wasn’t introduced until 1.4 so I’ll state on the download page that you need the 1.4.x

Thanks again 8)

Works fine on my end too.
I am using the linux version of Java 1.4.2

Well, when I mean works, Full Screen Exclusive mode isn’t available in Linux but your code handles this :slight_smile: