Skip to content

Commit

Permalink
Merge branch 'gl-render-maintainable' of https://github.com/JoopAue/j…
Browse files Browse the repository at this point in the history
…monkeyengine into gl-render-maintainable
  • Loading branch information
kristinfjola committed Apr 3, 2016
2 parents 0e2c744 + 4592bb0 commit c7dba4b
Showing 1 changed file with 32 additions and 33 deletions.
65 changes: 32 additions & 33 deletions jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,9 @@ private void loadCapabilitiesES() {

protected void loadCapabilitiesGL2() {
int oglVer = extractVersion(gl.glGetString(GL.GL_VERSION));
Map<Integer, List<Caps>> versionCapMap = getGLVersionCapabilityMapping();
addCapabilitiesBasedOnVersion(versionCapMap, oglVer);

Map<Integer, List<Caps>> versionCapMap = getVersionCapabilityMapping();

for (Map.Entry<Integer, List<Caps>> entry : versionCapMap.entrySet()) {
if (oglVer >= entry.getKey()) {
for (Caps cap : entry.getValue()) {
caps.add(cap);
}
}
}

// Fix issue in TestRenderToMemory when GL.GL_FRONT is the main
// buffer being used.
Expand All @@ -194,31 +187,22 @@ protected void loadCapabilitiesGL2() {
*/
protected void loadCapabilitiesGLSL() {
int glslVer = extractVersion(gl.glGetString(GL.GL_SHADING_LANGUAGE_VERSION));
Map<Integer, List<Caps>> versionCapMap = getGSLVersionCapabilityMapping();
addCapabilitiesBasedOnVersion(versionCapMap, glslVer);
}

switch (glslVer) {
default:
if (glslVer < 400) {
break;
/**
* Add capabilities for all versions below the given version.
* @param versionCapMap mapping of existing versions and there capabilities
* @param version version to add capabilities for
*/
private void addCapabilitiesBasedOnVersion(Map<Integer, List<Caps>> versionCapMap, int version) {
for (Map.Entry<Integer, List<Caps>> entry : versionCapMap.entrySet()) {
if (version >= entry.getKey()) {
for (Caps cap : entry.getValue()) {
caps.add(cap);
}
// so that future OpenGL revisions wont break jme3
// fall through intentional
case 400:
caps.add(Caps.GLSL400);
case 330:
caps.add(Caps.GLSL330);
case 150:
caps.add(Caps.GLSL150);
case 140:
caps.add(Caps.GLSL140);
case 130:
caps.add(Caps.GLSL130);
case 120:
caps.add(Caps.GLSL120);
case 110:
caps.add(Caps.GLSL110);
case 100:
caps.add(Caps.GLSL100);
break;
}
}
}

Expand Down Expand Up @@ -2714,7 +2698,7 @@ public void setLinearizeSrgbImages(boolean linearize) {
}
}

public Map<Integer,List<Caps>> getVersionCapabilityMapping() {
public Map<Integer,List<Caps>> getGLVersionCapabilityMapping() {

Map<Integer,List<Caps>> map = new TreeMap<>();

Expand All @@ -2728,4 +2712,19 @@ public Map<Integer,List<Caps>> getVersionCapabilityMapping() {

return map;
}

public Map<Integer,List<Caps>> getGSLVersionCapabilityMapping() {
Map<Integer,List<Caps>> map = new TreeMap<>();

map.put(100, Collections.singletonList(Caps.GLSL100));
map.put(110, Collections.singletonList(Caps.GLSL110));
map.put(120, Collections.singletonList(Caps.GLSL120));
map.put(130, Collections.singletonList(Caps.GLSL130));
map.put(140, Collections.singletonList(Caps.GLSL140));
map.put(150, Collections.singletonList(Caps.GLSL150));
map.put(330, Collections.singletonList(Caps.GLSL330));
map.put(400, Collections.singletonList(Caps.GLSL400));

return map;
}
}

0 comments on commit c7dba4b

Please sign in to comment.