Improved compatibility mode detection

Removed support for indirect buffers as arguments to GL functions
Added missing tokens in GL30 & GL32
Added support for AMD_seamless_cubemap_per_texture & AMD_shader_stencil_export
Fixed AMD_vertex_shader_tessellator typo
Added AMD extensions to the build process >.<
This commit is contained in:
Ioannis Tsakpinis 2010-01-31 16:40:51 +00:00
parent b1594c74e5
commit ede27aaa21
11 changed files with 113 additions and 13 deletions

View file

@ -173,13 +173,13 @@ public final class GLContext {
static native long getFunctionAddress(String name);
/**
* Determine which extensions are available. Helper method to ContextCapabilities.
* Determine which extensions are available and returns the context profile mask. Helper method to ContextCapabilities.
*
* @return A Set containing all available extension strings.
* @param supported_extensions the Set to fill with the available extension names
*
* @return the context profile mask, will be 0 for any version < 3.2
*/
static Set getSupportedExtensions() {
final Set supported_extensions = new HashSet();
static int getSupportedExtensions(final Set supported_extensions) {
// Detect OpenGL version first
final String version = GL11.glGetString(GL11.GL_VERSION);
@ -225,6 +225,8 @@ public final class GLContext {
if ( 1 < majorVersion || 1 <= minorVersion )
supported_extensions.add("OpenGL11");
int profileMask = 0;
if ( majorVersion < 3 ) {
// Parse EXTENSIONS string
final String extensions_string = GL11.glGetString(GL11.GL_EXTENSIONS);
@ -242,9 +244,15 @@ public final class GLContext {
for ( int i = 0; i < extensionCount; i++ )
supported_extensions.add(GL30.glGetStringi(GL11.GL_EXTENSIONS, i));
// Get the context profile mask for versions >= 3.2
if ( 3 < majorVersion || 2 <= minorVersion ) {
GL11.glGetInteger(GL32.GL_CONTEXT_PROFILE_MASK, buffer);
profileMask = buffer.get(0);
}
}
return supported_extensions;
return profileMask;
}
/**

View file

@ -55,6 +55,7 @@ public class ContextCapabilitiesGenerator {
private final static String ALL_INIT_METHOD_NAME = "initAllStubs";
private final static String POINTER_INITIALIZER_POSTFIX = "_initNativeFunctionAddresses";
private final static String CACHED_EXTS_VAR_NAME = "supported_extensions";
private final static String PROFILE_MASK_VAR_NAME = "profileMask";
private final static String EXTENSION_PREFIX = "GL_";
private final static String CORE_PREFIX = "Open";
@ -128,10 +129,11 @@ public class ContextCapabilitiesGenerator {
// Get the supported extensions set.
writer.println("\t\tGLContext.setCapabilities(this);");
writer.println("\t\tSet " + CACHED_EXTS_VAR_NAME + " = GLContext.getSupportedExtensions();");
writer.println("\t\tSet " + CACHED_EXTS_VAR_NAME + " = new HashSet(256);");
writer.println("\t\tint " + PROFILE_MASK_VAR_NAME + " = GLContext.getSupportedExtensions(" + CACHED_EXTS_VAR_NAME + ");");
// Force forward compatible mode when OpenGL version is 3.1 or higher and ARB_compatibility is not available.
writer.println("\t\tif ( supported_extensions.contains(\"OpenGL31\") && !supported_extensions.contains(\"GL_ARB_compatibility\") )");
writer.println("\t\tif ( supported_extensions.contains(\"OpenGL31\") && !(supported_extensions.contains(\"GL_ARB_compatibility\") || (profileMask & GL32.GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0) )");
writer.println("\t\t\tforwardCompatible = true;");
if ( !context_specific ) {

View file

@ -117,6 +117,7 @@ public class ContextGeneratorProcessorFactory implements AnnotationProcessorFact
writer.println("import org.lwjgl.LWJGLUtil;");
writer.println("import org.lwjgl.BufferUtils;");
writer.println("import java.util.Set;");
writer.println("import java.util.HashSet;");
writer.println("import java.nio.IntBuffer;");
writer.println();
ContextCapabilitiesGenerator.generateClassPrologue(writer, context_specific);

View file

@ -175,7 +175,8 @@ public class GeneratorVisitor extends SimpleDeclarationVisitor {
java_writer.println();
java_writer.println("import org.lwjgl.LWJGLException;");
java_writer.println("import org.lwjgl.BufferChecks;");
java_writer.println("import org.lwjgl.NondirectBufferWrapper;");
// DISABLED: indirect buffer support
//java_writer.println("import org.lwjgl.NondirectBufferWrapper;");
java_writer.println("import java.nio.*;");
java_writer.println();
java_writer.print("public ");

View file

@ -238,7 +238,8 @@ public class JavaMethodsGenerator {
writer.println(");");
if (generate_error_checks && method.getAnnotation(NoErrorCheck.class) == null)
writer.println("\t\t" + type_map.getErrorCheckMethodName() + ";");
printNondirectParameterCopies(writer, method, mode);
// DISABLED: indirect buffer support
//printNondirectParameterCopies(writer, method, mode);
if (has_result)
writer.println("\t\treturn " + Utils.RESULT_VAR_NAME + ";");
writer.println("\t}");
@ -491,7 +492,7 @@ public class JavaMethodsGenerator {
}
NullTerminated null_terminated = param.getAnnotation(NullTerminated.class);
if (Buffer.class.isAssignableFrom(java_type)) {
boolean indirect_buffer_allowed = param.getAnnotation(CachedReference.class) == null;
boolean indirect_buffer_allowed = false && param.getAnnotation(CachedReference.class) == null; // DISABLED: indirect buffer support
boolean out_parameter = param.getAnnotation(OutParameter.class) != null;
TypeInfo typeinfo = typeinfos.get(param);
printParameterCheck(writer, param.getSimpleName(), typeinfo.getType().getSimpleName(), check_value, can_be_null, null_terminated, indirect_buffer_allowed, out_parameter);