com.jme3.system.AppSettings Java Examples

The following examples show how to use com.jme3.system.AppSettings. 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: TestMultipleApplications.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    final AppSettings settings = new AppSettings(true);
    settings.setOpenCLSupport(true);
    settings.setVSync(true);
    settings.setOpenCLPlatformChooser(CustomPlatformChooser.class);
    settings.setRenderer(AppSettings.LWJGL_OPENGL2);
    for (int i=0; i<2; ++i) {
        new Thread() {
            @Override
            public void run() {
                if (currentDeviceIndex == -1) {
                    return;
                }
                TestMultipleApplications app = new TestMultipleApplications();
                app.setSettings(settings);
                app.setShowSettings(false);
                app.start();
            }
        }.start();
    }
}
 
Example #2
Source File: AbstractVRMouseManager.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void centerMouse() {
	
	if (environment != null){
		if (environment.getApplication() != null){
	        // set mouse in center of the screen if newly added
	        Vector2f size = environment.getVRGUIManager().getCanvasSize();
	        MouseInput mi = environment.getApplication().getContext().getMouseInput();
	        AppSettings as = environment.getApplication().getContext().getSettings();
	        if( mi instanceof GlfwMouseInputVR ) ((GlfwMouseInputVR)mi).setCursorPosition((int)(as.getWidth() / 2f), (int)(as.getHeight() / 2f));
	        if( environment.isInVR() ) {
	            cursorPos.x = size.x / 2f;
	            cursorPos.y = size.y / 2f;
	            recentCenterCount = 2;
	        }
		} else {
			throw new IllegalStateException("This VR environment is not attached to any application.");
		}
	} else {
        throw new IllegalStateException("This VR view manager is not attached to any VR environment.");
  	} 
	
}
 
