Updated ContextAttribs to not default to the core profile for 3.2+ versions.
Updated VersionTest (version 20 of ARB_create_context).
This commit is contained in:
parent
69dcdd170d
commit
a31db44724
|
@ -37,16 +37,16 @@ import org.lwjgl.LWJGLUtil;
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents the context attributes passed to CreateContextAttribs of the XGL_create_context extension.
|
* This class represents the context attributes passed to CreateContextAttribs of the ARB_create_context and
|
||||||
|
* ARB_create_context_profile extensions.
|
||||||
* These attributes can be used to indicate at context creation which OpenGL interface will be used. This includes the
|
* These attributes can be used to indicate at context creation which OpenGL interface will be used. This includes the
|
||||||
* OpenGL version, the layer plane on which rendering takes place and also optional debug and forward combatibility modes.
|
* OpenGL version, the layer plane on which rendering takes place and also optional debug and forward combatibility modes.
|
||||||
* (read the XGL_create_context spec for details)
|
* (read the ARB_create_context spec for details)
|
||||||
* <p/>
|
* <p/>
|
||||||
* Use of this class is optional. If an OpenGL context is created without passing an instance of this class
|
* Use of this class is optional. If an OpenGL context is created without passing an instance of this class
|
||||||
* (or XGL_create_context is not supported), the old context creation code will be used. Use of ContextAttribs is required
|
* (or ARB_create_context is not supported), the old context creation code will be used. Support for debug and forward
|
||||||
* to create an OpenGL 3.0 or newer context. Support for debug and forward compatible mobes is not guaranteed by the OpenGL
|
* compatible mobes is not guaranteed by the OpenGL implementation. Developers may encounter debug contexts being the same
|
||||||
* implementation. Developers may encounter debug contexts being the same as non-debug contexts or forward compatible
|
* as non-debug contexts or forward compatible contexts having support for deprecated functionality.
|
||||||
* contexts having support for deprecated functionality.
|
|
||||||
* <p/>
|
* <p/>
|
||||||
* If the forwardCompatible
|
* If the forwardCompatible
|
||||||
* attribute is used, LWJGL will not load the deprecated functionality (as defined in the OpenGL 3.0 specification). This
|
* attribute is used, LWJGL will not load the deprecated functionality (as defined in the OpenGL 3.0 specification). This
|
||||||
|
@ -72,10 +72,10 @@ public final class ContextAttribs {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContextAttribs(final int majorVersion, final int minorVersion) {
|
public ContextAttribs(final int majorVersion, final int minorVersion) {
|
||||||
if ( majorVersion < 0 ||
|
if ( majorVersion < 0 || 4 < majorVersion ||
|
||||||
3 < majorVersion ||
|
|
||||||
minorVersion < 0 ||
|
minorVersion < 0 ||
|
||||||
(majorVersion == 3 && 2 < minorVersion) ||
|
(majorVersion == 4 && 0 < minorVersion) ||
|
||||||
|
(majorVersion == 3 && 3 < minorVersion) ||
|
||||||
(majorVersion == 2 && 1 < minorVersion) ||
|
(majorVersion == 2 && 1 < minorVersion) ||
|
||||||
(majorVersion == 1 && 5 < minorVersion) )
|
(majorVersion == 1 && 5 < minorVersion) )
|
||||||
throw new IllegalArgumentException("Invalid OpenGL version specified: " + majorVersion + '.' + minorVersion);
|
throw new IllegalArgumentException("Invalid OpenGL version specified: " + majorVersion + '.' + minorVersion);
|
||||||
|
@ -88,7 +88,7 @@ public final class ContextAttribs {
|
||||||
this.debug = false;
|
this.debug = false;
|
||||||
this.forwardCompatible = false;
|
this.forwardCompatible = false;
|
||||||
|
|
||||||
this.profileCore = 3 < majorVersion || (majorVersion == 3 && 2 <= minorVersion) ? true : false;
|
this.profileCore = false;
|
||||||
this.profileCompatibility = false;
|
this.profileCompatibility = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,6 +179,7 @@ public final class VBOIndexTest {
|
||||||
mapped_indices_buffer);
|
mapped_indices_buffer);
|
||||||
if ( new_mapped_buffer != mapped_indices_buffer )
|
if ( new_mapped_buffer != mapped_indices_buffer )
|
||||||
mapped_indices_int_buffer = new_mapped_buffer.order(ByteOrder.nativeOrder()).asIntBuffer();
|
mapped_indices_int_buffer = new_mapped_buffer.order(ByteOrder.nativeOrder()).asIntBuffer();
|
||||||
|
mapped_indices_buffer = new_mapped_buffer;
|
||||||
|
|
||||||
mapped_float_buffer.rewind();
|
mapped_float_buffer.rewind();
|
||||||
vertices.rewind();
|
vertices.rewind();
|
||||||
|
|
|
@ -29,13 +29,6 @@
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
/*
|
|
||||||
* Created by LWJGL.
|
|
||||||
* User: spasi
|
|
||||||
* Date: 2009-04-04
|
|
||||||
* Time: 21:20:24 pm
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.lwjgl.test.opengl;
|
package org.lwjgl.test.opengl;
|
||||||
|
|
||||||
import org.lwjgl.LWJGLException;
|
import org.lwjgl.LWJGLException;
|
||||||
|
@ -44,6 +37,11 @@ import org.lwjgl.opengl.*;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the ARB_create_context extension through the use of the ContextAttribs class.
|
||||||
|
*
|
||||||
|
* @author Spasi
|
||||||
|
*/
|
||||||
public final class VersionTest {
|
public final class VersionTest {
|
||||||
|
|
||||||
private VersionTest() {
|
private VersionTest() {
|
||||||
|
@ -110,46 +108,105 @@ public final class VersionTest {
|
||||||
|
|
||||||
System.out.println("\n---------\n");
|
System.out.println("\n---------\n");
|
||||||
|
|
||||||
|
System.out.println("Requested " + ca);
|
||||||
|
|
||||||
final String version = GL11.glGetString(GL11.GL_VERSION);
|
final String version = GL11.glGetString(GL11.GL_VERSION);
|
||||||
|
|
||||||
System.out.print("GL Version requested: " + majorInput + '.' + minorInput);
|
boolean deprecated = false;
|
||||||
if ( ca.isProfileCore() )
|
try {
|
||||||
System.out.print(" - Core Profile");
|
GL11.glVertex3f(0.0f, 0.0f, 0.0f);
|
||||||
else if ( ca.isProfileCompatibility() )
|
deprecated = true;
|
||||||
System.out.print(" - Compatibility Profile");
|
} catch (Throwable t) {}
|
||||||
System.out.println("\nGL Version returned : " + version);
|
|
||||||
|
|
||||||
final StringTokenizer version_tokenizer = new StringTokenizer(version, ". ");
|
final StringTokenizer version_tokenizer = new StringTokenizer(version, ". ");
|
||||||
|
|
||||||
int majorVersion = Integer.parseInt(version_tokenizer.nextToken());
|
int majorVersion = Integer.parseInt(version_tokenizer.nextToken());
|
||||||
int minorVersion = Integer.parseInt(version_tokenizer.nextToken());
|
int minorVersion = Integer.parseInt(version_tokenizer.nextToken());
|
||||||
|
|
||||||
if ( majorVersion != majorInput || minorVersion != minorInput ) {
|
final boolean compatibilityProfile;
|
||||||
if ( majorInput == 1 && minorInput == 0 )
|
final boolean coreProfile;
|
||||||
System.out.println("\tThe maximum supported version has been returned. The driver is well-behaved. :)");
|
|
||||||
else if ( majorInput < 3 && majorVersion < 3 )
|
|
||||||
System.out.println("\tThe maximum supported version pre-3.0 has been returned. The driver is well-behaved. :)");
|
|
||||||
else
|
|
||||||
System.out.println("\tThe requested version was not returned. The driver is buggy! :(");
|
|
||||||
} else
|
|
||||||
System.out.println("\tThe requested version was returned. :)");
|
|
||||||
|
|
||||||
if ( ca.isProfileCompatibility() && !GLContext.getCapabilities().GL_ARB_compatibility )
|
if ( 3 < majorVersion || (majorVersion == 3 && 2 <= minorVersion) ) {
|
||||||
System.out.println("\tThe driver does not support the Compatibility Profile.");
|
final int profileMask = GL11.glGetInteger(GL32.GL_CONTEXT_PROFILE_MASK);
|
||||||
|
|
||||||
System.out.println("\n---------\n");
|
compatibilityProfile = (profileMask & GL32.GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0;
|
||||||
|
coreProfile = (profileMask & GL32.GL_CONTEXT_CORE_PROFILE_BIT) != 0;
|
||||||
|
} else {
|
||||||
|
compatibilityProfile = false;
|
||||||
|
coreProfile = false;
|
||||||
|
}
|
||||||
|
|
||||||
System.out.println("Debug mode: " + ca.isDebug());
|
System.out.println("\nGL_VERSION returned : " + version);
|
||||||
System.out.println("Forward compatible mode: " + ca.isForwardCompatible());
|
System.out.println("\tCore profile: " + coreProfile);
|
||||||
System.out.println("ARB_compatibility: " + GLContext.getCapabilities().GL_ARB_compatibility);
|
System.out.println("\tCompatibility profile: " + compatibilityProfile);
|
||||||
try {
|
System.out.println("ARB_compatibility present: " + GLContext.getCapabilities().GL_ARB_compatibility);
|
||||||
GL11.glVertex3f(0.0f, 0.0f, 0.0f);
|
System.out.println("Deprecated functionality present: " + deprecated);
|
||||||
System.out.println("Deprecated functionality present: " + true);
|
if ( !deprecated && GLContext.getCapabilities().GL_ARB_compatibility )
|
||||||
} catch (Throwable t) {
|
System.out.println("\tARB_compatibility is present, but LWJGL has enabled pseudo-forward compatible mode.");
|
||||||
System.out.println("Deprecated functionality present: " + false);
|
|
||||||
if ( GLContext.getCapabilities().GL_ARB_compatibility ) {
|
System.out.println("\n---------");
|
||||||
System.out.println("\tARB_compatibility is present, but LWJGL has enabled pseudo-forward compatible mode.");
|
|
||||||
}
|
boolean success = false;
|
||||||
|
boolean check;
|
||||||
|
if ( majorInput < 3 || minorInput == 0 ) {
|
||||||
|
System.out.println("\nA version less than or equal to 3.0 is requested, the context\n" +
|
||||||
|
"returned may implement any of the following versions:");
|
||||||
|
|
||||||
|
System.out.println("\n1) Any version no less than that requested and no greater than 3.0.");
|
||||||
|
check = (majorInput < majorVersion || (majorInput == majorVersion && minorInput <= minorVersion)) // Satisfies requested version
|
||||||
|
&& (majorVersion < 3 || (majorVersion == 3 && minorVersion == 0)); // 3.0 or earlier
|
||||||
|
System.out.println("\t" + check);
|
||||||
|
success |= check;
|
||||||
|
|
||||||
|
System.out.println("\n2) Version 3.1, if the GL_ARB_compatibility extension is also implemented.");
|
||||||
|
check = majorVersion == 3 && minorVersion == 1 && GLContext.getCapabilities().GL_ARB_compatibility;
|
||||||
|
System.out.println("\t" + check);
|
||||||
|
success |= check;
|
||||||
|
|
||||||
|
System.out.println("\n3) The compatibility profile of version 3.2 or greater.");
|
||||||
|
check = compatibilityProfile; // No need to check version, profiles are only available with 3.2+.
|
||||||
|
System.out.println("\t" + check);
|
||||||
|
success |= check;
|
||||||
|
|
||||||
|
System.out.println("\nTEST " + (success ? "SUCCEEDED" : "FAILED"));
|
||||||
|
if ( !success && ca.isForwardCompatible() )
|
||||||
|
System.out.println("\t(probably because the forward compatible flag was set)");
|
||||||
|
} else if ( majorInput == 3 && minorInput == 1 ) {
|
||||||
|
System.out.println("\nVersion 3.1 is requested, the context returned may implement\n" +
|
||||||
|
"any of the following versions:");
|
||||||
|
|
||||||
|
System.out.println("\n1) Version 3.1. The GL_ARB_compatibility extension may or may not\n" +
|
||||||
|
"be implemented, as determined by the implementation.");
|
||||||
|
check = majorVersion == 3 && minorVersion == 1;
|
||||||
|
System.out.println("\t" + check);
|
||||||
|
success |= check;
|
||||||
|
|
||||||
|
System.out.println("\n2) The core profile of version 3.2 or greater.");
|
||||||
|
check = coreProfile; // No need to check version, profiles are only available with 3.2+.
|
||||||
|
System.out.println("\t" + check);
|
||||||
|
success |= check;
|
||||||
|
|
||||||
|
System.out.println("\nTEST " + (success ? "SUCCEEDED" : "FAILED"));
|
||||||
|
} else {
|
||||||
|
System.out.println("\nVersion 3.2 or greater is requested, the context returned may\n" +
|
||||||
|
"implement any of the following versions:");
|
||||||
|
|
||||||
|
System.out.println("\n1) The requested profile of the requested version.");
|
||||||
|
check = majorInput == majorVersion && minorInput == minorVersion
|
||||||
|
&& (!ca.isProfileCompatibility() || compatibilityProfile)
|
||||||
|
&& (!ca.isProfileCore() || coreProfile);
|
||||||
|
System.out.println("\t" + check);
|
||||||
|
success |= check;
|
||||||
|
|
||||||
|
System.out.println("\n2) The requested profile of any later version, so long as no\n" +
|
||||||
|
"features have been removed from that later version and profile.");
|
||||||
|
check = majorInput < majorVersion || (majorInput == majorVersion && minorInput < minorVersion)
|
||||||
|
&& (!ca.isProfileCompatibility() || compatibilityProfile)
|
||||||
|
&& (!ca.isProfileCore() || coreProfile);
|
||||||
|
System.out.println("\t" + check);
|
||||||
|
success |= check;
|
||||||
|
|
||||||
|
System.out.println("\nTEST " + (success ? "SUCCEEDED" : "FAILED"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,12 +231,14 @@ public final class VersionTest {
|
||||||
|
|
||||||
private static void argsError(final String msg) {
|
private static void argsError(final String msg) {
|
||||||
System.out.println("\nInvalid arguments error: " + msg);
|
System.out.println("\nInvalid arguments error: " + msg);
|
||||||
System.out.println("\nUsage: VersionTest <majorVersion> <minorVersion> {<layer>, 'debug', 'fc'}:\n");
|
System.out.println("\nUsage: VersionTest <majorVersion> <minorVersion> {'core'|'compatibility', <layer>, 'debug', 'fc'}:\n");
|
||||||
System.out.println("majorVersion\t- Major OpenGL version.");
|
System.out.println("majorVersion\t- Major OpenGL version.");
|
||||||
System.out.println("majorVersion\t- Minor OpenGL version.");
|
System.out.println("majorVersion\t- Minor OpenGL version.");
|
||||||
|
System.out.println("core\t- Sets the Core Profile bit (optional, requires 3.2+).");
|
||||||
|
System.out.println("compatibility\t- Sets the Compatibility Profile bit (optional, requires 3.2+).");
|
||||||
System.out.println("layer\t- Layer plane (optional).");
|
System.out.println("layer\t- Layer plane (optional).");
|
||||||
System.out.println("debug\t- Enables debug mode (optional).");
|
System.out.println("debug\t- Enables debug mode (optional).");
|
||||||
System.out.println("fc\t- Enables forward compatibility mode (optional).");
|
System.out.println("fc\t- Enables forward compatibility mode (optional, requires 3.0+).");
|
||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
|
|
Loading…
Reference in New Issue