From 04e7bed5e7fe2f0a40ff41d3387d09bb8492f2f5 Mon Sep 17 00:00:00 2001 From: MeFisto94 Date: Sun, 12 Jan 2020 15:22:26 +0100 Subject: [PATCH] Fixes #1251 - Support OpenGL3.1 on LWJGL2 and LWJGL3 --- .../java/com/jme3/system/AppSettings.java | 28 ++++++++++++++----- .../com/jme3/system/lwjgl/LwjglContext.java | 4 +++ .../com/jme3/system/lwjgl/LwjglContext.java | 1 + .../com/jme3/system/lwjgl/LwjglWindow.java | 4 +++ 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/system/AppSettings.java b/jme3-core/src/main/java/com/jme3/system/AppSettings.java index bd8db3107..4f15a16bc 100644 --- a/jme3-core/src/main/java/com/jme3/system/AppSettings.java +++ b/jme3-core/src/main/java/com/jme3/system/AppSettings.java @@ -70,6 +70,23 @@ public final class AppSettings extends HashMap { */ public static final String LWJGL_OPENGL2 = "LWJGL-OpenGL2"; + /** + * Use LWJGL as the display system and force using the core OpenGL3.2 renderer. + *

+ * If the underlying system does not support OpenGL3.2, then the context + * initialization will throw an exception. Note that currently jMonkeyEngine + * does not have any shaders that support OpenGL3.2 therefore this + * option is not useful. + *

+ * Note: OpenGL 3.2 is used to give 3.x support to Mac users. + * + * @deprecated Previously meant 3.2, use LWJGL_OPENGL32 or LWJGL_OPENGL30 + * @see AppSettings#setRenderer(java.lang.String) + */ + @Deprecated + public static final String LWJGL_OPENGL3 = "LWJGL-OpenGL3"; + + /** * Use LWJGL as the display system and force using the core OpenGL3.0 renderer. *

@@ -84,20 +101,17 @@ public final class AppSettings extends HashMap { public static final String LWJGL_OPENGL30 = "LWJGL-OpenGL30"; /** - * Use LWJGL as the display system and force using the core OpenGL3.2 renderer. + * Use LWJGL as the display system and force using the core OpenGL3.1 renderer. *

- * If the underlying system does not support OpenGL3.2, then the context + * If the underlying system does not support OpenGL3.1, then the context * initialization will throw an exception. Note that currently jMonkeyEngine - * does not have any shaders that support OpenGL3.2 therefore this + * does not have any shaders that support OpenGL3.0 therefore this * option is not useful. *

- * Note: OpenGL 3.2 is used to give 3.x support to Mac users. * - * @deprecated Previously meant 3.2, use LWJGL_OPENGL32 or LWJGL_OPENGL30 * @see AppSettings#setRenderer(java.lang.String) */ - @Deprecated - public static final String LWJGL_OPENGL3 = "LWJGL-OpenGL3"; + public static final String LWJGL_OPENGL31 = "LWJGL-OpenGL31"; /** * Use LWJGL as the display system and force using the core OpenGL3.2 renderer. diff --git a/jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglContext.java b/jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglContext.java index 4d2d776c5..ebd549d57 100644 --- a/jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglContext.java +++ b/jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglContext.java @@ -117,6 +117,10 @@ public abstract class LwjglContext implements JmeContext { maj = 3; min = 0; break; + case AppSettings.LWJGL_OPENGL31: + maj = 3; + min = 1; + break; case AppSettings.LWJGL_OPENGL32: maj = 3; min = 2; diff --git a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglContext.java b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglContext.java index 8f3afca85..028ad881f 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglContext.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglContext.java @@ -106,6 +106,7 @@ public abstract class LwjglContext implements JmeContext { private static final Set SUPPORTED_RENDERS = new HashSet<>(Arrays.asList( AppSettings.LWJGL_OPENGL2, AppSettings.LWJGL_OPENGL30, + AppSettings.LWJGL_OPENGL31, AppSettings.LWJGL_OPENGL32, AppSettings.LWJGL_OPENGL33, AppSettings.LWJGL_OPENGL40, diff --git a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java index e84c5c3ce..8e655f05a 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java @@ -80,6 +80,10 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable { glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); }); + RENDER_CONFIGS.put(AppSettings.LWJGL_OPENGL31, () -> { + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); + }); RENDER_CONFIGS.put(AppSettings.LWJGL_OPENGL32, () -> { glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);