Example #3
Source File: OpenRTSApplication.java    From OpenRTS with MIT License 6 votes vote down vote up
@Override
public void start() {
	// set some default settings in-case
	// settings dialog is not shown
	if (settings == null) {
		setSettings(new AppSettings(true));
		settings.setWidth(1024);
		settings.setHeight(768);
		try {
			settings.load("openrts.example");
		} catch (BackingStoreException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	super.start();
}
 
Example #4
Source File: SimpleApplication.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void start() {
    // set some default settings in-case
    // settings dialog is not shown
    boolean loadSettings = false;
    if (settings == null) {
        setSettings(new AppSettings(true));
        loadSettings = true;
    }

    // show settings dialog
    if (showSettings) {
        if (!JmeSystem.showSettingsDialog(settings, loadSettings)) {
            return;
        }
    }
    //re-setting settings they can have been merged from the registry.
    setSettings(settings);
    super.start();
}
 
Example #5
Source File: LwjglWindow.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Set custom icons to the window of this application.
 *
 * @param settings settings for getting the icons
 */
protected void setWindowIcon(final AppSettings settings) {

    final Object[] icons = settings.getIcons();
    if (icons == null) return;

    final GLFWImage[] images = imagesToGLFWImages(icons);

    try (final GLFWImage.Buffer iconSet = GLFWImage.malloc(images.length)) {

        for (int i = images.length - 1; i >= 0; i--) {
            final GLFWImage image = images[i];
            iconSet.put(i, image);
        }

        glfwSetWindowIcon(window, iconSet);
    }
}
 
Example #6
Source File: SimpleApplication.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void start() {
    // set some default settings in-case
    // settings dialog is not shown
    boolean loadSettings = false;
    if (settings == null) {
        setSettings(new AppSettings(true));
        loadSettings = true;
    }

    // show settings dialog
    if (showSettings) {
        if (!JmeSystem.showSettingsDialog(settings, loadSettings)) {
            return;
        }
    }
    //re-setting settings they can have been merged from the registry.
    setSettings(settings);
    super.start();
}
 
Example #7
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 #8
Source File: TestContextRestart.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public static void main(String[] args) throws InterruptedException{
    AppSettings settings = new AppSettings(true);

    final Application app = new Application();
    app.setSettings(settings);
    app.start();

    Thread.sleep(3000);

    settings.setFullscreen(true);
    settings.setResolution(-1, -1);
    app.setSettings(settings);
    app.restart();

    Thread.sleep(3000);

    app.stop();
}
 
Example #9
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 #10
Source File: TestAwtPanels.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public static void main(String[] args){
    Logger.getLogger("com.jme3").setLevel(Level.WARNING);
    
    app = new TestAwtPanels();
    app.setShowSettings(false);
    AppSettings settings = new AppSettings(true);
    settings.setCustomRenderer(AwtPanelsContext.class);
    settings.setFrameRate(60);
    app.setSettings(settings);
    app.start();
    
    SwingUtilities.invokeLater(new Runnable(){
        public void run(){
            final AwtPanelsContext ctx = (AwtPanelsContext) app.getContext();
            panel = ctx.createPanel(PaintMode.Accelerated);
            panel.setPreferredSize(new Dimension(400, 300));
            ctx.setInputSource(panel);
            
            panel2 = ctx.createPanel(PaintMode.Accelerated);
            panel2.setPreferredSize(new Dimension(400, 300));
            
            createWindowForPanel(panel, 300);
            createWindowForPanel(panel2, 700);
        }
    });
}
 
Example #11
Source File: TestContextRestart.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void main(String[] args) throws InterruptedException{
    AppSettings settings = new AppSettings(true);

    final LegacyApplication app = new LegacyApplication();
    app.setSettings(settings);
    app.start();

    Thread.sleep(3000);

    settings.setFullscreen(true);
    settings.setResolution(-1, -1);
    app.setSettings(settings);
    app.restart();

    Thread.sleep(3000);

    app.stop();
}
 
Example #12
Source File: EditorConfig.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
/**
 * Get the jME settings.
 *
 * @return the the jME settings.
 */
@FromAnyThread
public AppSettings getSettings() {

    var graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    var device = graphicsEnvironment.getDefaultScreenDevice();
    var displayMode = device.getDisplayMode();

    var settings = new AppSettings(true);
    settings.setFrequency(displayMode.getRefreshRate());
    settings.setGammaCorrection(getBoolean(PREF_GAMMA_CORRECTION, PREF_DEFAULT_GAMMA_CORRECTION));
    settings.setResizable(true);
    // settings.putBoolean("GraphicsDebug", true);

    JmeToJfxIntegrator.prepareSettings(settings, getInteger(PREF_FRAME_RATE, PREF_DEFAULT_FRAME_RATE));

    return settings;
}
 
Example #13
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 #14
Source File: TestCameraNode.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void main(String[] args) {
  TestCameraNode app = new TestCameraNode();
  AppSettings s = new AppSettings(true);
  s.setFrameRate(100);
  app.setSettings(s);
  app.start();
}
 
Example #15
Source File: TestSoftwareMouse.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void onMouseMotionEvent(MouseMotionEvent evt) {
    x += evt.getDX();
    y += evt.getDY();

    // Prevent mouse from leaving screen
    AppSettings settings = TestSoftwareMouse.this.settings;
    x = FastMath.clamp(x, 0, settings.getWidth());
    y = FastMath.clamp(y, 0, settings.getHeight());

    // adjust for hotspot
    cursor.setPosition(x, y - 64);
}
 
Example #16
Source File: TestBatchNodeCluster.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void main(String[] args) {
    TestBatchNodeCluster app = new TestBatchNodeCluster();
    settingst = new AppSettings(true);
    //settingst.setFrameRate(75);
    settingst.setResolution(640, 480);
    settingst.setVSync(false);
    settingst.setFullscreen(false);
    app.setSettings(settingst);
    app.setShowSettings(false); 
    app.start();
}
 
Example #17
Source File: JmeIosSystem.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public AudioRenderer newAudioRenderer(AppSettings settings) {
    ALC alc = new IosALC();
    AL al = new IosAL();
    //EFX efx = new IosEFX();
    return new ALAudioRenderer(al, alc, null);
 }
 
Example #18
Source File: TestSoftwareMouse.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void onMouseMotionEvent(MouseMotionEvent evt) {
    x += evt.getDX();
    y += evt.getDY();

    // Prevent mouse from leaving screen
    AppSettings settings = TestSoftwareMouse.this.settings;
    x = FastMath.clamp(x, 0, settings.getWidth());
    y = FastMath.clamp(y, 0, settings.getHeight());

    // adjust for hotspot
    cursor.setPosition(x, y - 64);
}
 
Example #19
Source File: VRAppState.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Process the attached settings and apply changes to this app state.
 * @param settings the app settings to process.
 */
protected void processSettings(AppSettings settings){
	if (settings != null){

        if (settings.get(VRConstants.SETTING_DISABLE_VR) != null){
            DISABLE_VR = settings.getBoolean(VRConstants.SETTING_DISABLE_VR);
		}
	}
}
 
Example #20
Source File: TestInitHmd.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void testInitHmd(){
    VREnvironment environment = new VREnvironment(new AppSettings(true));
    environment.initialize();
    OpenVR openVr = (OpenVR) environment.getVRHardware();
    System.out.println(openVr.getName());
    
    openVr.updatePose();
    
    openVr.destroy();

}
 
Example #21
Source File: JmeIosSystem.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public JmeContext newContext(AppSettings settings, JmeContext.Type contextType) {
    initialize(settings);
    JmeContext ctx = null;
    if (settings.getRenderer() == null
            || settings.getRenderer().equals("NULL")
            || contextType == JmeContext.Type.Headless) {
        ctx = new NullContext();
        ctx.setSettings(settings);
    } else {
        ctx = new IGLESContext();
        ctx.setSettings(settings);
    }
    return ctx;
}
 
Example #22
Source File: OGLESContext.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected void  applySettingsToRenderer(OGLESShaderRenderer renderer, AppSettings settings) 
{
    logger.warning("setSettings.USE_VA: [" + settings.getBoolean("USE_VA") + "]");
    logger.warning("setSettings.VERBOSE_LOGGING: [" + settings.getBoolean("VERBOSE_LOGGING") + "]");
    renderer.setUseVA(settings.getBoolean("USE_VA"));
    renderer.setVerboseLogging(settings.getBoolean("VERBOSE_LOGGING"));
}
 
Example #23
Source File: TestJoystick.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void main(String[] args){
    TestJoystick app = new TestJoystick();
    AppSettings settings = new AppSettings(true);
    settings.setUseJoysticks(true);
    app.setSettings(settings);
    app.start();
}
 
Example #24
Source File: TestWriteToTexture.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void main(String[] args){
    TestWriteToTexture app = new TestWriteToTexture();
    AppSettings settings = new AppSettings(true);
    settings.setOpenCLSupport(true);
    settings.setVSync(false);
    settings.setRenderer(AppSettings.LWJGL_OPENGL2);
    app.setSettings(settings);
    app.start(); // start the game
}
 
Example #25
Source File: TestOpenCLLibraries.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void main(String[] args){
    TestOpenCLLibraries app = new TestOpenCLLibraries();
    AppSettings settings = new AppSettings(true);
    settings.setOpenCLSupport(true);
    settings.setVSync(true);
    settings.setRenderer(AppSettings.LWJGL_OPENGL2);
    app.setSettings(settings);
    app.start(); // start the game
}
 
Example #26
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 #27
Source File: HelloOpenCL.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void main(String[] args){
    HelloOpenCL app = new HelloOpenCL();
    AppSettings settings = new AppSettings(true);
    settings.setOpenCLSupport(true);
    settings.setVSync(true);
    settings.setRenderer(AppSettings.LWJGL_OPENGL2);
    app.setSettings(settings);
    app.start(); // start the game
}
 
Example #28
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 #29
Source File: TestVertexBufferSharing.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void main(String[] args){
    TestVertexBufferSharing app = new TestVertexBufferSharing();
    AppSettings settings = new AppSettings(true);
    settings.setOpenCLSupport(true);
    settings.setVSync(false);
    settings.setRenderer(AppSettings.LWJGL_OPENGL2);
    app.setSettings(settings);
    app.start(); // start the game
}
 
Example #30
Source File: TestMusicPlayer.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void initAudioPlayer(){
    AppSettings settings = new AppSettings(true);
    settings.setRenderer(null); // disable rendering
    settings.setAudioRenderer("LWJGL");
    ar = JmeSystem.newAudioRenderer(settings);
    ar.initialize();
    ar.setListener(listener);
    AudioContext.setAudioRenderer(ar);
}