1 /* void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */ 2 static void 3 android_glGetActiveUniform__III_3II_3II_3II_3BI 4 (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) { 5 jint _exception = 0; 6 const char * _exceptionType; 7 const char * _exceptionMessage; 8 GLsizei *length_base = (GLsizei *) 0; 9 jint _lengthRemaining; 10 GLsizei *length = (GLsizei *) 0; 11 GLint *size_base = (GLint *) 0; 12 jint _sizeRemaining; 13 GLint *size = (GLint *) 0; 14 GLenum *type_base = (GLenum *) 0; 15 jint _typeRemaining; 16 GLenum *type = (GLenum *) 0; 17 char *name_base = (char *) 0; 18 jint _nameRemaining; 19 char *name = (char *) 0; 20 21 if (!length_ref) { 22 _exception = 1; 23 _exceptionType = "java/lang/IllegalArgumentException"; 24 _exceptionMessage = "length == null"; 25 goto exit; 26 } 27 if (lengthOffset < 0) { 28 _exception = 1; 29 _exceptionType = "java/lang/IllegalArgumentException"; 30 _exceptionMessage = "lengthOffset < 0"; 31 goto exit; 32 } 33 _lengthRemaining = _env->GetArrayLength(length_ref) - lengthOffset; 34 length_base = (GLsizei *) 35 _env->GetIntArrayElements(length_ref, (jboolean *)0); 36 length = length_base + lengthOffset; 37 38 if (!size_ref) { 39 _exception = 1; 40 _exceptionType = "java/lang/IllegalArgumentException"; 41 _exceptionMessage = "size == null"; 42 goto exit; 43 } 44 if (sizeOffset < 0) { 45 _exception = 1; 46 _exceptionType = "java/lang/IllegalArgumentException"; 47 _exceptionMessage = "sizeOffset < 0"; 48 goto exit; 49 } 50 _sizeRemaining = _env->GetArrayLength(size_ref) - sizeOffset; 51 size_base = (GLint *) 52 _env->GetIntArrayElements(size_ref, (jboolean *)0); 53 size = size_base + sizeOffset; 54 55 if (!type_ref) { 56 _exception = 1; 57 _exceptionType = "java/lang/IllegalArgumentException"; 58 _exceptionMessage = "type == null"; 59 goto exit; 60 } 61 if (typeOffset < 0) { 62 _exception = 1; 63 _exceptionType = "java/lang/IllegalArgumentException"; 64 _exceptionMessage = "typeOffset < 0"; 65 goto exit; 66 } 67 _typeRemaining = _env->GetArrayLength(type_ref) - typeOffset; 68 type_base = (GLenum *) 69 _env->GetIntArrayElements(type_ref, (jboolean *)0); 70 type = type_base + typeOffset; 71 72 if (!name_ref) { 73 _exception = 1; 74 _exceptionType = "java/lang/IllegalArgumentException"; 75 _exceptionMessage = "name == null"; 76 goto exit; 77 } 78 if (nameOffset < 0) { 79 _exception = 1; 80 _exceptionType = "java/lang/IllegalArgumentException"; 81 _exceptionMessage = "nameOffset < 0"; 82 goto exit; 83 } 84 _nameRemaining = _env->GetArrayLength(name_ref) - nameOffset; 85 name_base = (char *) 86 _env->GetByteArrayElements(name_ref, (jboolean *)0); 87 name = name_base + nameOffset; 88 89 glGetActiveUniform( 90 (GLuint)program, 91 (GLuint)index, 92 (GLsizei)bufsize, 93 (GLsizei *)length, 94 (GLint *)size, 95 (GLenum *)type, 96 (char *)name 97 ); 98 99 exit: 100 if (name_base) { 101 _env->ReleaseByteArrayElements(name_ref, (jbyte*)name_base, 102 _exception ? JNI_ABORT: 0); 103 } 104 if (type_base) { 105 _env->ReleaseIntArrayElements(type_ref, (jint*)type_base, 106 _exception ? JNI_ABORT: 0); 107 } 108 if (size_base) { 109 _env->ReleaseIntArrayElements(size_ref, (jint*)size_base, 110 _exception ? JNI_ABORT: 0); 111 } 112 if (length_base) { 113 _env->ReleaseIntArrayElements(length_ref, (jint*)length_base, 114 _exception ? JNI_ABORT: 0); 115 } 116 if (_exception) { 117 jniThrowException(_env, _exceptionType, _exceptionMessage); 118 } 119 } 120 121 /* void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */ 122 static void 123 android_glGetActiveUniform__IIILjava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2B 124 (JNIEnv *_env, jobject _this, jint program, jint index, jint bufsize, jobject length_buf, jobject size_buf, jobject type_buf, jbyte name) { 125 jintArray _lengthArray = (jintArray) 0; 126 jint _lengthBufferOffset = (jint) 0; 127 jintArray _sizeArray = (jintArray) 0; 128 jint _sizeBufferOffset = (jint) 0; 129 jintArray _typeArray = (jintArray) 0; 130 jint _typeBufferOffset = (jint) 0; 131 jint _lengthRemaining; 132 GLsizei *length = (GLsizei *) 0; 133 jint _sizeRemaining; 134 GLint *size = (GLint *) 0; 135 jint _typeRemaining; 136 GLenum *type = (GLenum *) 0; 137 138 length = (GLsizei *)getPointer(_env, length_buf, (jarray*)&_lengthArray, &_lengthRemaining, &_lengthBufferOffset); 139 size = (GLint *)getPointer(_env, size_buf, (jarray*)&_sizeArray, &_sizeRemaining, &_sizeBufferOffset); 140 type = (GLenum *)getPointer(_env, type_buf, (jarray*)&_typeArray, &_typeRemaining, &_typeBufferOffset); 141 if (length == NULL) { 142 char * _lengthBase = (char *)_env->GetIntArrayElements(_lengthArray, (jboolean *) 0); 143 length = (GLsizei *) (_lengthBase + _lengthBufferOffset); 144 } 145 if (size == NULL) { 146 char * _sizeBase = (char *)_env->GetIntArrayElements(_sizeArray, (jboolean *) 0); 147 size = (GLint *) (_sizeBase + _sizeBufferOffset); 148 } 149 if (type == NULL) { 150 char * _typeBase = (char *)_env->GetIntArrayElements(_typeArray, (jboolean *) 0); 151 type = (GLenum *) (_typeBase + _typeBufferOffset); 152 } 153 glGetActiveUniform( 154 (GLuint)program, 155 (GLuint)index, 156 (GLsizei)bufsize, 157 (GLsizei *)length, 158 (GLint *)size, 159 (GLenum *)type, 160 reinterpret_cast<char *>(name) 161 ); 162 if (_typeArray) { 163 releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _typeArray, (jint*)type, JNI_TRUE); 164 } 165 if (_sizeArray) { 166 releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _sizeArray, (jint*)size, JNI_TRUE); 167 } 168 if (_lengthArray) { 169 releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _lengthArray, (jint*)length, JNI_TRUE); 170 } 171 } 172 173 /* void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */ 174 static jstring 175 android_glGetActiveUniform1 176 (JNIEnv *_env, jobject _this, jint program, jint index, jintArray size_ref, jint sizeOffset, jintArray type_ref, jint typeOffset) { 177 jint _exception = 0; 178 const char * _exceptionType; 179 const char * _exceptionMessage; 180 181 GLint *size_base = (GLint *) 0; 182 jint _sizeRemaining; 183 GLint *size = (GLint *) 0; 184 185 GLenum *type_base = (GLenum *) 0; 186 jint _typeRemaining; 187 GLenum *type = (GLenum *) 0; 188 189 jstring result = 0; 190 191 GLint len = 0; 192 glGetProgramiv((GLuint)program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &len); 193 if (!len) { 194 return _env->NewStringUTF(""); 195 } 196 char* buf = (char*) malloc(len); 197 198 if (buf == NULL) { 199 jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory"); 200 return NULL; 201 } 202 203 if (!size_ref) { 204 _exception = 1; 205 _exceptionType = "java/lang/IllegalArgumentException"; 206 _exceptionMessage = "size == null"; 207 goto exit; 208 } 209 if (sizeOffset < 0) { 210 _exception = 1; 211 _exceptionType = "java/lang/IllegalArgumentException"; 212 _exceptionMessage = "sizeOffset < 0"; 213 goto exit; 214 } 215 _sizeRemaining = _env->GetArrayLength(size_ref) - sizeOffset; 216 size_base = (GLint *) 217 _env->GetIntArrayElements(size_ref, (jboolean *)0); 218 size = size_base + sizeOffset; 219 220 if (!type_ref) { 221 _exception = 1; 222 _exceptionType = "java/lang/IllegalArgumentException"; 223 _exceptionMessage = "type == null"; 224 goto exit; 225 } 226 if (typeOffset < 0) { 227 _exception = 1; 228 _exceptionType = "java/lang/IllegalArgumentException"; 229 _exceptionMessage = "typeOffset < 0"; 230 goto exit; 231 } 232 _typeRemaining = _env->GetArrayLength(type_ref) - typeOffset; 233 type_base = (GLenum *) 234 _env->GetIntArrayElements(type_ref, (jboolean *)0); 235 type = type_base + typeOffset; 236 237 glGetActiveUniform( 238 (GLuint)program, 239 (GLuint)index, 240 (GLsizei)len, 241 NULL, 242 (GLint *)size, 243 (GLenum *)type, 244 (char *)buf 245 ); 246 247 exit: 248 if (type_base) { 249 _env->ReleaseIntArrayElements(type_ref, (jint*)type_base, 250 _exception ? JNI_ABORT: 0); 251 } 252 if (size_base) { 253 _env->ReleaseIntArrayElements(size_ref, (jint*)size_base, 254 _exception ? JNI_ABORT: 0); 255 } 256 if (_exception != 1) { 257 result = _env->NewStringUTF(buf); 258 } 259 if (buf) { 260 free(buf); 261 } 262 if (_exception) { 263 jniThrowException(_env, _exceptionType, _exceptionMessage); 264 } 265 if (result == 0) { 266 result = _env->NewStringUTF(""); 267 } 268 return result; 269 } 270 271 /* void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */ 272 static jstring 273 android_glGetActiveUniform2 274 (JNIEnv *_env, jobject _this, jint program, jint index, jobject size_buf, jobject type_buf) { 275 jintArray _sizeArray = (jintArray) 0; 276 jint _sizeBufferOffset = (jint) 0; 277 jintArray _typeArray = (jintArray) 0; 278 jint _typeBufferOffset = (jint) 0; 279 jint _sizeRemaining; 280 GLint *size = (GLint *) 0; 281 jint _typeRemaining; 282 GLenum *type = (GLenum *) 0; 283 284 jstring result = 0; 285 GLint len = 0; 286 glGetProgramiv((GLuint)program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &len); 287 if (!len) { 288 return _env->NewStringUTF(""); 289 } 290 char* buf = (char*) malloc(len); 291 292 if (buf == NULL) { 293 jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory"); 294 return NULL; 295 } 296 297 size = (GLint *)getPointer(_env, size_buf, (jarray*)&_sizeArray, &_sizeRemaining, &_sizeBufferOffset); 298 type = (GLenum *)getPointer(_env, type_buf, (jarray*)&_typeArray, &_typeRemaining, &_typeBufferOffset); 299 300 if (size == NULL) { 301 char * _sizeBase = (char *)_env->GetIntArrayElements(_sizeArray, (jboolean *) 0); 302 size = (GLint *) (_sizeBase + _sizeBufferOffset); 303 } 304 if (type == NULL) { 305 char * _typeBase = (char *)_env->GetIntArrayElements(_typeArray, (jboolean *) 0); 306 type = (GLenum *) (_typeBase + _typeBufferOffset); 307 } 308 glGetActiveUniform( 309 (GLuint)program, 310 (GLuint)index, 311 len, 312 NULL, 313 (GLint *)size, 314 (GLenum *)type, 315 (char *)buf 316 ); 317 318 if (_typeArray) { 319 releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _typeArray, (jint*)type, JNI_TRUE); 320 } 321 if (_sizeArray) { 322 releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _sizeArray, (jint*)size, JNI_TRUE); 323 } 324 result = _env->NewStringUTF(buf); 325 if (buf) { 326 free(buf); 327 } 328 return result; 329 } 330