Java Code Examples for com.jme3.system.AppSettings#setWidth()

The following examples show how to use com.jme3.system.AppSettings#setWidth() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseExternalTest.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
protected static @NotNull AppSettings getAppSettings() {
    final AppSettings settings = new AppSettings(true);
    settings.setHeight(768);
    settings.setWidth(1024);
    settings.setGammaCorrection(true);
    settings.setRenderer(AppSettings.LWJGL_OPENGL43);
    return settings;
}
 
Example 2
Source File: TestSafeCanvas.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void main(String[] args) throws InterruptedException{
    AppSettings settings = new AppSettings(true);
    settings.setWidth(640);
    settings.setHeight(480);

    final TestSafeCanvas app = new TestSafeCanvas();
    app.setPauseOnLostFocus(false);
    app.setSettings(settings);
    app.createCanvas();
    app.startCanvas(true);

    JmeCanvasContext context = (JmeCanvasContext) app.getContext();
    Canvas canvas = context.getCanvas();
    canvas.setSize(settings.getWidth(), settings.getHeight());

    

    Thread.sleep(3000);

    JFrame frame = new JFrame("Test");
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            app.stop();
        }
    });
    frame.getContentPane().add(canvas);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    Thread.sleep(3000);

    frame.getContentPane().remove(canvas);

    Thread.sleep(3000);

    frame.getContentPane().add(canvas);
}
 
Example 3
Source File: TestContextSwitching.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public TestContextSwitching() {
    AppSettings settings = new AppSettings(true);
    settings.setOpenCLSupport(true);
    settings.setVSync(true);
    settings.setWidth(800);
    settings.setHeight(600);
    settings.setOpenCLPlatformChooser(CustomPlatformChooser.class);
    settings.setRenderer(AppSettings.LWJGL_OPENGL2);
    
    setSettings(settings);
    setShowSettings(false);
}
 
Example 4
Source File: TestSafeCanvas.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void main(String[] args) throws InterruptedException{
    AppSettings settings = new AppSettings(true);
    settings.setWidth(640);
    settings.setHeight(480);

    final TestSafeCanvas app = new TestSafeCanvas();
    app.setPauseOnLostFocus(false);
    app.setSettings(settings);
    app.createCanvas();
    app.startCanvas(true);

    JmeCanvasContext context = (JmeCanvasContext) app.getContext();
    Canvas canvas = context.getCanvas();
    canvas.setSize(settings.getWidth(), settings.getHeight());

    

    Thread.sleep(3000);

    JFrame frame = new JFrame("Test");
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            app.stop();
        }
    });
    frame.getContentPane().add(canvas);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    Thread.sleep(3000);

    frame.getContentPane().remove(canvas);

    Thread.sleep(3000);

    frame.getContentPane().add(canvas);
}
 
Example 5
Source File: JoglDisplay.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected void applySettings(AppSettings settings) {
    DisplayMode displayMode;
    if (settings.getWidth() <= 0 || settings.getHeight() <= 0) {
        displayMode = device.getDisplayMode();
        settings.setResolution(displayMode.getWidth(), displayMode.getHeight());
    }
    else if (settings.isFullscreen()) {
        displayMode = getFullscreenDisplayMode(device.getDisplayModes(), settings.getWidth(),
                settings.getHeight(), settings.getBitsPerPixel(), settings.getFrequency());
        if (displayMode == null) {
            throw new RuntimeException(
                    "Unable to find fullscreen display mode matching settings");
        }
    }
    else {
        displayMode = getFullscreenDisplayMode(device.getDisplayModes(), settings.getWidth(),
                settings.getHeight(), settings.getBitsPerPixel(), settings.getFrequency());
    }
    settings.setWidth(displayMode.getWidth());
    settings.setHeight(displayMode.getHeight());
    settings.setBitsPerPixel(displayMode.getBitDepth());
    settings.setFrequency(displayMode.getRefreshRate());

    // FIXME: seems to return false even though
    // it is supported..
    // if (!device.isDisplayChangeSupported()){
    // // must use current device mode if display mode change not supported
    // displayMode = device.getDisplayMode();
    // settings.setResolution(displayMode.getWidth(), displayMode.getHeight());
    // }

    frameRate = settings.getFrameRate();
    logger.log(
            Level.INFO,
            "Selected display mode: {0}x{1}x{2} @{3}",
            new Object[] { settings.getWidth(), settings.getHeight(),
                    settings.getBitsPerPixel(), settings.getFrequency() });

    canvas.setSize(settings.getWidth(), settings.getHeight());

    DisplayMode prevDisplayMode = device.getDisplayMode();

    frame.setUndecorated(settings.isFullscreen());
    if (settings.isFullscreen()) {
        if (device.isFullScreenSupported()) {
            try {
                device.setFullScreenWindow(frame);
                if (!prevDisplayMode.equals(displayMode) && device.isDisplayChangeSupported()) {
                    device.setDisplayMode(displayMode);
                }
            }
            catch (Throwable t) {
                logger.log(Level.SEVERE, "Failed to enter fullscreen mode", t);
                device.setFullScreenWindow(null);
            }
        }
        else {
            logger.warning("Fullscreen not supported.");
        }
    }
    else {
        if (device.getFullScreenWindow() == frame) {
            device.setFullScreenWindow(null);
        }
    }
    frame.setVisible(true);
}