restore the JOGL/JOAL hooks (#1368)
* restore the "hooks" for using JOGL/JOAL instead of LWJGL as the backend * clarify the AppSettings javadoc related to JOGL and JOAL * clarify some JmeDesktopSystem diagnostics related to JOGL and JOAL
This commit is contained in:
parent
c0692df207
commit
d6b0069407
@ -238,6 +238,33 @@ public final class AppSettings extends HashMap<String, Object> {
|
|||||||
*/
|
*/
|
||||||
public static final String ANDROID_OPENAL_SOFT = "OpenAL_SOFT";
|
public static final String ANDROID_OPENAL_SOFT = "OpenAL_SOFT";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use JogAmp's JOGL as the display system, with the OpenGL forward compatible profile
|
||||||
|
* <p>
|
||||||
|
* N.B: This backend is EXPERIMENTAL
|
||||||
|
*
|
||||||
|
* @see AppSettings#setRenderer(java.lang.String)
|
||||||
|
*/
|
||||||
|
public static final String JOGL_OPENGL_FORWARD_COMPATIBLE = "JOGL_OPENGL_FORWARD_COMPATIBLE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use JogAmp's JOGL as the display system, with the backward compatible profile
|
||||||
|
* <p>
|
||||||
|
* N.B: This backend is EXPERIMENTAL
|
||||||
|
*
|
||||||
|
* @see AppSettings#setRenderer(java.lang.String)
|
||||||
|
*/
|
||||||
|
public static final String JOGL_OPENGL_BACKWARD_COMPATIBLE = "JOGL_OPENGL_BACKWARD_COMPATIBLE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use JogAmp's JOAL as the audio renderer.
|
||||||
|
* <p>
|
||||||
|
* N.B: This backend is EXPERIMENTAL
|
||||||
|
*
|
||||||
|
* @see AppSettings#setAudioRenderer(java.lang.String)
|
||||||
|
*/
|
||||||
|
public static final String JOAL = "JOAL";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
defaults.put("Width", 640);
|
defaults.put("Width", 640);
|
||||||
defaults.put("Height", 480);
|
defaults.put("Height", 480);
|
||||||
@ -644,6 +671,8 @@ public final class AppSettings extends HashMap<String, Object> {
|
|||||||
* <li>AppSettings.LWJGL_OPENGL3 - Force OpenGL3.3 compatability</li>
|
* <li>AppSettings.LWJGL_OPENGL3 - Force OpenGL3.3 compatability</li>
|
||||||
* <li>AppSettings.LWJGL_OPENGL_ANY - Choose an appropriate
|
* <li>AppSettings.LWJGL_OPENGL_ANY - Choose an appropriate
|
||||||
* OpenGL version based on system capabilities</li>
|
* OpenGL version based on system capabilities</li>
|
||||||
|
* <li>AppSettings.JOGL_OPENGL_BACKWARD_COMPATIBLE</li>
|
||||||
|
* <li>AppSettings.JOGL_OPENGL_FORWARD_COMPATIBLE</li>
|
||||||
* <li>null - Disable graphics rendering</li>
|
* <li>null - Disable graphics rendering</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* @param renderer The renderer to set
|
* @param renderer The renderer to set
|
||||||
@ -667,6 +696,7 @@ public final class AppSettings extends HashMap<String, Object> {
|
|||||||
* Set the audio renderer to use. One of:<br>
|
* Set the audio renderer to use. One of:<br>
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>AppSettings.LWJGL_OPENAL - Default for LWJGL</li>
|
* <li>AppSettings.LWJGL_OPENAL - Default for LWJGL</li>
|
||||||
|
* <li>AppSettings.JOAL</li>
|
||||||
* <li>null - Disable audio</li>
|
* <li>null - Disable audio</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* @param audioRenderer
|
* @param audioRenderer
|
||||||
|
@ -221,6 +221,36 @@ public class JmeDesktopSystem extends JmeSystemDelegate {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private JmeContext newContextJogl(AppSettings settings, JmeContext.Type type) {
|
||||||
|
try {
|
||||||
|
Class ctxClazz = null;
|
||||||
|
switch (type) {
|
||||||
|
case Display:
|
||||||
|
ctxClazz = Class.forName("com.jme3.system.jogl.JoglNewtDisplay");
|
||||||
|
break;
|
||||||
|
case Canvas:
|
||||||
|
ctxClazz = Class.forName("com.jme3.system.jogl.JoglNewtCanvas");
|
||||||
|
break;
|
||||||
|
case OffscreenSurface:
|
||||||
|
ctxClazz = Class.forName("com.jme3.system.jogl.JoglOffscreenBuffer");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Unsupported context type " + type);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (JmeContext) ctxClazz.newInstance();
|
||||||
|
} catch (InstantiationException ex) {
|
||||||
|
logger.log(Level.SEVERE, "Failed to create context", ex);
|
||||||
|
} catch (IllegalAccessException ex) {
|
||||||
|
logger.log(Level.SEVERE, "Failed to create context", ex);
|
||||||
|
} catch (ClassNotFoundException ex) {
|
||||||
|
logger.log(Level.SEVERE, "CRITICAL ERROR: Context class is missing!\n"
|
||||||
|
+ "Make sure jme3-jogl is on the classpath.", ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private JmeContext newContextCustom(AppSettings settings, JmeContext.Type type) {
|
private JmeContext newContextCustom(AppSettings settings, JmeContext.Type type) {
|
||||||
try {
|
try {
|
||||||
String className = settings.getRenderer().substring("CUSTOM".length());
|
String className = settings.getRenderer().substring("CUSTOM".length());
|
||||||
@ -250,6 +280,9 @@ public class JmeDesktopSystem extends JmeSystemDelegate {
|
|||||||
} else if (settings.getRenderer().startsWith("LWJGL")) {
|
} else if (settings.getRenderer().startsWith("LWJGL")) {
|
||||||
ctx = newContextLwjgl(settings, contextType);
|
ctx = newContextLwjgl(settings, contextType);
|
||||||
ctx.setSettings(settings);
|
ctx.setSettings(settings);
|
||||||
|
} else if (settings.getRenderer().startsWith("JOGL")) {
|
||||||
|
ctx = newContextJogl(settings, contextType);
|
||||||
|
ctx.setSettings(settings);
|
||||||
} else if (settings.getRenderer().startsWith("CUSTOM")) {
|
} else if (settings.getRenderer().startsWith("CUSTOM")) {
|
||||||
ctx = newContextCustom(settings, contextType);
|
ctx = newContextCustom(settings, contextType);
|
||||||
ctx.setSettings(settings);
|
ctx.setSettings(settings);
|
||||||
@ -267,8 +300,8 @@ public class JmeDesktopSystem extends JmeSystemDelegate {
|
|||||||
Class<T> clazz = (Class<T>) Class.forName(className);
|
Class<T> clazz = (Class<T>) Class.forName(className);
|
||||||
return clazz.newInstance();
|
return clazz.newInstance();
|
||||||
} catch (ClassNotFoundException ex) {
|
} catch (ClassNotFoundException ex) {
|
||||||
logger.log(Level.SEVERE, "CRITICAL ERROR: Audio implementation class is missing!\n"
|
logger.log(Level.SEVERE, "CRITICAL ERROR: Audio implementation class "
|
||||||
+ "Make sure jme3_lwjgl-oal is on the classpath.", ex);
|
+ className + " is missing!\n", ex);
|
||||||
} catch (IllegalAccessException ex) {
|
} catch (IllegalAccessException ex) {
|
||||||
logger.log(Level.SEVERE, "Failed to create context", ex);
|
logger.log(Level.SEVERE, "Failed to create context", ex);
|
||||||
} catch (InstantiationException ex) {
|
} catch (InstantiationException ex) {
|
||||||
@ -289,6 +322,10 @@ public class JmeDesktopSystem extends JmeSystemDelegate {
|
|||||||
al = newObject("com.jme3.audio.lwjgl.LwjglAL");
|
al = newObject("com.jme3.audio.lwjgl.LwjglAL");
|
||||||
alc = newObject("com.jme3.audio.lwjgl.LwjglALC");
|
alc = newObject("com.jme3.audio.lwjgl.LwjglALC");
|
||||||
efx = newObject("com.jme3.audio.lwjgl.LwjglEFX");
|
efx = newObject("com.jme3.audio.lwjgl.LwjglEFX");
|
||||||
|
} else if (settings.getAudioRenderer().startsWith("JOAL")) {
|
||||||
|
al = newObject("com.jme3.audio.joal.JoalAL");
|
||||||
|
alc = newObject("com.jme3.audio.joal.JoalALC");
|
||||||
|
efx = newObject("com.jme3.audio.joal.JoalEFX");
|
||||||
} else {
|
} else {
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException(
|
||||||
"Unrecognizable audio renderer specified: "
|
"Unrecognizable audio renderer specified: "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user