1 /* void glGetActiveUniformBlockName ( GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName ) */
2 static void
android_glGetActiveUniformBlockName_III_3II_3BI(JNIEnv * _env,jobject _this,jint program,jint uniformBlockIndex,int bufSize,jintArray length_ref,jint lengthOffset,jbyteArray name_ref,jint nameOffset)3 android_glGetActiveUniformBlockName_III_3II_3BI
4 (JNIEnv* _env, jobject _this, jint program, jint uniformBlockIndex, int bufSize, jintArray length_ref, jint lengthOffset, 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 GLchar* _name_base = (GLchar*)0;
12 jint _nameRemaining;
13 GLchar* _name = (GLchar*)0;
14
15 if (length_ref) {
16 if (lengthOffset < 0) {
17 _exception = 1;
18 _exceptionType = "java/lang/IllegalArgumentException";
19 _exceptionMessage = "lengthOffset < 0";
20 goto exit;
21 }
22 _lengthRemaining = _env->GetArrayLength(length_ref) - lengthOffset;
23 _length_base = (GLsizei*)_env->GetIntArrayElements(
24 length_ref, (jboolean*)0);
25 _length = _length_base + lengthOffset;
26 }
27
28 if (!name_ref) {
29 _exception = 1;
30 _exceptionType = "java/lang/IllegalArgumentException";
31 _exceptionMessage = "uniformBlockName == null";
32 goto exit;
33 }
34 if (nameOffset < 0) {
35 _exception = 1;
36 _exceptionType = "java/lang/IllegalArgumentException";
37 _exceptionMessage = "uniformBlockNameOffset < 0";
38 goto exit;
39 }
40 _nameRemaining = _env->GetArrayLength(name_ref) - nameOffset;
41 _name_base = (GLchar*)_env->GetByteArrayElements(
42 name_ref, (jboolean*)0);
43 _name = _name_base + nameOffset;
44
45 glGetActiveUniformBlockName(
46 (GLuint)program,
47 (GLuint)uniformBlockIndex,
48 (GLsizei)bufSize,
49 (GLsizei*)_length,
50 (GLchar*)_name
51 );
52
53 exit:
54 if (_name_base) {
55 _env->ReleaseByteArrayElements(name_ref, (jbyte*)_name_base,
56 _exception ? JNI_ABORT: 0);
57 }
58 if (_length_base) {
59 _env->ReleaseIntArrayElements(length_ref, (jint*)_length_base,
60 _exception ? JNI_ABORT: 0);
61 }
62 if (_exception) {
63 jniThrowException(_env, _exceptionType, _exceptionMessage);
64 }
65 }
66
67 /* void glGetActiveUniformBlockName ( GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName ) */
68 static void
android_glGetActiveUniformBlockName_IILjava_nio_Buffer_2Ljava_nio_Buffer_2(JNIEnv * _env,jobject _this,jint program,jint uniformBlockIndex,jobject length_buf,jobject uniformBlockName_buf)69 android_glGetActiveUniformBlockName_IILjava_nio_Buffer_2Ljava_nio_Buffer_2
70 (JNIEnv* _env, jobject _this, jint program, jint uniformBlockIndex, jobject length_buf, jobject uniformBlockName_buf) {
71 jint _exception = 0;
72 const char* _exceptionType;
73 const char* _exceptionMessage;
74 jarray _lengthArray = (jarray)0;
75 jint _lengthBufferOffset = (jint)0;
76 GLsizei* _length = (GLsizei*)0;
77 jint _lengthRemaining;
78 jarray _nameArray = (jarray)0;
79 jint _nameBufferOffset = (jint)0;
80 GLchar* _name = (GLchar*)0;
81 jint _nameRemaining;
82
83 _length = (GLsizei*)getPointer(_env, length_buf, &_lengthArray, &_lengthRemaining, &_lengthBufferOffset);
84 if (_length == NULL) {
85 GLsizei* _lengthBase = (GLsizei*)_env->GetPrimitiveArrayCritical(_lengthArray, (jboolean*)0);
86 _length = (GLsizei*)(_lengthBase + _lengthBufferOffset);
87 }
88
89 _name = (GLchar*)getPointer(_env, uniformBlockName_buf, &_nameArray, &_nameRemaining, &_nameBufferOffset);
90 if (_name == NULL) {
91 GLchar* _nameBase = (GLchar*)_env->GetPrimitiveArrayCritical(_nameArray, (jboolean*)0);
92 _name = (GLchar*)(_nameBase + _nameBufferOffset);
93 }
94
95 glGetActiveUniformBlockName(
96 (GLuint)program,
97 (GLuint)uniformBlockIndex,
98 (GLsizei)_nameRemaining,
99 _length, _name
100 );
101 if (_nameArray) {
102 releasePointer(_env, _nameArray, _name, JNI_TRUE);
103 }
104 if (_lengthArray) {
105 releasePointer(_env, _lengthArray, _length, JNI_TRUE);
106 }
107 }
108
109 /* void glGetActiveUniformBlockName ( GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName ) */
110 static jstring
android_glGetActiveUniformBlockName_II(JNIEnv * _env,jobject _this,jint program,jint uniformBlockIndex)111 android_glGetActiveUniformBlockName_II
112 (JNIEnv *_env, jobject _this, jint program, jint uniformBlockIndex) {
113 GLint len = 0;
114 glGetActiveUniformBlockiv((GLuint)program, (GLuint)uniformBlockIndex,
115 GL_UNIFORM_BLOCK_NAME_LENGTH, &len);
116 GLchar* name = (GLchar*)malloc(len);
117 glGetActiveUniformBlockName((GLuint)program, (GLuint)uniformBlockIndex,
118 len, NULL, name);
119 jstring result = _env->NewStringUTF(name);
120 free(name);
121 return result;
122 }
123