From 55b4e553c8e6021cb65a9ac99857bfbf4d4f335d Mon Sep 17 00:00:00 2001 From: Thomas Tafertshofer Date: Thu, 19 Jul 2012 16:50:08 -0700 Subject: [PATCH] glgen stubs to fix bad methods in gles20 bindings this adds correct versions of the broken GLES20 methods glGetShaderSource, glGetActiveAttrib and glGetActiveUniform. the old broken methods are still there and need to be @hide later. Bug: 6006380 Change-Id: Ide74242ada54b85459b459ae4f20cd26a23c7610 --- .../glgen/stubs/gles11/glGetActiveAttrib.cpp | 328 +++++++++++++++++ .../glgen/stubs/gles11/glGetActiveAttrib.java | 47 +++ .../stubs/gles11/glGetActiveAttrib.nativeReg | 4 + .../glgen/stubs/gles11/glGetActiveUniform.cpp | 329 ++++++++++++++++++ .../stubs/gles11/glGetActiveUniform.java | 46 +++ .../stubs/gles11/glGetActiveUniform.nativeReg | 4 + .../glgen/stubs/gles11/glGetShaderSource.cpp | 111 ++++++ .../glgen/stubs/gles11/glGetShaderSource.java | 25 ++ .../stubs/gles11/glGetShaderSource.nativeReg | 3 + 9 files changed, 897 insertions(+) create mode 100644 opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.cpp create mode 100644 opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.java create mode 100644 opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.nativeReg create mode 100644 opengl/tools/glgen/stubs/gles11/glGetActiveUniform.cpp create mode 100644 opengl/tools/glgen/stubs/gles11/glGetActiveUniform.java create mode 100644 opengl/tools/glgen/stubs/gles11/glGetActiveUniform.nativeReg create mode 100644 opengl/tools/glgen/stubs/gles11/glGetShaderSource.cpp create mode 100644 opengl/tools/glgen/stubs/gles11/glGetShaderSource.java create mode 100644 opengl/tools/glgen/stubs/gles11/glGetShaderSource.nativeReg diff --git a/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.cpp b/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.cpp new file mode 100644 index 000000000..27b91fc56 --- /dev/null +++ b/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.cpp @@ -0,0 +1,328 @@ +/* void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */ +static void +android_glGetActiveAttrib__III_3II_3II_3II_3BI + (JNIEnv *_env, jobject _this, jint program, jint index, jint bufsize, jintArray length_ref, jint lengthOffset, jintArray size_ref, jint sizeOffset, jintArray type_ref, jint typeOffset, jbyteArray name_ref, jint nameOffset) { + jint _exception = 0; + const char * _exceptionType; + const char * _exceptionMessage; + GLsizei *length_base = (GLsizei *) 0; + jint _lengthRemaining; + GLsizei *length = (GLsizei *) 0; + GLint *size_base = (GLint *) 0; + jint _sizeRemaining; + GLint *size = (GLint *) 0; + GLenum *type_base = (GLenum *) 0; + jint _typeRemaining; + GLenum *type = (GLenum *) 0; + char *name_base = (char *) 0; + jint _nameRemaining; + char *name = (char *) 0; + + if (!length_ref) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "length == null"; + goto exit; + } + if (lengthOffset < 0) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "lengthOffset < 0"; + goto exit; + } + _lengthRemaining = _env->GetArrayLength(length_ref) - lengthOffset; + length_base = (GLsizei *) + _env->GetPrimitiveArrayCritical(length_ref, (jboolean *)0); + length = length_base + lengthOffset; + + if (!size_ref) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "size == null"; + goto exit; + } + if (sizeOffset < 0) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "sizeOffset < 0"; + goto exit; + } + _sizeRemaining = _env->GetArrayLength(size_ref) - sizeOffset; + size_base = (GLint *) + _env->GetPrimitiveArrayCritical(size_ref, (jboolean *)0); + size = size_base + sizeOffset; + + if (!type_ref) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "type == null"; + goto exit; + } + if (typeOffset < 0) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "typeOffset < 0"; + goto exit; + } + _typeRemaining = _env->GetArrayLength(type_ref) - typeOffset; + type_base = (GLenum *) + _env->GetPrimitiveArrayCritical(type_ref, (jboolean *)0); + type = type_base + typeOffset; + + if (!name_ref) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "name == null"; + goto exit; + } + if (nameOffset < 0) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "nameOffset < 0"; + goto exit; + } + _nameRemaining = _env->GetArrayLength(name_ref) - nameOffset; + name_base = (char *) + _env->GetPrimitiveArrayCritical(name_ref, (jboolean *)0); + name = name_base + nameOffset; + + glGetActiveAttrib( + (GLuint)program, + (GLuint)index, + (GLsizei)bufsize, + (GLsizei *)length, + (GLint *)size, + (GLenum *)type, + (char *)name + ); + +exit: + if (name_base) { + _env->ReleasePrimitiveArrayCritical(name_ref, name_base, + _exception ? JNI_ABORT: 0); + } + if (type_base) { + _env->ReleasePrimitiveArrayCritical(type_ref, type_base, + _exception ? JNI_ABORT: 0); + } + if (size_base) { + _env->ReleasePrimitiveArrayCritical(size_ref, size_base, + _exception ? JNI_ABORT: 0); + } + if (length_base) { + _env->ReleasePrimitiveArrayCritical(length_ref, length_base, + _exception ? JNI_ABORT: 0); + } + if (_exception) { + jniThrowException(_env, _exceptionType, _exceptionMessage); + } +} + +/* void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */ +static void +android_glGetActiveAttrib__IIILjava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2B + (JNIEnv *_env, jobject _this, jint program, jint index, jint bufsize, jobject length_buf, jobject size_buf, jobject type_buf, jbyte name) { + jarray _lengthArray = (jarray) 0; + jint _lengthBufferOffset = (jint) 0; + jarray _sizeArray = (jarray) 0; + jint _sizeBufferOffset = (jint) 0; + jarray _typeArray = (jarray) 0; + jint _typeBufferOffset = (jint) 0; + jint _lengthRemaining; + GLsizei *length = (GLsizei *) 0; + jint _sizeRemaining; + GLint *size = (GLint *) 0; + jint _typeRemaining; + GLenum *type = (GLenum *) 0; + + length = (GLsizei *)getPointer(_env, length_buf, &_lengthArray, &_lengthRemaining, &_lengthBufferOffset); + size = (GLint *)getPointer(_env, size_buf, &_sizeArray, &_sizeRemaining, &_sizeBufferOffset); + type = (GLenum *)getPointer(_env, type_buf, &_typeArray, &_typeRemaining, &_typeBufferOffset); + if (length == NULL) { + char * _lengthBase = (char *)_env->GetPrimitiveArrayCritical(_lengthArray, (jboolean *) 0); + length = (GLsizei *) (_lengthBase + _lengthBufferOffset); + } + if (size == NULL) { + char * _sizeBase = (char *)_env->GetPrimitiveArrayCritical(_sizeArray, (jboolean *) 0); + size = (GLint *) (_sizeBase + _sizeBufferOffset); + } + if (type == NULL) { + char * _typeBase = (char *)_env->GetPrimitiveArrayCritical(_typeArray, (jboolean *) 0); + type = (GLenum *) (_typeBase + _typeBufferOffset); + } + glGetActiveAttrib( + (GLuint)program, + (GLuint)index, + (GLsizei)bufsize, + (GLsizei *)length, + (GLint *)size, + (GLenum *)type, + (char *)name + ); + if (_typeArray) { + releasePointer(_env, _typeArray, type, JNI_TRUE); + } + if (_sizeArray) { + releasePointer(_env, _sizeArray, size, JNI_TRUE); + } + if (_lengthArray) { + releasePointer(_env, _lengthArray, length, JNI_TRUE); + } +} + +/* void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */ +static jstring +android_glGetActiveAttrib1 + (JNIEnv *_env, jobject _this, jint program, jint index, jintArray size_ref, jint sizeOffset, jintArray type_ref, jint typeOffset) { + jint _exception = 0; + const char * _exceptionType; + const char * _exceptionMessage; + GLint *size_base = (GLint *) 0; + jint _sizeRemaining; + GLint *size = (GLint *) 0; + GLenum *type_base = (GLenum *) 0; + jint _typeRemaining; + GLenum *type = (GLenum *) 0; + + jstring result = 0; + + GLint len = 0; + glGetProgramiv((GLuint)program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &len); + if (!len) { + return _env->NewStringUTF(""); + } + char* buf = (char*) malloc(len); + + if (buf == NULL) { + jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory"); + return NULL; + } + if (!size_ref) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "size == null"; + goto exit; + } + if (sizeOffset < 0) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "sizeOffset < 0"; + goto exit; + } + _sizeRemaining = _env->GetArrayLength(size_ref) - sizeOffset; + size_base = (GLint *) + _env->GetPrimitiveArrayCritical(size_ref, (jboolean *)0); + size = size_base + sizeOffset; + + if (!type_ref) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "type == null"; + goto exit; + } + if (typeOffset < 0) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "typeOffset < 0"; + goto exit; + } + _typeRemaining = _env->GetArrayLength(type_ref) - typeOffset; + type_base = (GLenum *) + _env->GetPrimitiveArrayCritical(type_ref, (jboolean *)0); + type = type_base + typeOffset; + + glGetActiveAttrib( + (GLuint)program, + (GLuint)index, + (GLsizei)len, + NULL, + (GLint *)size, + (GLenum *)type, + (char *)buf + ); +exit: + if (type_base) { + _env->ReleasePrimitiveArrayCritical(type_ref, type_base, + _exception ? JNI_ABORT: 0); + } + if (size_base) { + _env->ReleasePrimitiveArrayCritical(size_ref, size_base, + _exception ? JNI_ABORT: 0); + } + if (_exception != 1) { + result = _env->NewStringUTF(buf); + } + if (buf) { + free(buf); + } + if (_exception) { + jniThrowException(_env, _exceptionType, _exceptionMessage); + } + if (result == 0) { + result = _env->NewStringUTF(""); + } + + return result; +} + +/* void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */ +static jstring +android_glGetActiveAttrib2 + (JNIEnv *_env, jobject _this, jint program, jint index, jobject size_buf, jobject type_buf) { + jarray _sizeArray = (jarray) 0; + jint _sizeBufferOffset = (jint) 0; + jarray _typeArray = (jarray) 0; + jint _typeBufferOffset = (jint) 0; + jint _lengthRemaining; + GLsizei *length = (GLsizei *) 0; + jint _sizeRemaining; + GLint *size = (GLint *) 0; + jint _typeRemaining; + GLenum *type = (GLenum *) 0; + + jstring result = 0; + + GLint len = 0; + glGetProgramiv((GLuint)program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &len); + if (!len) { + return _env->NewStringUTF(""); + } + char* buf = (char*) malloc(len); + + if (buf == NULL) { + jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory"); + return NULL; + } + + size = (GLint *)getPointer(_env, size_buf, &_sizeArray, &_sizeRemaining, &_sizeBufferOffset); + type = (GLenum *)getPointer(_env, type_buf, &_typeArray, &_typeRemaining, &_typeBufferOffset); + if (size == NULL) { + char * _sizeBase = (char *)_env->GetPrimitiveArrayCritical(_sizeArray, (jboolean *) 0); + size = (GLint *) (_sizeBase + _sizeBufferOffset); + } + if (type == NULL) { + char * _typeBase = (char *)_env->GetPrimitiveArrayCritical(_typeArray, (jboolean *) 0); + type = (GLenum *) (_typeBase + _typeBufferOffset); + } + glGetActiveAttrib( + (GLuint)program, + (GLuint)index, + (GLsizei)len, + NULL, + (GLint *)size, + (GLenum *)type, + (char *)buf + ); + + if (_typeArray) { + releasePointer(_env, _typeArray, type, JNI_TRUE); + } + if (_sizeArray) { + releasePointer(_env, _sizeArray, size, JNI_TRUE); + } + result = _env->NewStringUTF(buf); + if (buf) { + free(buf); + } + return result; +} diff --git a/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.java b/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.java new file mode 100644 index 000000000..bad213723 --- /dev/null +++ b/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.java @@ -0,0 +1,47 @@ + // C function void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) + + public static native void glGetActiveAttrib( + int program, + int index, + int bufsize, + int[] length, + int lengthOffset, + int[] size, + int sizeOffset, + int[] type, + int typeOffset, + byte[] name, + int nameOffset + ); + + // C function void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) + + public static native void glGetActiveAttrib( + int program, + int index, + int bufsize, + java.nio.IntBuffer length, + java.nio.IntBuffer size, + java.nio.IntBuffer type, + byte name + ); + + // C function void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) + + public static native String glGetActiveAttrib( + int program, + int index, + int[] size, + int sizeOffset, + int[] type, + int typeOffset + ); + + // C function void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) + + public static native String glGetActiveAttrib( + int program, + int index, + java.nio.IntBuffer size, + java.nio.IntBuffer type + ); diff --git a/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.nativeReg b/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.nativeReg new file mode 100644 index 000000000..f54c0a056 --- /dev/null +++ b/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.nativeReg @@ -0,0 +1,4 @@ +{"glGetActiveAttrib", "(III[II[II[II[BI)V", (void *) android_glGetActiveAttrib__III_3II_3II_3II_3BI }, +{"glGetActiveAttrib", "(IIILjava/nio/IntBuffer;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;B)V", (void *) android_glGetActiveAttrib__IIILjava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2B }, +{"glGetActiveAttrib", "(II[II[II)Ljava/lang/String;", (void *) android_glGetActiveAttrib1 }, +{"glGetActiveAttrib", "(IILjava/nio/IntBuffer;Ljava/nio/IntBuffer;)Ljava/lang/String;", (void *) android_glGetActiveAttrib2 }, diff --git a/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.cpp b/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.cpp new file mode 100644 index 000000000..58f704c17 --- /dev/null +++ b/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.cpp @@ -0,0 +1,329 @@ +/* void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */ +static void +android_glGetActiveUniform__III_3II_3II_3II_3BI + (JNIEnv *_env, jobject _this, jint program, jint index, jint bufsize, jintArray length_ref, jint lengthOffset, jintArray size_ref, jint sizeOffset, jintArray type_ref, jint typeOffset, jbyteArray name_ref, jint nameOffset) { + jint _exception = 0; + const char * _exceptionType; + const char * _exceptionMessage; + GLsizei *length_base = (GLsizei *) 0; + jint _lengthRemaining; + GLsizei *length = (GLsizei *) 0; + GLint *size_base = (GLint *) 0; + jint _sizeRemaining; + GLint *size = (GLint *) 0; + GLenum *type_base = (GLenum *) 0; + jint _typeRemaining; + GLenum *type = (GLenum *) 0; + char *name_base = (char *) 0; + jint _nameRemaining; + char *name = (char *) 0; + + if (!length_ref) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "length == null"; + goto exit; + } + if (lengthOffset < 0) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "lengthOffset < 0"; + goto exit; + } + _lengthRemaining = _env->GetArrayLength(length_ref) - lengthOffset; + length_base = (GLsizei *) + _env->GetPrimitiveArrayCritical(length_ref, (jboolean *)0); + length = length_base + lengthOffset; + + if (!size_ref) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "size == null"; + goto exit; + } + if (sizeOffset < 0) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "sizeOffset < 0"; + goto exit; + } + _sizeRemaining = _env->GetArrayLength(size_ref) - sizeOffset; + size_base = (GLint *) + _env->GetPrimitiveArrayCritical(size_ref, (jboolean *)0); + size = size_base + sizeOffset; + + if (!type_ref) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "type == null"; + goto exit; + } + if (typeOffset < 0) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "typeOffset < 0"; + goto exit; + } + _typeRemaining = _env->GetArrayLength(type_ref) - typeOffset; + type_base = (GLenum *) + _env->GetPrimitiveArrayCritical(type_ref, (jboolean *)0); + type = type_base + typeOffset; + + if (!name_ref) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "name == null"; + goto exit; + } + if (nameOffset < 0) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "nameOffset < 0"; + goto exit; + } + _nameRemaining = _env->GetArrayLength(name_ref) - nameOffset; + name_base = (char *) + _env->GetPrimitiveArrayCritical(name_ref, (jboolean *)0); + name = name_base + nameOffset; + + glGetActiveUniform( + (GLuint)program, + (GLuint)index, + (GLsizei)bufsize, + (GLsizei *)length, + (GLint *)size, + (GLenum *)type, + (char *)name + ); + +exit: + if (name_base) { + _env->ReleasePrimitiveArrayCritical(name_ref, name_base, + _exception ? JNI_ABORT: 0); + } + if (type_base) { + _env->ReleasePrimitiveArrayCritical(type_ref, type_base, + _exception ? JNI_ABORT: 0); + } + if (size_base) { + _env->ReleasePrimitiveArrayCritical(size_ref, size_base, + _exception ? JNI_ABORT: 0); + } + if (length_base) { + _env->ReleasePrimitiveArrayCritical(length_ref, length_base, + _exception ? JNI_ABORT: 0); + } + if (_exception) { + jniThrowException(_env, _exceptionType, _exceptionMessage); + } +} + +/* void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */ +static void +android_glGetActiveUniform__IIILjava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2B + (JNIEnv *_env, jobject _this, jint program, jint index, jint bufsize, jobject length_buf, jobject size_buf, jobject type_buf, jbyte name) { + jarray _lengthArray = (jarray) 0; + jint _lengthBufferOffset = (jint) 0; + jarray _sizeArray = (jarray) 0; + jint _sizeBufferOffset = (jint) 0; + jarray _typeArray = (jarray) 0; + jint _typeBufferOffset = (jint) 0; + jint _lengthRemaining; + GLsizei *length = (GLsizei *) 0; + jint _sizeRemaining; + GLint *size = (GLint *) 0; + jint _typeRemaining; + GLenum *type = (GLenum *) 0; + + length = (GLsizei *)getPointer(_env, length_buf, &_lengthArray, &_lengthRemaining, &_lengthBufferOffset); + size = (GLint *)getPointer(_env, size_buf, &_sizeArray, &_sizeRemaining, &_sizeBufferOffset); + type = (GLenum *)getPointer(_env, type_buf, &_typeArray, &_typeRemaining, &_typeBufferOffset); + if (length == NULL) { + char * _lengthBase = (char *)_env->GetPrimitiveArrayCritical(_lengthArray, (jboolean *) 0); + length = (GLsizei *) (_lengthBase + _lengthBufferOffset); + } + if (size == NULL) { + char * _sizeBase = (char *)_env->GetPrimitiveArrayCritical(_sizeArray, (jboolean *) 0); + size = (GLint *) (_sizeBase + _sizeBufferOffset); + } + if (type == NULL) { + char * _typeBase = (char *)_env->GetPrimitiveArrayCritical(_typeArray, (jboolean *) 0); + type = (GLenum *) (_typeBase + _typeBufferOffset); + } + glGetActiveUniform( + (GLuint)program, + (GLuint)index, + (GLsizei)bufsize, + (GLsizei *)length, + (GLint *)size, + (GLenum *)type, + (char *)name + ); + if (_typeArray) { + releasePointer(_env, _typeArray, type, JNI_TRUE); + } + if (_sizeArray) { + releasePointer(_env, _sizeArray, size, JNI_TRUE); + } + if (_lengthArray) { + releasePointer(_env, _lengthArray, length, JNI_TRUE); + } +} + +/* void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */ +static jstring +android_glGetActiveUniform1 + (JNIEnv *_env, jobject _this, jint program, jint index, jintArray size_ref, jint sizeOffset, jintArray type_ref, jint typeOffset) { + jint _exception = 0; + const char * _exceptionType; + const char * _exceptionMessage; + + GLint *size_base = (GLint *) 0; + jint _sizeRemaining; + GLint *size = (GLint *) 0; + + GLenum *type_base = (GLenum *) 0; + jint _typeRemaining; + GLenum *type = (GLenum *) 0; + + jstring result = 0; + + GLint len = 0; + glGetProgramiv((GLuint)program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &len); + if (!len) { + return _env->NewStringUTF(""); + } + char* buf = (char*) malloc(len); + + if (buf == NULL) { + jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory"); + return NULL; + } + + if (!size_ref) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "size == null"; + goto exit; + } + if (sizeOffset < 0) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "sizeOffset < 0"; + goto exit; + } + _sizeRemaining = _env->GetArrayLength(size_ref) - sizeOffset; + size_base = (GLint *) + _env->GetPrimitiveArrayCritical(size_ref, (jboolean *)0); + size = size_base + sizeOffset; + + if (!type_ref) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "type == null"; + goto exit; + } + if (typeOffset < 0) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "typeOffset < 0"; + goto exit; + } + _typeRemaining = _env->GetArrayLength(type_ref) - typeOffset; + type_base = (GLenum *) + _env->GetPrimitiveArrayCritical(type_ref, (jboolean *)0); + type = type_base + typeOffset; + + glGetActiveUniform( + (GLuint)program, + (GLuint)index, + (GLsizei)len, + NULL, + (GLint *)size, + (GLenum *)type, + (char *)buf + ); + +exit: + if (type_base) { + _env->ReleasePrimitiveArrayCritical(type_ref, type_base, + _exception ? JNI_ABORT: 0); + } + if (size_base) { + _env->ReleasePrimitiveArrayCritical(size_ref, size_base, + _exception ? JNI_ABORT: 0); + } + if (_exception != 1) { + result = _env->NewStringUTF(buf); + } + if (buf) { + free(buf); + } + if (_exception) { + jniThrowException(_env, _exceptionType, _exceptionMessage); + } + if (result == 0) { + result = _env->NewStringUTF(""); + } + return result; +} + +/* void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */ +static jstring +android_glGetActiveUniform2 + (JNIEnv *_env, jobject _this, jint program, jint index, jobject size_buf, jobject type_buf) { + jarray _sizeArray = (jarray) 0; + jint _sizeBufferOffset = (jint) 0; + jarray _typeArray = (jarray) 0; + jint _typeBufferOffset = (jint) 0; + jint _sizeRemaining; + GLint *size = (GLint *) 0; + jint _typeRemaining; + GLenum *type = (GLenum *) 0; + + jstring result = 0; + GLint len = 0; + glGetProgramiv((GLuint)program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &len); + if (!len) { + return _env->NewStringUTF(""); + } + char* buf = (char*) malloc(len); + + if (buf == NULL) { + jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory"); + return NULL; + } + + size = (GLint *)getPointer(_env, size_buf, &_sizeArray, &_sizeRemaining, &_sizeBufferOffset); + type = (GLenum *)getPointer(_env, type_buf, &_typeArray, &_typeRemaining, &_typeBufferOffset); + + if (size == NULL) { + char * _sizeBase = (char *)_env->GetPrimitiveArrayCritical(_sizeArray, (jboolean *) 0); + size = (GLint *) (_sizeBase + _sizeBufferOffset); + } + if (type == NULL) { + char * _typeBase = (char *)_env->GetPrimitiveArrayCritical(_typeArray, (jboolean *) 0); + type = (GLenum *) (_typeBase + _typeBufferOffset); + } + glGetActiveUniform( + (GLuint)program, + (GLuint)index, + len, + NULL, + (GLint *)size, + (GLenum *)type, + (char *)buf + ); + + if (_typeArray) { + releasePointer(_env, _typeArray, type, JNI_TRUE); + } + if (_sizeArray) { + releasePointer(_env, _sizeArray, size, JNI_TRUE); + } + result = _env->NewStringUTF(buf); + if (buf) { + free(buf); + } + return result; +} diff --git a/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.java b/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.java new file mode 100644 index 000000000..28aaa7804 --- /dev/null +++ b/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.java @@ -0,0 +1,46 @@ + // C function void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) + + public static native void glGetActiveUniform( + int program, + int index, + int bufsize, + int[] length, + int lengthOffset, + int[] size, + int sizeOffset, + int[] type, + int typeOffset, + byte[] name, + int nameOffset + ); + + // C function void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) + + public static native void glGetActiveUniform( + int program, + int index, + int bufsize, + java.nio.IntBuffer length, + java.nio.IntBuffer size, + java.nio.IntBuffer type, + byte name + ); + // C function void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) + + public static native String glGetActiveUniform( + int program, + int index, + int[] size, + int sizeOffset, + int[] type, + int typeOffset + ); + + // C function void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) + + public static native String glGetActiveUniform( + int program, + int index, + java.nio.IntBuffer size, + java.nio.IntBuffer type + ); diff --git a/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.nativeReg b/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.nativeReg new file mode 100644 index 000000000..f0b5fd957 --- /dev/null +++ b/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.nativeReg @@ -0,0 +1,4 @@ +{"glGetActiveUniform", "(III[II[II[II[BI)V", (void *) android_glGetActiveUniform__III_3II_3II_3II_3BI }, +{"glGetActiveUniform", "(II[II[II)Ljava/lang/String;", (void *) android_glGetActiveUniform1 }, +{"glGetActiveUniform", "(IIILjava/nio/IntBuffer;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;B)V", (void *) android_glGetActiveUniform__IIILjava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2B }, +{"glGetActiveUniform", "(IILjava/nio/IntBuffer;Ljava/nio/IntBuffer;)Ljava/lang/String;", (void *) android_glGetActiveUniform2 }, diff --git a/opengl/tools/glgen/stubs/gles11/glGetShaderSource.cpp b/opengl/tools/glgen/stubs/gles11/glGetShaderSource.cpp new file mode 100644 index 000000000..a7e1cd25e --- /dev/null +++ b/opengl/tools/glgen/stubs/gles11/glGetShaderSource.cpp @@ -0,0 +1,111 @@ +/* void glGetShaderSource ( GLuint shader, GLsizei bufsize, GLsizei *length, char *source ) */ +static void +android_glGetShaderSource__II_3II_3BI + (JNIEnv *_env, jobject _this, jint shader, jint bufsize, jintArray length_ref, jint lengthOffset, jbyteArray source_ref, jint sourceOffset) { + jint _exception = 0; + const char * _exceptionType; + const char * _exceptionMessage; + GLsizei *length_base = (GLsizei *) 0; + jint _lengthRemaining; + GLsizei *length = (GLsizei *) 0; + char *source_base = (char *) 0; + jint _sourceRemaining; + char *source = (char *) 0; + + if (!length_ref) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "length == null"; + goto exit; + } + if (lengthOffset < 0) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "lengthOffset < 0"; + goto exit; + } + _lengthRemaining = _env->GetArrayLength(length_ref) - lengthOffset; + length_base = (GLsizei *) + _env->GetPrimitiveArrayCritical(length_ref, (jboolean *)0); + length = length_base + lengthOffset; + + if (!source_ref) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "source == null"; + goto exit; + } + if (sourceOffset < 0) { + _exception = 1; + _exceptionType = "java/lang/IllegalArgumentException"; + _exceptionMessage = "sourceOffset < 0"; + goto exit; + } + _sourceRemaining = _env->GetArrayLength(source_ref) - sourceOffset; + source_base = (char *) + _env->GetPrimitiveArrayCritical(source_ref, (jboolean *)0); + source = source_base + sourceOffset; + + glGetShaderSource( + (GLuint)shader, + (GLsizei)bufsize, + (GLsizei *)length, + (char *)source + ); + +exit: + if (source_base) { + _env->ReleasePrimitiveArrayCritical(source_ref, source_base, + _exception ? JNI_ABORT: 0); + } + if (length_base) { + _env->ReleasePrimitiveArrayCritical(length_ref, length_base, + _exception ? JNI_ABORT: 0); + } + if (_exception) { + jniThrowException(_env, _exceptionType, _exceptionMessage); + } +} + +/* void glGetShaderSource ( GLuint shader, GLsizei bufsize, GLsizei *length, char *source ) */ +static void +android_glGetShaderSource__IILjava_nio_IntBuffer_2B + (JNIEnv *_env, jobject _this, jint shader, jint bufsize, jobject length_buf, jbyte source) { + jarray _array = (jarray) 0; + jint _bufferOffset = (jint) 0; + jint _remaining; + GLsizei *length = (GLsizei *) 0; + + length = (GLsizei *)getPointer(_env, length_buf, &_array, &_remaining, &_bufferOffset); + if (length == NULL) { + char * _lengthBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0); + length = (GLsizei *) (_lengthBase + _bufferOffset); + } + glGetShaderSource( + (GLuint)shader, + (GLsizei)bufsize, + (GLsizei *)length, + (char *)source + ); + if (_array) { + releasePointer(_env, _array, length, JNI_TRUE); + } +} + +/* void glGetShaderSource ( GLuint shader, GLsizei bufsize, GLsizei *length, char *source ) */ +static jstring android_glGetShaderSource(JNIEnv *_env, jobject, jint shader) { + GLint shaderLen = 0; + glGetShaderiv((GLuint)shader, GL_SHADER_SOURCE_LENGTH, &shaderLen); + if (!shaderLen) { + return _env->NewStringUTF(""); + } + char* buf = (char*) malloc(shaderLen); + if (buf == NULL) { + jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory"); + return NULL; + } + glGetShaderSource(shader, shaderLen, NULL, buf); + jstring result = _env->NewStringUTF(buf); + free(buf); + return result; +} diff --git a/opengl/tools/glgen/stubs/gles11/glGetShaderSource.java b/opengl/tools/glgen/stubs/gles11/glGetShaderSource.java new file mode 100644 index 000000000..199d93abb --- /dev/null +++ b/opengl/tools/glgen/stubs/gles11/glGetShaderSource.java @@ -0,0 +1,25 @@ + // C function void glGetShaderSource ( GLuint shader, GLsizei bufsize, GLsizei *length, char *source ) + + public static native void glGetShaderSource( + int shader, + int bufsize, + int[] length, + int lengthOffset, + byte[] source, + int sourceOffset + ); + + // C function void glGetShaderSource ( GLuint shader, GLsizei bufsize, GLsizei *length, char *source ) + + public static native void glGetShaderSource( + int shader, + int bufsize, + java.nio.IntBuffer length, + byte source + ); + + // C function void glGetShaderSource ( GLuint shader, GLsizei bufsize, GLsizei *length, char *source ) + + public static native String glGetShaderSource( + int shader + ); diff --git a/opengl/tools/glgen/stubs/gles11/glGetShaderSource.nativeReg b/opengl/tools/glgen/stubs/gles11/glGetShaderSource.nativeReg new file mode 100644 index 000000000..acb47a592 --- /dev/null +++ b/opengl/tools/glgen/stubs/gles11/glGetShaderSource.nativeReg @@ -0,0 +1,3 @@ +{"glGetShaderSource", "(II[II[BI)V", (void *) android_glGetShaderSource__II_3II_3BI }, +{"glGetShaderSource", "(IILjava/nio/IntBuffer;B)V", (void *) android_glGetShaderSource__IILjava_nio_IntBuffer_2B }, +{"glGetShaderSource", "(I)Ljava/lang/String;", (void *) android_glGetShaderSource },