Java Code Examples for com.jme3.system.AppSettings#setResolution()
The following examples show how to use
com.jme3.system.AppSettings#setResolution() .
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: TestContextRestart.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
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 2
Source File: TestContextRestart.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
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 3
Source File: TestRenderToMemory.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void main(String[] args){ TestRenderToMemory app = new TestRenderToMemory(); app.setPauseOnLostFocus(false); AppSettings settings = new AppSettings(true); settings.setResolution(1, 1); app.setSettings(settings); app.start(Type.OffscreenSurface); }
Example 4
Source File: TestApplication.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void main(String[] args) throws InterruptedException{ System.out.println("Creating application.."); LegacyApplication app = new LegacyApplication(); System.out.println("Starting application in LWJGL mode.."); app.start(); System.out.println("Waiting 5 seconds"); Thread.sleep(5000); System.out.println("Closing application.."); app.stop(); Thread.sleep(2000); System.out.println("Starting in fullscreen mode"); app = new LegacyApplication(); AppSettings settings = new AppSettings(true); settings.setFullscreen(true); settings.setResolution(-1,-1); // current width/height app.setSettings(settings); app.start(); Thread.sleep(5000); app.stop(); Thread.sleep(2000); System.out.println("Creating offscreen buffer application"); app = new LegacyApplication(); app.start(Type.OffscreenSurface); Thread.sleep(3000); System.out.println("Destroying offscreen buffer"); app.stop(); }
Example 5
Source File: TestAppStates.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void start(JmeContext.Type contextType){ AppSettings settings = new AppSettings(true); settings.setResolution(1024, 768); setSettings(settings); super.start(contextType); }
Example 6
Source File: TestBatchNodeCluster.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
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 7
Source File: TestRenderToMemory.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public static void main(String[] args){ TestRenderToMemory app = new TestRenderToMemory(); app.setPauseOnLostFocus(false); AppSettings settings = new AppSettings(true); settings.setResolution(1, 1); app.setSettings(settings); app.start(Type.OffscreenSurface); }
Example 8
Source File: TestAppStates.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void start(JmeContext.Type contextType){ AppSettings settings = new AppSettings(true); settings.setResolution(1024, 768); setSettings(settings); super.start(contextType); }
Example 9
Source File: TestBatchNodeCluster.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
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 10
Source File: TestCubeCluster.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public static void main(String[] args) { TestCubeCluster app = new TestCubeCluster(); 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 11
Source File: LwjglDisplay.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@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 12
Source File: AndroidHarness.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { initializeLogHandler(); logger.fine("onCreate"); super.onCreate(savedInstanceState); if (screenFullScreen) { requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } else { if (!screenShowTitle) { requestWindowFeature(Window.FEATURE_NO_TITLE); } } final DataObject data = (DataObject) getLastNonConfigurationInstance(); if (data != null) { logger.log(Level.FINE, "Using Retained App"); this.app = data.app; } else { // Discover the screen reolution //TODO try to find a better way to get a hand on the resolution WindowManager wind = this.getWindowManager(); Display disp = wind.getDefaultDisplay(); Log.d("AndroidHarness", "Resolution from Window, width:" + disp.getWidth() + ", height: " + disp.getHeight()); // Create Settings logger.log(Level.FINE, "Creating settings"); AppSettings settings = new AppSettings(true); settings.setEmulateMouse(mouseEventsEnabled); settings.setEmulateMouseFlipAxis(mouseEventsInvertX, mouseEventsInvertY); settings.setUseJoysticks(joystickEventsEnabled); settings.setEmulateKeyboard(keyEventsEnabled); settings.setBitsPerPixel(eglBitsPerPixel); settings.setAlphaBits(eglAlphaBits); settings.setDepthBits(eglDepthBits); settings.setSamples(eglSamples); settings.setStencilBits(eglStencilBits); settings.setResolution(disp.getWidth(), disp.getHeight()); settings.setAudioRenderer(audioRendererType); settings.setFrameRate(frameRate); // Create application instance try { if (app == null) { Class clazz = Class.forName(appClass); app = (LegacyApplication)clazz.newInstance(); } app.setSettings(settings); app.start(); } catch (Exception ex) { handleError("Class " + appClass + " init failed", ex); setContentView(new TextView(this)); } } ctx = (OGLESContext) app.getContext(); view = ctx.createView(this); // store the glSurfaceView in JmeAndroidSystem for future use JmeAndroidSystem.setView(view); // AndroidHarness wraps the app as a SystemListener. ctx.setSystemListener(this); layoutDisplay(); }
Example 13
Source File: JoglDisplay.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
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 14
Source File: JoglDisplay.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
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); }