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