Skip to content

Commit 04e7bed

Browse files
committed
Fixes jMonkeyEngine#1251 - Support OpenGL3.1 on LWJGL2 and LWJGL3
1 parent 77c521f commit 04e7bed

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

jme3-core/src/main/java/com/jme3/system/AppSettings.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,23 @@ public final class AppSettings extends HashMap<String, Object> {
7070
*/
7171
public static final String LWJGL_OPENGL2 = "LWJGL-OpenGL2";
7272

73+
/**
74+
* Use LWJGL as the display system and force using the core OpenGL3.2 renderer.
75+
* <p>
76+
* If the underlying system does not support OpenGL3.2, then the context
77+
* initialization will throw an exception. Note that currently jMonkeyEngine
78+
* does not have any shaders that support OpenGL3.2 therefore this
79+
* option is not useful.
80+
* <p>
81+
* Note: OpenGL 3.2 is used to give 3.x support to Mac users.
82+
*
83+
* @deprecated Previously meant 3.2, use LWJGL_OPENGL32 or LWJGL_OPENGL30
84+
* @see AppSettings#setRenderer(java.lang.String)
85+
*/
86+
@Deprecated
87+
public static final String LWJGL_OPENGL3 = "LWJGL-OpenGL3";
88+
89+
7390
/**
7491
* Use LWJGL as the display system and force using the core OpenGL3.0 renderer.
7592
* <p>
@@ -84,20 +101,17 @@ public final class AppSettings extends HashMap<String, Object> {
84101
public static final String LWJGL_OPENGL30 = "LWJGL-OpenGL30";
85102

86103
/**
87-
* Use LWJGL as the display system and force using the core OpenGL3.2 renderer.
104+
* Use LWJGL as the display system and force using the core OpenGL3.1 renderer.
88105
* <p>
89-
* If the underlying system does not support OpenGL3.2, then the context
106+
* If the underlying system does not support OpenGL3.1, then the context
90107
* initialization will throw an exception. Note that currently jMonkeyEngine
91-
* does not have any shaders that support OpenGL3.2 therefore this
108+
* does not have any shaders that support OpenGL3.0 therefore this
92109
* option is not useful.
93110
* <p>
94-
* Note: OpenGL 3.2 is used to give 3.x support to Mac users.
95111
*
96-
* @deprecated Previously meant 3.2, use LWJGL_OPENGL32 or LWJGL_OPENGL30
97112
* @see AppSettings#setRenderer(java.lang.String)
98113
*/
99-
@Deprecated
100-
public static final String LWJGL_OPENGL3 = "LWJGL-OpenGL3";
114+
public static final String LWJGL_OPENGL31 = "LWJGL-OpenGL31";
101115

102116
/**
103117
* Use LWJGL as the display system and force using the core OpenGL3.2 renderer.

jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglContext.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ protected int[] getGLVersion(String renderer) {
117117
maj = 3;
118118
min = 0;
119119
break;
120+
case AppSettings.LWJGL_OPENGL31:
121+
maj = 3;
122+
min = 1;
123+
break;
120124
case AppSettings.LWJGL_OPENGL32:
121125
maj = 3;
122126
min = 2;

jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglContext.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public abstract class LwjglContext implements JmeContext {
106106
private static final Set<String> SUPPORTED_RENDERS = new HashSet<>(Arrays.asList(
107107
AppSettings.LWJGL_OPENGL2,
108108
AppSettings.LWJGL_OPENGL30,
109+
AppSettings.LWJGL_OPENGL31,
109110
AppSettings.LWJGL_OPENGL32,
110111
AppSettings.LWJGL_OPENGL33,
111112
AppSettings.LWJGL_OPENGL40,

jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
8080
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
8181
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
8282
});
83+
RENDER_CONFIGS.put(AppSettings.LWJGL_OPENGL31, () -> {
84+
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
85+
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
86+
});
8387
RENDER_CONFIGS.put(AppSettings.LWJGL_OPENGL32, () -> {
8488
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
8589
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);

0 commit comments

Comments
 (0)