use of com.jme3.system.AppSettings in project jmonkeyengine by jMonkeyEngine.
the class VRMouseManager method centerMouse.
/**
* Center the mouse on the display.
*/
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.");
}
}
use of com.jme3.system.AppSettings in project jmonkeyengine by jMonkeyEngine.
the class SimpleApplication method start.
@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();
}
use of com.jme3.system.AppSettings in project jmonkeyengine by jMonkeyEngine.
the class JmeAndroidSystem method newAudioRenderer.
@Override
public AudioRenderer newAudioRenderer(AppSettings settings) {
ALC alc = new AndroidALC();
AL al = new AndroidAL();
EFX efx = new AndroidEFX();
return new ALAudioRenderer(al, alc, efx);
}
use of com.jme3.system.AppSettings in project jmonkeyengine by jMonkeyEngine.
the class AndroidHarnessFragment method onCreate.
/**
* This Fragment uses setRetainInstance(true) so the onCreate method will only
* be called once. During device configuration changes, the instance of
* this Fragment will be reused in the new Activity. This method should not
* contain any View related objects. They are created and destroyed by
* other methods. View related objects should not be reused, but rather
* created and destroyed along with the Activity.
*
* @param savedInstanceState
*/
@Override
public void onCreate(Bundle savedInstanceState) {
initializeLogHandler();
logger.fine("onCreate");
super.onCreate(savedInstanceState);
// 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.setAudioRenderer(audioRendererType);
settings.setFrameRate(frameRate);
// Create application instance
try {
if (app == null) {
@SuppressWarnings("unchecked") Class<? extends LegacyApplication> clazz = (Class<? extends LegacyApplication>) Class.forName(appClass);
app = clazz.newInstance();
}
app.setSettings(settings);
app.start();
} catch (Exception ex) {
handleError("Class " + appClass + " init failed", ex);
}
OGLESContext ctx = (OGLESContext) app.getContext();
// AndroidHarness wraps the app as a SystemListener.
ctx.setSystemListener(this);
setRetainInstance(true);
}
use of com.jme3.system.AppSettings in project jmonkeyengine by jMonkeyEngine.
the class TestBetterCharacter method main.
public static void main(String[] args) {
TestBetterCharacter app = new TestBetterCharacter();
AppSettings settings = new AppSettings(true);
settings.setRenderer(AppSettings.LWJGL_OPENGL2);
settings.setAudioRenderer(AppSettings.LWJGL_OPENAL);
app.setSettings(settings);
app.start();
}
Aggregations