Added some alternate AL functions.

This commit is contained in:
Ioannis Tsakpinis 2010-03-16 17:58:48 +00:00
parent 94a4c50a83
commit 3715e4b39d
5 changed files with 42 additions and 12 deletions

View File

@ -153,6 +153,8 @@ final class ShaderUNI extends Shader {
}
void cleanup() {
GL15.glDeleteBuffers(bufferID);
GL20.glDetachShader(programID, shaderID);
GL20.glDeleteShader(shaderID);

View File

@ -173,9 +173,7 @@ public class GeneratorVisitor extends SimpleDeclarationVisitor {
writer.println("static " + Utils.getTypedefName(method) + " " + method.getSimpleName() + ";");
}
private void generateJavaSource(InterfaceDeclaration d) throws IOException {
validateMethods(d);
PrintWriter java_writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, d.getPackage().getQualifiedName(), new File(Utils.getSimpleClassName(d) + ".java"), null);
private void generateJavaSource(InterfaceDeclaration d, PrintWriter java_writer) throws IOException {
java_writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */");
java_writer.println();
java_writer.println("package " + d.getPackage().getQualifiedName() + ";");
@ -252,23 +250,25 @@ public class GeneratorVisitor extends SimpleDeclarationVisitor {
File input = d.getPosition().file();
File output = new File(env.getOptions().get("-s") + '/' + d.getPackage().getQualifiedName().replace('.', '/'), Utils.getSimpleClassName(d) + ".java");
PrintWriter java_writer = null;
try {
// Skip this class if the output exists and the input has not been modified.
if ( output.exists() && input.lastModified() < output.lastModified() )
return;
if (d.getMethods().size() > 0 || d.getFields().size() > 0)
generateJavaSource(d);
if (d.getMethods().size() > 0 || d.getFields().size() > 0) {
validateMethods(d);
java_writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, d.getPackage().getQualifiedName(), new File(Utils.getSimpleClassName(d) + ".java"), null);
generateJavaSource(d, java_writer);
}
if (d.getMethods().size() > 0)
generateNativeSource(d);
} catch (Exception e) {
try {
// If anything goes wrong mid-gen, delete output to allow regen next time we run.
if ( output.exists() )
output.delete();
} catch (Exception e2) {
// ignore
}
// If anything goes wrong mid-gen, delete output to allow regen next time we run.
if ( java_writer != null ) java_writer.close();
if ( output.exists() ) output.delete();
throw new RuntimeException(e);
}
}

View File

@ -73,6 +73,8 @@ public class JavaMethodsGenerator {
}
Alternate alt_annotation = method.getAnnotation(Alternate.class);
if ( alt_annotation == null || alt_annotation.nativeAlt() ) {
if ( alt_annotation != null && method.getSimpleName().equals(alt_annotation.value()) )
throw new RuntimeException("An alternate function with native code should have a different name than the main function.");
printJavaNativeStub(writer, method, Mode.NORMAL, generate_error_checks, context_specific);
if (Utils.hasMethodBufferObjectParameter(method)) {
printMethodWithMultiType(env, type_map, writer, interface_decl, method, TypeInfo.getDefaultTypeInfoMap(method), Mode.BUFFEROBJECT, generate_error_checks, context_specific);

View File

@ -52,6 +52,8 @@ public class RegisterStubsGenerator {
Iterator<? extends MethodDeclaration> it = d.getMethods().iterator();
while (it.hasNext()) {
MethodDeclaration method = it.next();
if ( method.getAnnotation(Alternate.class) != null )
continue;
EnumSet<Platform> platforms;
PlatformDependent platform_annotation = method.getAnnotation(PlatformDependent.class);
if (platform_annotation != null)

View File

@ -721,6 +721,10 @@ public interface AL10 {
@ALvoid
void alGenSources(@AutoSize("sources") @ALsizei int n, @OutParameter @ALuint IntBuffer sources);
@Alternate(value = "alGenSources", nativeAlt = true)
@ALvoid
void alGenSources2(@Constant("1") @ALsizei int n, @Result @ALuint int source);
/**
* The application requests deletion of a number of Sources by DeleteSources.
*
@ -729,6 +733,10 @@ public interface AL10 {
@ALvoid
void alDeleteSources(@AutoSize("sources") @ALsizei int n, @ALuint IntBuffer sources);
@Alternate(value = "alDeleteSources", nativeAlt = true)
@ALvoid
void alDeleteSources2(@Constant("1") @ALsizei int n, @Indirect @ALuint int source);
/**
* The application can verify whether a source name is valid using the IsSource query.
*
@ -945,6 +953,10 @@ public interface AL10 {
@ALvoid
void alGenBuffers(@AutoSize("buffers") @ALsizei int n, @OutParameter @ALuint IntBuffer buffers);
@Alternate(value = "alGenBuffers", nativeAlt = true)
@ALvoid
void alGenBuffers2(@Constant("1") @ALsizei int n, @Result @ALuint int buffer);
/**
* <p>
* The application requests deletion of a number of Buffers by calling DeleteBuffers.
@ -964,6 +976,10 @@ public interface AL10 {
@ALvoid
void alDeleteBuffers(@AutoSize("buffers") @ALsizei int n, @ALuint IntBuffer buffers);
@Alternate(value = "alDeleteBuffers", nativeAlt = true)
@ALvoid
void alDeleteBuffers2(@Constant("1") @ALsizei int n, @Indirect @ALuint int buffer);
/**
* The application can verify whether a buffer Name is valid using the IsBuffer query.
*
@ -1052,6 +1068,10 @@ public interface AL10 {
@ALvoid
void alSourceQueueBuffers(@ALuint int source, @AutoSize("buffers") @ALsizei int n, @ALuint IntBuffer buffers);
@Alternate(value = "alSourceQueueBuffers", nativeAlt = true)
@ALvoid
void alSourceQueueBuffers2(@ALuint int source, @Constant("1") @ALsizei int n, @Indirect @ALuint int buffer);
/**
* <p>
* Once a queue entry for a buffer has been appended to a queue and is pending
@ -1074,6 +1094,10 @@ public interface AL10 {
@ALvoid
void alSourceUnqueueBuffers(@ALuint int source, @AutoSize("buffers") @ALsizei int n, @OutParameter @ALuint IntBuffer buffers);
@Alternate(value = "alSourceUnqueueBuffers", nativeAlt = true)
@ALvoid
void alSourceUnqueueBuffers2(@ALuint int source, @Constant("1") @ALsizei int n, @Result @ALuint int buffer);
/**
* <p>
* Samples usually use the entire dynamic range of the chosen format/encoding,