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

The following examples show how to use com.jme3.system.AppSettings#getHeight() . 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: AndroidTouchInput.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void loadSettings(AppSettings settings) {
    keyboardEventsEnabled = settings.isEmulateKeyboard();
    mouseEventsEnabled = settings.isEmulateMouse();
    mouseEventsInvertX = settings.isEmulateMouseFlipX();
    mouseEventsInvertY = settings.isEmulateMouseFlipY();

    // view width and height are 0 until the view is displayed on the screen
    if (androidInput.getView().getWidth() != 0 && androidInput.getView().getHeight() != 0) {
        scaleX = settings.getWidth() / (float)androidInput.getView().getWidth();
        scaleY = settings.getHeight() / (float)androidInput.getView().getHeight();
    }
    logger.log(Level.FINE, "Setting input scaling, scaleX: {0}, scaleY: {1}",
            new Object[]{scaleX, scaleY});


}
 
Example 2
Source File: IosInputHandler.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void loadSettings(AppSettings settings) {
        // TODO: add simulate keyboard to settings
//        keyboardEventsEnabled = true;
        mouseEventsEnabled = true;//settings.isEmulateMouse();
        mouseEventsInvertX = settings.isEmulateMouseFlipX();
        mouseEventsInvertY = settings.isEmulateMouseFlipY();

        // view width and height are 0 until the view is displayed on the screen
        //if (view.getWidth() != 0 && view.getHeight() != 0) {
        //    scaleX = (float)settings.getWidth() / (float)view.getWidth();
        //    scaleY = (float)settings.getHeight() / (float)view.getHeight();
        //}
        scaleX = 1.0f;
        scaleY = 1.0f;
        width = settings.getWidth();
        height = settings.getHeight();
        logger.log(Level.FINE, "Setting input scaling, scaleX: {0}, scaleY: {1}, width: {2}, height: {3}",
                new Object[]{scaleX, scaleY, width, height});
    }
 
Example 3
Source File: LwjglDisplay.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected void createContext(AppSettings settings) throws LWJGLException{
    DisplayMode displayMode;
    if (settings.getWidth() <= 0 || settings.getHeight() <= 0){
        displayMode = Display.getDesktopDisplayMode();
        settings.setResolution(displayMode.getWidth(), displayMode.getHeight());
    }else if (settings.isFullscreen()){
        displayMode = getFullscreenDisplayMode(settings.getWidth(), settings.getHeight(),
                                               settings.getBitsPerPixel(), settings.getFrequency());
        if (displayMode == null) {
            throw new RuntimeException("Unable to find fullscreen display mode matching settings");
        }
    }else{
        displayMode = new DisplayMode(settings.getWidth(), settings.getHeight());
    }

    int samples = getNumSamplesToUse();
    PixelFormat pf = new PixelFormat(settings.getBitsPerPixel(),
                                     settings.getAlphaBits(),
                                     settings.getDepthBits(),
                                     settings.getStencilBits(),
                                     samples, 
                                     0, 
                                     0, 
                                     0, 
                                     settings.useStereo3D());
    
    frameRate = settings.getFrameRate();
    allowSwapBuffers = settings.isSwapBuffers();
    logger.log(Level.FINE, "Selected display mode: {0}", displayMode);

    boolean pixelFormatChanged = false;
    if (created.get() && (pixelFormat.getBitsPerPixel() != pf.getBitsPerPixel()
    					||pixelFormat.getAlphaBits() != pf.getAlphaBits()
                        ||pixelFormat.getDepthBits() != pf.getDepthBits()
                        ||pixelFormat.getStencilBits() != pf.getStencilBits()
                        ||pixelFormat.getSamples() != pf.getSamples())){
        renderer.resetGLObjects();
        Display.destroy();
        pixelFormatChanged = true;
    }
    pixelFormat = pf;
    
    Display.setTitle(settings.getTitle());
    Display.setResizable(settings.isResizable());
    
    if (settings.isFullscreen()) {
        Display.setDisplayModeAndFullscreen(displayMode);
    } else {
        Display.setFullscreen(false);
        Display.setDisplayMode(displayMode);
    }

    if (settings.getIcons() != null) {
        Display.setIcon(imagesToByteBuffers(settings.getIcons()));
    }
    
    Display.setVSyncEnabled(settings.isVSync());
    
    if (created.get() && !pixelFormatChanged) {
        Display.releaseContext();
        Display.makeCurrent();
        Display.update();
    }

    if (!created.get() || pixelFormatChanged){
        ContextAttribs attr = createContextAttribs();
        if (attr != null) {
            Display.create(pixelFormat, attr);
        } else {
            Display.create(pixelFormat);
        }
        renderable.set(true);
        
        if (pixelFormatChanged && pixelFormat.getSamples() > 1
         && GLContext.getCapabilities().GL_ARB_multisample){
            GL11.glEnable(ARBMultisample.GL_MULTISAMPLE_ARB);
        }
    }
    
    if (settings.isOpenCLSupport()) {
        initOpenCL();
    }
}
 
Example 4
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 = new DisplayMode(settings.getWidth(), settings.getHeight(), 0, 0);
        }

        // 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[]{displayMode.getWidth(),
                             displayMode.getHeight(),
                             displayMode.getBitDepth(),
                             displayMode.getRefreshRate()});
        
        canvas.setSize(displayMode.getWidth(), displayMode.getHeight());

        DisplayMode prevDisplayMode = device.getDisplayMode();

        if (settings.isFullscreen() && device.isFullScreenSupported()){
            frame.setUndecorated(true);

            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{
            if (!device.isFullScreenSupported()){
                logger.warning("Fullscreen not supported.");
            }else{
                frame.setUndecorated(false);
                device.setFullScreenWindow(null);
            }

            frame.setVisible(true);
        }
    }
 
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);
}