Created
May 6, 2019 16:16
-
-
Save riccardobl/39697bc37da450812acb9bc2def7294a to your computer and use it in GitHub Desktop.
Fix GL versions support for jme+lwjgl2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- <unnamed> | |
+++ <unnamed> | |
@@ -70,6 +70,8 @@ | |
*/ | |
public static final String LWJGL_OPENGL2 = "LWJGL-OpenGL2"; | |
+ public static final String LWJGL_OPENGL30 = "LWJGL-OpenGL30"; | |
+ | |
/** | |
* Use LWJGL as the display system and force using the core OpenGL3.2 renderer. | |
* <p> | |
@@ -82,7 +84,11 @@ | |
* | |
* @see AppSettings#setRenderer(java.lang.String) | |
*/ | |
+ @Deprecated | |
public static final String LWJGL_OPENGL3 = "LWJGL-OpenGL3"; | |
+ | |
+ public static final String LWJGL_OPENGL32 = "LWJGL-OpenGL32"; | |
+ | |
/** | |
* Use LWJGL as the display system and force using the OpenGL3.3 renderer. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- <unnamed> | |
+++ <unnamed> | |
@@ -107,11 +107,50 @@ | |
Display.getPixelScaleFactor()}); | |
} | |
+ protected int[] getGLVersion(String renderer){ | |
+ int maj=-1,min=-1; | |
+ switch(settings.getRenderer()){ | |
+ | |
+ case AppSettings.LWJGL_OPENGL2: | |
+ maj=2;min=0; | |
+ break; | |
+ case AppSettings.LWJGL_OPENGL30: | |
+ maj=3;min=0; | |
+ break; | |
+ default: | |
+ case AppSettings.LWJGL_OPENGL3: | |
+ case AppSettings.LWJGL_OPENGL32: | |
+ maj=3;min=2; | |
+ break; | |
+ case AppSettings.LWJGL_OPENGL33: | |
+ maj=3;min=3; | |
+ break; | |
+ case AppSettings.LWJGL_OPENGL4: | |
+ maj=4;min=0; | |
+ break; | |
+ case AppSettings.LWJGL_OPENGL41: | |
+ maj=4;min=1; | |
+ break; | |
+ case AppSettings.LWJGL_OPENGL42: | |
+ maj=4;min=2; | |
+ break; | |
+ case AppSettings.LWJGL_OPENGL43: | |
+ maj=4;min=3; | |
+ break; | |
+ case AppSettings.LWJGL_OPENGL44: | |
+ maj=4;min=4; | |
+ break; | |
+ } | |
+ return maj==-1?null:new int[]{maj,min}; | |
+ } | |
+ | |
protected ContextAttribs createContextAttribs() { | |
- if (settings.getBoolean("GraphicsDebug") || settings.getRenderer().equals(AppSettings.LWJGL_OPENGL3)) { | |
+ int vers[]=getGLVersion(settings.getRenderer()); | |
+ if (settings.getBoolean("GraphicsDebug") || (vers!=null&&vers[0]!=2/*??*/)) { | |
ContextAttribs attr; | |
- if (settings.getRenderer().equals(AppSettings.LWJGL_OPENGL3)) { | |
- attr = new ContextAttribs(3, 2); | |
+ | |
+ if (vers!=null&&vers[0]!=2/*??*/) { | |
+ attr = new ContextAttribs(vers[0], vers[1]); | |
attr = attr.withProfileCore(true).withForwardCompatible(true).withProfileCompatibility(false); | |
} else { | |
attr = new ContextAttribs(); | |
@@ -204,9 +243,9 @@ | |
throw new RendererException("OpenGL 2.0 or higher is " | |
+ "required for jMonkeyEngine"); | |
} | |
- | |
- if (settings.getRenderer().equals(AppSettings.LWJGL_OPENGL2) | |
- || settings.getRenderer().equals(AppSettings.LWJGL_OPENGL3)) { | |
+ int vers[]=getGLVersion(settings.getRenderer()); | |
+ | |
+ if (vers!=null) { | |
GL gl = new LwjglGL(); | |
GLExt glext = new LwjglGLExt(); | |
GLFbo glfbo; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment