Skip to content

Commit

Permalink
Fix #875 - ES version should be strictly validated
Browse files Browse the repository at this point in the history
When initializing the context in GLContextImpl.setGLFuncAvailability
ES devices must be validated by strictly matching the major version,
otherwise on ES3 devices we were mixing ES1 implementation with ES3
contexts, ultimately crashing in a safeguard.

Signed-off-by: Brice Figureau <brice@daysofwonder.com>
  • Loading branch information
Brice Figureau committed Oct 29, 2013
1 parent bcfaa14 commit 85be813
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/jogl/classes/jogamp/opengl/GLContextImpl.java
Expand Up @@ -1386,6 +1386,8 @@ protected final boolean setGLFunctionAvailability(boolean force, int major, int
}
}

boolean isES = ( CTX_PROFILE_ES & ctxProfileBits ) != 0;

//
// Validate GL version either by GL-Integer or GL-String
//
Expand Down Expand Up @@ -1424,10 +1426,13 @@ protected final boolean setGLFunctionAvailability(boolean force, int major, int
}
return false;
}
// Use returned GL version!
major = glIntMajor[0];
minor = glIntMinor[0];
versionValidated = true;
// impose strict matching for ES
if ((isES && major == glIntMajor[0]) || !isES) {
// Use returned GL version!
major = glIntMajor[0];
minor = glIntMinor[0];
versionValidated = true;
}
} else {
versionGL3IntFailed = true;
}
Expand Down Expand Up @@ -1455,10 +1460,13 @@ protected final boolean setGLFunctionAvailability(boolean force, int major, int
}
return false;
}
// Use returned GL version!
major = hasGLVersionNumber.getMajor();
minor = hasGLVersionNumber.getMinor();
versionValidated = true;
// impose strict matching for ES
if ((isES && major == hasGLVersionNumber.getMajor()) || !isES) {
// Use returned GL version!
major = hasGLVersionNumber.getMajor();
minor = hasGLVersionNumber.getMinor();
versionValidated = true;
}
}
}
if( strictMatch && !versionValidated ) {
Expand Down Expand Up @@ -1551,7 +1559,7 @@ protected final boolean setGLFunctionAvailability(boolean force, int major, int
}
}

if( 0 != ( CTX_PROFILE_ES & ctxProfileBits ) ) {
if( isES ) {
if( major >= 3 ) {
ctxProfileBits |= CTX_IMPL_ES3_COMPAT | CTX_IMPL_ES2_COMPAT ;
ctxProfileBits |= CTX_IMPL_FBO;
Expand Down

0 comments on commit 85be813

Please sign in to comment.