OpenGL: Made generated ContextCapabilities only try to load super class symbols if a sub class is supported. This avoids spurious 'Could not locate symbol' warnings in debug mode (glLoadProgramNV on ATI hardware)

This commit is contained in:
Elias Naur 2006-02-06 11:11:09 +00:00
parent ac3a70926b
commit 2e3c168792
3 changed files with 31 additions and 8 deletions

View File

@ -2094,9 +2094,20 @@ public class ContextCapabilities {
throw new LWJGLException("GL11 not supported");
GLContext.setCapabilities(this);
Set supported_extensions = GLContext.getSupportedExtensions();
supported_extensions.add("GL_ARB_buffer_object");
supported_extensions.add("GL_ARB_program");
supported_extensions.add("GL_NV_program");
if (supported_extensions.contains("GL_ARB_fragment_program"))
supported_extensions.add("GL_ARB_program");
if (supported_extensions.contains("GL_ARB_pixel_buffer_object"))
supported_extensions.add("GL_ARB_buffer_object");
if (supported_extensions.contains("GL_ARB_vertex_buffer_object"))
supported_extensions.add("GL_ARB_buffer_object");
if (supported_extensions.contains("GL_ARB_vertex_program"))
supported_extensions.add("GL_ARB_program");
if (supported_extensions.contains("GL_EXT_pixel_buffer_object"))
supported_extensions.add("GL_ARB_buffer_object");
if (supported_extensions.contains("GL_NV_fragment_program"))
supported_extensions.add("GL_NV_program");
if (supported_extensions.contains("GL_NV_vertex_program"))
supported_extensions.add("GL_NV_program");
if (supported_extensions.contains("GL_ARB_buffer_object") && !ARB_buffer_object_initNativeFunctionAddresses())
supported_extensions.remove("GL_ARB_buffer_object");
if (supported_extensions.contains("GL_ARB_color_buffer_float") && !ARB_color_buffer_float_initNativeFunctionAddresses())

View File

@ -85,6 +85,19 @@ public class ContextCapabilitiesGenerator {
return EXTENSION_PREFIX + interface_name;
}
public static void generateSuperClassAdds(PrintWriter writer, InterfaceDeclaration d) {
Collection<InterfaceType> super_interfaces = d.getSuperinterfaces();
if (super_interfaces.size() > 1)
throw new RuntimeException(d + " extends more than one other interface");
if (super_interfaces.size() == 1) {
InterfaceType super_interface = super_interfaces.iterator().next();
writer.print("\t\tif (" + CACHED_EXTS_VAR_NAME + ".contains(\"");
writer.println(translateFieldName(d.getSimpleName()) + "\"))");
writer.print("\t\t\t");
generateAddExtension(writer, super_interface.getDeclaration());
}
}
public static void generateInitializer(PrintWriter writer, InterfaceDeclaration d) {
String translated_field_name = translateFieldName(d.getSimpleName());
writer.print("\t\tthis." + translated_field_name + " = ");
@ -145,13 +158,13 @@ public class ContextCapabilitiesGenerator {
writer.println(translateFieldName(d.getSimpleName()) + "\");");
} else {
writer.print("\t\tGLContext." + Utils.STUB_INITIALIZER_NAME + "(" + Utils.getSimpleClassName(d));
writer.println(".class, supported_extensions, \"" + translateFieldName(d.getSimpleName()) + "\");");
writer.println(".class, " + CACHED_EXTS_VAR_NAME + ", \"" + translateFieldName(d.getSimpleName()) + "\");");
}
}
}
public static void generateAddExtension(PrintWriter writer, InterfaceDeclaration d) {
writer.print("\t\t" + CACHED_EXTS_VAR_NAME + ".add(\"");
private static void generateAddExtension(PrintWriter writer, InterfaceDeclaration d) {
writer.print(CACHED_EXTS_VAR_NAME + ".add(\"");
writer.println(translateFieldName(d.getSimpleName()) + "\");");
}

View File

@ -139,8 +139,7 @@ public class ContextGeneratorProcessorFactory implements AnnotationProcessorFact
ContextCapabilitiesGenerator.generateInitStubsPrologue(writer, context_specific);
for (TypeDeclaration typedecl : interface_decls) {
InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
if (!Utils.isFinal(interface_decl))
ContextCapabilitiesGenerator.generateAddExtension(writer, interface_decl);
ContextCapabilitiesGenerator.generateSuperClassAdds(writer, interface_decl);
}
for (TypeDeclaration typedecl : interface_decls) {
InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;