Fixed NV_vertex_array_range platform specific symbols. Fixed generics warning.

This commit is contained in:
Elias Naur 2005-02-17 09:44:06 +00:00
parent 0f97eef81b
commit 94a8c16bb9
7 changed files with 62 additions and 12 deletions

View File

@ -149,8 +149,30 @@ public class ContextCapabilitiesGenerator {
writer.println("\t\treturn ");
while (methods.hasNext()) {
MethodDeclaration method = methods.next();
writer.print("\t\t\t(" + Utils.getFunctionAddressName(d, method) + " = GLContext.getFunctionAddress(\"");
writer.print(method.getSimpleName() + "\")) != 0");
writer.print("\t\t\t(" + Utils.getFunctionAddressName(d, method) + " = ");
PlatformDependent platform_dependent = method.getAnnotation(PlatformDependent.class);
if (platform_dependent != null) {
EnumSet<Platform> platform_set = EnumSet.copyOf(Arrays.asList(platform_dependent.value()));
writer.print("GLContext.getPlatformSpecificFunctionAddress(\"");
writer.print(Platform.ALL.getPrefix() + "\", ");
writer.print("new String[]{");
Iterator<Platform> platforms = platform_set.iterator();
while (platforms.hasNext()) {
writer.print("\"" + platforms.next().getOSPrefix() + "\"");
if(platforms.hasNext())
writer.print(", ");
}
writer.print("}, new String[]{");
platforms = platform_set.iterator();
while (platforms.hasNext()) {
writer.print("\"" + platforms.next().getPrefix() + "\"");
if(platforms.hasNext())
writer.print(", ");
}
writer.print("}, ");
} else
writer.print("GLContext.getFunctionAddress(");
writer.print("\"" + method.getSimpleName() + "\")) != 0");
if (methods.hasNext())
writer.println(" &&");
}

View File

@ -127,10 +127,12 @@ public class ContextGeneratorProcessorFactory implements AnnotationProcessorFact
InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
ContextCapabilitiesGenerator.generateSymbolAddresses(writer, interface_decl);
}
writer.println();
for (TypeDeclaration typedecl : interface_decls) {
InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
ContextCapabilitiesGenerator.generateAddressesInitializers(writer, interface_decl);
if (context_specific) {
writer.println();
for (TypeDeclaration typedecl : interface_decls) {
InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
ContextCapabilitiesGenerator.generateAddressesInitializers(writer, interface_decl);
}
}
ContextCapabilitiesGenerator.generateInitStubsPrologue(writer, context_specific);
for (TypeDeclaration typedecl : interface_decls) {

View File

@ -67,7 +67,18 @@ public enum Platform {
writer.println("#endif");
}
public String getPostfix() {
public String getOSPrefix() {
switch (this) {
case WGL:
return "Windows";
case GLX:
return "Linux";
default:
throw new RuntimeException(this + " has no OS specific prefix");
}
}
public String getPrefix() {
switch (this) {
case WGL:
return "wgl";

View File

@ -108,7 +108,7 @@ public class RegisterStubsGenerator {
writer.print(Utils.getQualifiedNativeMethodName(Utils.getQualifiedClassName(d), method, generate_error_checks, context_specific));
if (mode == Mode.BUFFEROBJECT)
writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX);
String opengl_handle_name = method.getSimpleName().replaceFirst("gl", platform.getPostfix());
String opengl_handle_name = method.getSimpleName().replaceFirst("gl", platform.getPrefix());
writer.print(", \"" + opengl_handle_name + "\", (void *)&" + method.getSimpleName() + "}");
if (has_more)
writer.println(",");

View File

@ -202,7 +202,7 @@ public class TypeInfo {
}
private static void getCrossProductRecursive(int index, ParameterDeclaration[] parameters, Map<ParameterDeclaration,
Collection<TypeInfo>> typeinfos_map, HashMap<ParameterDeclaration, TypeInfo> current_instance,
Collection<TypeInfo>> typeinfos_map, Map<ParameterDeclaration, TypeInfo> current_instance,
Collection<Map<ParameterDeclaration, TypeInfo>> cross_product) {
if (index == parameters.length) {
cross_product.add(current_instance);
@ -212,7 +212,7 @@ public class TypeInfo {
Collection<TypeInfo> typeinfos = typeinfos_map.get(param);
if (typeinfos != null) {
for (TypeInfo typeinfo : typeinfos) {
HashMap<ParameterDeclaration, TypeInfo> instance = (HashMap<ParameterDeclaration, TypeInfo>)current_instance.clone();
Map<ParameterDeclaration, TypeInfo> instance = new HashMap<ParameterDeclaration, TypeInfo>(current_instance);
instance.put(param, typeinfo);
getCrossProductRecursive(index + 1, parameters, typeinfos_map, instance, cross_product);
}

View File

@ -1825,8 +1825,8 @@ public class ContextCapabilities {
private boolean NV_vertex_array_range_initNativeFunctionAddresses() {
return
(NV_vertex_array_range_glFreeMemoryNV_pointer = GLContext.getFunctionAddress("glFreeMemoryNV")) != 0 &&
(NV_vertex_array_range_glAllocateMemoryNV_pointer = GLContext.getFunctionAddress("glAllocateMemoryNV")) != 0 &&
(NV_vertex_array_range_glFreeMemoryNV_pointer = GLContext.getPlatformSpecificFunctionAddress("gl", new String[]{"Windows", "Linux"}, new String[]{"wgl", "glX"}, "glFreeMemoryNV")) != 0 &&
(NV_vertex_array_range_glAllocateMemoryNV_pointer = GLContext.getPlatformSpecificFunctionAddress("gl", new String[]{"Windows", "Linux"}, new String[]{"wgl", "glX"}, "glAllocateMemoryNV")) != 0 &&
(NV_vertex_array_range_glFlushVertexArrayRangeNV_pointer = GLContext.getFunctionAddress("glFlushVertexArrayRangeNV")) != 0 &&
(NV_vertex_array_range_glVertexArrayRangeNV_pointer = GLContext.getFunctionAddress("glVertexArrayRangeNV")) != 0;
}

View File

@ -82,6 +82,21 @@ public final class GLContext {
current_capabilities.set(capabilities);
}
/**
* Helper method to get a pointer to a named function in the OpenGL library
* with a name dependent on the current platform
*/
static long getPlatformSpecificFunctionAddress(String function_prefix, String[] os_prefixes, String[] os_function_prefixes, String function) {
String os_name = System.getProperty("os.name");
for (int i = 0; i < os_prefixes.length; i++)
if (os_name.startsWith(os_prefixes[i])) {
String platform_function_name = function.replaceFirst(function_prefix, os_function_prefixes[i]);
long address = getFunctionAddress(platform_function_name);
return address;
}
return 0;
}
/**
* Helper method to get a pointer to a named function in the OpenGL library
*/