Browse Source

Allows to choose between the forward compatible profile and the backward compatible profile in the JOGL backend

Julien Gouesse 10 years ago
parent
commit
ce86a3e555

+ 11 - 2
jme3-core/src/main/java/com/jme3/system/AppSettings.java

@@ -112,13 +112,22 @@ public final class AppSettings extends HashMap<String, Object> {
     public static final String ANDROID_OPENAL_SOFT = "OpenAL_SOFT";
     
     /**
-     * Use JogAmp's JOGL as the display system
+     * 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 = "JOGL";
+    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 display system

+ 8 - 3
jme3-jogl/src/main/java/com/jme3/system/jogl/JoglAbstractDisplay.java

@@ -37,6 +37,7 @@ import com.jme3.input.MouseInput;
 import com.jme3.input.TouchInput;
 import com.jme3.input.awt.AwtKeyInput;
 import com.jme3.input.awt.AwtMouseInput;
+import com.jme3.system.AppSettings;
 import com.jogamp.opengl.util.Animator;
 import com.jogamp.opengl.util.AnimatorBase;
 import com.jogamp.opengl.util.FPSAnimator;
@@ -80,9 +81,13 @@ public abstract class JoglAbstractDisplay extends JoglContext implements GLEvent
         
         device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
         
-        //FIXME use the settings to know whether to use the max programmable profile
-        //then call GLProfile.getMaxProgrammable(true);
-        GLCapabilities caps = new GLCapabilities(GLProfile.getMaxFixedFunc(true));
+        GLCapabilities caps;
+        if (settings.getRenderer().equals(AppSettings.JOGL_OPENGL_FORWARD_COMPATIBLE)) {
+        	caps = new GLCapabilities(GLProfile.getMaxProgrammable(true));
+        } else {
+        	caps = new GLCapabilities(GLProfile.getMaxFixedFunc(true));
+        }
+        
         caps.setHardwareAccelerated(true);
         caps.setDoubleBuffered(true);
         caps.setStencilBits(settings.getStencilBits());

+ 1 - 1
jme3-jogl/src/main/java/com/jme3/system/jogl/JoglContext.java

@@ -167,7 +167,7 @@ public abstract class JoglContext implements JmeContext {
                                         "required for jMonkeyEngine");
         }
         
-        if (settings.getRenderer().equals("JOGL")) {
+        if (settings.getRenderer().startsWith("JOGL")) {
         	com.jme3.renderer.opengl.GL gl = new JoglGL();
         	GLExt glext = new JoglGLExt();
         	GLFbo glfbo = new JoglGLFbo();

+ 7 - 4
jme3-jogl/src/main/java/com/jme3/system/jogl/JoglNewtAbstractDisplay.java

@@ -37,6 +37,7 @@ import com.jme3.input.MouseInput;
 import com.jme3.input.TouchInput;
 import com.jme3.input.jogl.NewtKeyInput;
 import com.jme3.input.jogl.NewtMouseInput;
+import com.jme3.system.AppSettings;
 import com.jogamp.newt.opengl.GLWindow;
 import com.jogamp.opengl.util.Animator;
 import com.jogamp.opengl.util.AnimatorBase;
@@ -73,10 +74,12 @@ public abstract class JoglNewtAbstractDisplay extends JoglContext implements GLE
 
     protected void initGLCanvas() {
         loadNatives();
-        //FIXME use the settings to know whether to use the max programmable profile
-        //then call GLProfile.getMaxProgrammable(true);
-        //FIXME use the default profile only on embedded devices
-        GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
+        GLCapabilities caps;
+        if (settings.getRenderer().equals(AppSettings.JOGL_OPENGL_FORWARD_COMPATIBLE)) {
+        	caps = new GLCapabilities(GLProfile.getMaxProgrammable(true));
+        } else {
+        	caps = new GLCapabilities(GLProfile.getMaxFixedFunc(true));
+        }
         caps.setHardwareAccelerated(true);
         caps.setDoubleBuffered(true);
         caps.setStencilBits(settings.getStencilBits());