1/* GLuint glCreateShaderProgramv ( GLenum type, GLsizei count, const GLchar *const *strings ) */ 2static jint 3android_glCreateShaderProgramv 4 (JNIEnv *_env, jobject _this, jint type, jobjectArray strings) { 5 jint _exception = 0; 6 const char * _exceptionType = NULL; 7 const char * _exceptionMessage = NULL; 8 GLsizei _count; 9 const GLchar** _strings = NULL; 10 jstring* _jstrings = NULL; 11 GLuint _returnValue = 0; 12 13 if (!strings) { 14 _exception = 1; 15 _exceptionType = "java/lang/IllegalArgumentException"; 16 _exceptionMessage = "strings == null"; 17 goto exit; 18 } 19 20 _count = _env->GetArrayLength(strings); 21 22 _strings = (const GLchar**) calloc(_count, sizeof(const GLchar*)); 23 if (!_strings) { 24 _exception = 1; 25 _exceptionType = "java/lang/OutOfMemoryError"; 26 _exceptionMessage = "out of memory"; 27 goto exit; 28 } 29 30 _jstrings = (jstring*) calloc(_count, sizeof(jstring)); 31 if (!_jstrings) { 32 _exception = 1; 33 _exceptionType = "java/lang/OutOfMemoryError"; 34 _exceptionMessage = "out of memory"; 35 goto exit; 36 } 37 38 for(int i = 0; i < _count; i++) { 39 _jstrings[i] = (jstring) _env->GetObjectArrayElement(strings, i); 40 if (!_jstrings[i]) { 41 _exception = 1; 42 _exceptionType = "java/lang/IllegalArgumentException"; 43 _exceptionMessage = "strings == null"; 44 goto exit; 45 } 46 _strings[i] = _env->GetStringUTFChars(_jstrings[i], 0); 47 } 48 49 _returnValue = glCreateShaderProgramv((GLenum)type, _count, _strings); 50exit: 51 if (_strings && _jstrings) { 52 for(int i = 0; i < _count; i++) { 53 if (_strings[i] && _jstrings[i]) { 54 _env->ReleaseStringUTFChars(_jstrings[i], _strings[i]); 55 } 56 } 57 } 58 if (_strings) { 59 free(_strings); 60 } 61 if (_jstrings) { 62 free(_jstrings); 63 } 64 if (_exception) { 65 jniThrowException(_env, _exceptionType, _exceptionMessage); 66 } 67 return (jint)_returnValue; 68} 69