com.jme3.system.JmeContext.Type Java Examples
The following examples show how to use
com.jme3.system.JmeContext.Type.
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: JmeDesktopSystem.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public JmeContext newContext(AppSettings settings, Type contextType) { initialize(settings); JmeContext ctx; if (settings.getRenderer() == null || settings.getRenderer().equals("NULL") || contextType == JmeContext.Type.Headless) { ctx = new NullContext(); ctx.setSettings(settings); } else if (settings.getRenderer().startsWith("LWJGL")) { ctx = newContextLwjgl(settings, contextType); ctx.setSettings(settings); } else if (settings.getRenderer().startsWith("JOGL")) { ctx = newContextJogl(settings, contextType); ctx.setSettings(settings); } else if (settings.getRenderer().startsWith("CUSTOM")) { ctx = newContextCustom(settings, contextType); ctx.setSettings(settings); } else { throw new UnsupportedOperationException( "Unrecognizable renderer specified: " + settings.getRenderer()); } return ctx; }
Example #2
Source File: LegacyApplication.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Internal use only. */ @Override public void handleError(String errMsg, Throwable t){ // Print error to log. logger.log(Level.SEVERE, errMsg, t); // Display error message on screen if not in headless mode if (context.getType() != JmeContext.Type.Headless) { if (t != null) { JmeSystem.showErrorDialog(errMsg + "\n" + t.getClass().getSimpleName() + (t.getMessage() != null ? ": " + t.getMessage() : "")); } else { JmeSystem.showErrorDialog(errMsg); } } stop(); // stop the application }
Example #3
Source File: VRApplication.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Handle the error given in parameters by creating a log entry and a dialog window. Internal use only. */ @Override public void handleError(String errMsg, Throwable t){ // Print error to log. logger.log(Level.SEVERE, errMsg, t); // Display error message on screen if not in headless mode if (context.getType() != JmeContext.Type.Headless) { if (t != null) { JmeSystem.showErrorDialog(errMsg + "\n" + t.getClass().getSimpleName() + (t.getMessage() != null ? ": " + t.getMessage() : "")); } else { JmeSystem.showErrorDialog(errMsg); } } stop(); // stop the application }
Example #4
Source File: LegacyApplication.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Starts the application. * Creating a rendering context and executing * the main loop in a separate thread. */ public void start(JmeContext.Type contextType, boolean waitFor){ if (context != null && context.isCreated()){ logger.warning("start() called when application already created!"); return; } if (settings == null){ settings = new AppSettings(true); } logger.log(Level.FINE, "Starting application: {0}", getClass().getName()); context = JmeSystem.newContext(settings, contextType); context.setSystemListener(this); context.create(waitFor); }
Example #5
Source File: LegacyApplication.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void initAudio(){ if (settings.getAudioRenderer() != null && context.getType() != Type.Headless){ audioRenderer = JmeSystem.newAudioRenderer(settings); audioRenderer.initialize(); AudioContext.setAudioRenderer(audioRenderer); listener = new Listener(); audioRenderer.setListener(listener); } }
Example #6
Source File: JmeSystem.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public static JmeContext newContext(AppSettings settings, Type contextType) { initialize(settings); if (settings.getRenderer().startsWith("LiveWallpaper")) { } return new OGLESContext(); }
Example #7
Source File: JmeSystemDelegateImpl.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public JmeContext newContext(AppSettings settings, Type contextType) { initialize(settings); if (settings.getRenderer().startsWith("LiveWallpaper")) { } return new GdxContext(); }
Example #8
Source File: OpenRTSApplication.java From OpenRTS with MIT License | 5 votes |
@Override public void initialize() { bulletAppState = new BulletAppState(); bulletAppState.startPhysics(); super.initialize(); guiNode.setQueueBucket(Bucket.Gui); guiNode.setCullHint(CullHint.Never); initTexts(); loadStatsView(); viewPort.attachScene(rootNode); guiViewPort.attachScene(guiNode); if (inputManager != null) { flyCam = new AzertyFlyByCamera(cam); flyCam.setMoveSpeed(1f); flyCam.registerWithInput(inputManager); if (context.getType() == Type.Display) { inputManager.addMapping("SIMPLEAPP_Exit", new KeyTrigger(KeyInput.KEY_ESCAPE)); } inputManager.addMapping("SIMPLEAPP_CameraPos", new KeyTrigger(KeyInput.KEY_C)); inputManager.addMapping("SIMPLEAPP_Memory", new KeyTrigger(KeyInput.KEY_M)); inputManager.addListener(actionListener, "SIMPLEAPP_Exit", "SIMPLEAPP_CameraPos", "SIMPLEAPP_Memory"); } // call user code simpleInitApp(); stateManager.attach(bulletAppState); getPhysicsSpace().addTickListener(this); }
Example #9
Source File: LegacyApplication.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Initializes the application's canvas for use. * <p> * After calling this method, cast the {@link #getContext()} context to * JmeCanvasContext, * then acquire the canvas with JmeCanvasContext.getCanvas() * and attach it to an AWT/Swing Frame. * The rendering thread will start when the canvas becomes visible on * screen, however if you wish to start the context immediately you * may call {@link #startCanvas() } to force the rendering thread * to start. * * @see Type#Canvas */ public void createCanvas(){ if (context != null && context.isCreated()){ logger.warning("createCanvas() called when application already created!"); return; } if (settings == null){ settings = new AppSettings(true); } logger.log(Level.FINE, "Starting application: {0}", getClass().getName()); context = JmeSystem.newContext(settings, JmeContext.Type.Canvas); context.setSystemListener(this); }
Example #10
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 #11
Source File: SimpleApplication.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void initialize() { super.initialize(); guiNode.setQueueBucket(Bucket.Gui); guiNode.setCullHint(CullHint.Never); loadFPSText(); loadStatsView(); viewPort.attachScene(rootNode); guiViewPort.attachScene(guiNode); if (inputManager != null) { flyCam = new FlyByCamera(cam); flyCam.setMoveSpeed(1f); flyCam.registerWithInput(inputManager); if (context.getType() == Type.Display) { inputManager.addMapping(INPUT_MAPPING_EXIT, new KeyTrigger(KeyInput.KEY_ESCAPE)); } inputManager.addMapping(INPUT_MAPPING_CAMERA_POS, new KeyTrigger(KeyInput.KEY_C)); inputManager.addMapping(INPUT_MAPPING_MEMORY, new KeyTrigger(KeyInput.KEY_M)); inputManager.addMapping(INPUT_MAPPING_HIDE_STATS, new KeyTrigger(KeyInput.KEY_F5)); inputManager.addListener(actionListener, INPUT_MAPPING_EXIT, INPUT_MAPPING_CAMERA_POS, INPUT_MAPPING_MEMORY, INPUT_MAPPING_HIDE_STATS); } // call user code simpleInitApp(); }
Example #12
Source File: Application.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
private void initAudio(){ if (settings.getAudioRenderer() != null && context.getType() != Type.Headless){ audioRenderer = JmeSystem.newAudioRenderer(settings); audioRenderer.initialize(); AudioContext.setAudioRenderer(audioRenderer); listener = new Listener(); audioRenderer.setListener(listener); } }
Example #13
Source File: VRApplication.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void initAudio(){ if (settings.getAudioRenderer() != null && context.getType() != JmeContext.Type.Headless){ audioRenderer = JmeSystem.newAudioRenderer(settings); audioRenderer.initialize(); AudioContext.setAudioRenderer(audioRenderer); listener = new Listener(); audioRenderer.setListener(listener); } }
Example #14
Source File: JmeAndroidSystem.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public JmeContext newContext(AppSettings settings, Type contextType) { if (settings.getAudioRenderer().equals(AppSettings.ANDROID_MEDIAPLAYER)) { audioRendererType = AppSettings.ANDROID_MEDIAPLAYER; } else if (settings.getAudioRenderer().equals(AppSettings.ANDROID_OPENAL_SOFT)) { audioRendererType = AppSettings.ANDROID_OPENAL_SOFT; } else { logger.log(Level.INFO, "AudioRenderer not set. Defaulting to OpenAL Soft"); audioRendererType = AppSettings.ANDROID_OPENAL_SOFT; } initialize(settings); JmeContext ctx = new OGLESContext(); ctx.setSettings(settings); return ctx; }
Example #15
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 #16
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 #17
Source File: SimpleApplication.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void initialize() { super.initialize(); // Several things rely on having this guiFont = loadGuiFont(); guiNode.setQueueBucket(Bucket.Gui); guiNode.setCullHint(CullHint.Never); viewPort.attachScene(rootNode); guiViewPort.attachScene(guiNode); if (inputManager != null) { // We have to special-case the FlyCamAppState because too // many SimpleApplication subclasses expect it to exist in // simpleInit(). But at least it only gets initialized if // the app state is added. if (stateManager.getState(FlyCamAppState.class) != null) { flyCam = new FlyByCamera(cam); flyCam.setMoveSpeed(1f); // odd to set this here but it did it before stateManager.getState(FlyCamAppState.class).setCamera( flyCam ); } if (context.getType() == Type.Display) { inputManager.addMapping(INPUT_MAPPING_EXIT, new KeyTrigger(KeyInput.KEY_ESCAPE)); } if (stateManager.getState(StatsAppState.class) != null) { inputManager.addMapping(INPUT_MAPPING_HIDE_STATS, new KeyTrigger(KeyInput.KEY_F5)); inputManager.addListener(actionListener, INPUT_MAPPING_HIDE_STATS); } inputManager.addListener(actionListener, INPUT_MAPPING_EXIT); } if (stateManager.getState(StatsAppState.class) != null) { // Some of the tests rely on having access to fpsText // for quick display. Maybe a different way would be better. stateManager.getState(StatsAppState.class).setFont(guiFont); fpsText = stateManager.getState(StatsAppState.class).getFpsText(); } // call user code simpleInitApp(); }
Example #18
Source File: GuiGlobals.java From Lemur with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected boolean isHeadless( Application app ) { Type type = app.getContext().getType(); return type == Type.Headless; // || type == Type.OffscreenSurface; }
Example #19
Source File: LwjglDisplay.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public Type getType() { return Type.Display; }
Example #20
Source File: LwjglCanvas.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public Type getType() { return Type.Canvas; }
Example #21
Source File: LwjglCanvas.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
@Override public Type getType() { return Type.Canvas; }
Example #22
Source File: LwjglDisplay.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public Type getType() { return Type.Display; }
Example #23
Source File: Application.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 2 votes |
/** * Starts the application in {@link Type#Display display} mode. * * @see #start(com.jme3.system.JmeContext.Type) */ public void start(){ start(JmeContext.Type.Display); }
Example #24
Source File: LwjglAbstractDisplay.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 2 votes |
/** * @return Type.Display or Type.Canvas */ public abstract Type getType();
Example #25
Source File: LegacyApplication.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Starts the application. * Creating a rendering context and executing * the main loop in a separate thread. */ public void start(JmeContext.Type contextType) { start(contextType, false); }
Example #26
Source File: LegacyApplication.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Starts the application in {@link Type#Display display} mode. * * @see #start(com.jme3.system.JmeContext.Type) */ @Override public void start(boolean waitFor){ start(JmeContext.Type.Display, waitFor); }
Example #27
Source File: LegacyApplication.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Starts the application in {@link Type#Display display} mode. * * @see #start(com.jme3.system.JmeContext.Type) */ @Override public void start(){ start(JmeContext.Type.Display, false); }
Example #28
Source File: VRApplication.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Starts the application in {@link com.jme3.system.JmeContext.Type#Display display} mode. * @param waitFor if <code>true</code>, the method will wait until the application is started. * @see #start(com.jme3.system.JmeContext.Type, boolean) */ @Override public void start(boolean waitFor){ start(JmeContext.Type.Display, waitFor); }