1/*
2**
3** Copyright 2009, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9**     http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18// This source file is automatically generated
19
20#pragma GCC diagnostic ignored "-Wunused-variable"
21#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
22#pragma GCC diagnostic ignored "-Wunused-function"
23
24#include <GLES2/gl2.h>
25#include <GLES2/gl2ext.h>
26
27#include <jni.h>
28#include <JNIHelp.h>
29#include <android_runtime/AndroidRuntime.h>
30#include <utils/misc.h>
31#include <assert.h>
32
33static int initialized = 0;
34
35static jclass nioAccessClass;
36static jclass bufferClass;
37static jmethodID getBasePointerID;
38static jmethodID getBaseArrayID;
39static jmethodID getBaseArrayOffsetID;
40static jfieldID positionID;
41static jfieldID limitID;
42static jfieldID elementSizeShiftID;
43
44
45/* special calls implemented in Android's GLES wrapper used to more
46 * efficiently bound-check passed arrays */
47extern "C" {
48#ifdef GL_VERSION_ES_CM_1_1
49GL_API void GL_APIENTRY glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
50        const GLvoid *ptr, GLsizei count);
51GL_API void GL_APIENTRY glNormalPointerBounds(GLenum type, GLsizei stride,
52        const GLvoid *pointer, GLsizei count);
53GL_API void GL_APIENTRY glTexCoordPointerBounds(GLint size, GLenum type,
54        GLsizei stride, const GLvoid *pointer, GLsizei count);
55GL_API void GL_APIENTRY glVertexPointerBounds(GLint size, GLenum type,
56        GLsizei stride, const GLvoid *pointer, GLsizei count);
57GL_API void GL_APIENTRY glPointSizePointerOESBounds(GLenum type,
58        GLsizei stride, const GLvoid *pointer, GLsizei count);
59GL_API void GL_APIENTRY glMatrixIndexPointerOESBounds(GLint size, GLenum type,
60        GLsizei stride, const GLvoid *pointer, GLsizei count);
61GL_API void GL_APIENTRY glWeightPointerOESBounds(GLint size, GLenum type,
62        GLsizei stride, const GLvoid *pointer, GLsizei count);
63#endif
64#ifdef GL_ES_VERSION_2_0
65static void glVertexAttribPointerBounds(GLuint indx, GLint size, GLenum type,
66        GLboolean normalized, GLsizei stride, const GLvoid *pointer, GLsizei count) {
67    glVertexAttribPointer(indx, size, type, normalized, stride, pointer);
68}
69#endif
70#ifdef GL_ES_VERSION_3_0
71static void glVertexAttribIPointerBounds(GLuint indx, GLint size, GLenum type,
72        GLsizei stride, const GLvoid *pointer, GLsizei count) {
73    glVertexAttribIPointer(indx, size, type, stride, pointer);
74}
75#endif
76}
77
78/* Cache method IDs each time the class is loaded. */
79
80static void
81nativeClassInit(JNIEnv *_env, jclass glImplClass)
82{
83    jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess");
84    nioAccessClass = (jclass) _env->NewGlobalRef(nioAccessClassLocal);
85
86    jclass bufferClassLocal = _env->FindClass("java/nio/Buffer");
87    bufferClass = (jclass) _env->NewGlobalRef(bufferClassLocal);
88
89    getBasePointerID = _env->GetStaticMethodID(nioAccessClass,
90            "getBasePointer", "(Ljava/nio/Buffer;)J");
91    getBaseArrayID = _env->GetStaticMethodID(nioAccessClass,
92            "getBaseArray", "(Ljava/nio/Buffer;)Ljava/lang/Object;");
93    getBaseArrayOffsetID = _env->GetStaticMethodID(nioAccessClass,
94            "getBaseArrayOffset", "(Ljava/nio/Buffer;)I");
95
96    positionID = _env->GetFieldID(bufferClass, "position", "I");
97    limitID = _env->GetFieldID(bufferClass, "limit", "I");
98    elementSizeShiftID =
99        _env->GetFieldID(bufferClass, "_elementSizeShift", "I");
100}
101
102static void *
103getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining, jint *offset)
104{
105    jint position;
106    jint limit;
107    jint elementSizeShift;
108    jlong pointer;
109
110    position = _env->GetIntField(buffer, positionID);
111    limit = _env->GetIntField(buffer, limitID);
112    elementSizeShift = _env->GetIntField(buffer, elementSizeShiftID);
113    *remaining = (limit - position) << elementSizeShift;
114    pointer = _env->CallStaticLongMethod(nioAccessClass,
115            getBasePointerID, buffer);
116    if (pointer != 0L) {
117        *array = NULL;
118        return reinterpret_cast<void*>(pointer);
119    }
120
121    *array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
122            getBaseArrayID, buffer);
123    *offset = _env->CallStaticIntMethod(nioAccessClass,
124            getBaseArrayOffsetID, buffer);
125
126    return NULL;
127}
128
129class ByteArrayGetter {
130public:
131    static void* Get(JNIEnv* _env, jbyteArray array, jboolean* is_copy) {
132        return _env->GetByteArrayElements(array, is_copy);
133    }
134};
135class BooleanArrayGetter {
136public:
137    static void* Get(JNIEnv* _env, jbooleanArray array, jboolean* is_copy) {
138        return _env->GetBooleanArrayElements(array, is_copy);
139    }
140};
141class CharArrayGetter {
142public:
143    static void* Get(JNIEnv* _env, jcharArray array, jboolean* is_copy) {
144        return _env->GetCharArrayElements(array, is_copy);
145    }
146};
147class ShortArrayGetter {
148public:
149    static void* Get(JNIEnv* _env, jshortArray array, jboolean* is_copy) {
150        return _env->GetShortArrayElements(array, is_copy);
151    }
152};
153class IntArrayGetter {
154public:
155    static void* Get(JNIEnv* _env, jintArray array, jboolean* is_copy) {
156        return _env->GetIntArrayElements(array, is_copy);
157    }
158};
159class LongArrayGetter {
160public:
161    static void* Get(JNIEnv* _env, jlongArray array, jboolean* is_copy) {
162        return _env->GetLongArrayElements(array, is_copy);
163    }
164};
165class FloatArrayGetter {
166public:
167    static void* Get(JNIEnv* _env, jfloatArray array, jboolean* is_copy) {
168        return _env->GetFloatArrayElements(array, is_copy);
169    }
170};
171class DoubleArrayGetter {
172public:
173    static void* Get(JNIEnv* _env, jdoubleArray array, jboolean* is_copy) {
174        return _env->GetDoubleArrayElements(array, is_copy);
175    }
176};
177
178template<typename JTYPEARRAY, typename ARRAYGETTER>
179static void*
180getArrayPointer(JNIEnv *_env, JTYPEARRAY array, jboolean* is_copy) {
181    return ARRAYGETTER::Get(_env, array, is_copy);
182}
183
184class ByteArrayReleaser {
185public:
186    static void Release(JNIEnv* _env, jbyteArray array, jbyte* data, jboolean commit) {
187        _env->ReleaseByteArrayElements(array, data, commit ? 0 : JNI_ABORT);
188    }
189};
190class BooleanArrayReleaser {
191public:
192    static void Release(JNIEnv* _env, jbooleanArray array, jboolean* data, jboolean commit) {
193        _env->ReleaseBooleanArrayElements(array, data, commit ? 0 : JNI_ABORT);
194    }
195};
196class CharArrayReleaser {
197public:
198    static void Release(JNIEnv* _env, jcharArray array, jchar* data, jboolean commit) {
199        _env->ReleaseCharArrayElements(array, data, commit ? 0 : JNI_ABORT);
200    }
201};
202class ShortArrayReleaser {
203public:
204    static void Release(JNIEnv* _env, jshortArray array, jshort* data, jboolean commit) {
205        _env->ReleaseShortArrayElements(array, data, commit ? 0 : JNI_ABORT);
206    }
207};
208class IntArrayReleaser {
209public:
210    static void Release(JNIEnv* _env, jintArray array, jint* data, jboolean commit) {
211        _env->ReleaseIntArrayElements(array, data, commit ? 0 : JNI_ABORT);
212    }
213};
214class LongArrayReleaser {
215public:
216    static void Release(JNIEnv* _env, jlongArray array, jlong* data, jboolean commit) {
217        _env->ReleaseLongArrayElements(array, data, commit ? 0 : JNI_ABORT);
218    }
219};
220class FloatArrayReleaser {
221public:
222    static void Release(JNIEnv* _env, jfloatArray array, jfloat* data, jboolean commit) {
223        _env->ReleaseFloatArrayElements(array, data, commit ? 0 : JNI_ABORT);
224    }
225};
226class DoubleArrayReleaser {
227public:
228    static void Release(JNIEnv* _env, jdoubleArray array, jdouble* data, jboolean commit) {
229        _env->ReleaseDoubleArrayElements(array, data, commit ? 0 : JNI_ABORT);
230    }
231};
232
233template<typename JTYPEARRAY, typename NTYPEARRAY, typename ARRAYRELEASER>
234static void
235releaseArrayPointer(JNIEnv *_env, JTYPEARRAY array, NTYPEARRAY data, jboolean commit) {
236    ARRAYRELEASER::Release(_env, array, data, commit);
237}
238
239static void
240releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit)
241{
242    _env->ReleasePrimitiveArrayCritical(array, data,
243                       commit ? 0 : JNI_ABORT);
244}
245
246static void *
247getDirectBufferPointer(JNIEnv *_env, jobject buffer) {
248    char* buf = (char*) _env->GetDirectBufferAddress(buffer);
249    if (buf) {
250        jint position = _env->GetIntField(buffer, positionID);
251        jint elementSizeShift = _env->GetIntField(buffer, elementSizeShiftID);
252        buf += position << elementSizeShift;
253    } else {
254        jniThrowException(_env, "java/lang/IllegalArgumentException",
255                          "Must use a native order direct Buffer");
256    }
257    return (void*) buf;
258}
259
260// --------------------------------------------------------------------------
261
262/*
263 * returns the number of values glGet returns for a given pname.
264 *
265 * The code below is written such that pnames requiring only one values
266 * are the default (and are not explicitely tested for). This makes the
267 * checking code much shorter/readable/efficient.
268 *
269 * This means that unknown pnames (e.g.: extensions) will default to 1. If
270 * that unknown pname needs more than 1 value, then the validation check
271 * is incomplete and the app may crash if it passed the wrong number params.
272 */
273static int getNeededCount(GLint pname) {
274    int needed = 1;
275#ifdef GL_ES_VERSION_3_0
276    // GLES 3.x pnames
277    switch (pname) {
278        case GL_MAX_VIEWPORT_DIMS:
279            needed = 2;
280            break;
281
282        case GL_PROGRAM_BINARY_FORMATS:
283            glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &needed);
284            break;
285    }
286#endif
287
288#ifdef GL_ES_VERSION_2_0
289    // GLES 2.x pnames
290    switch (pname) {
291        case GL_ALIASED_LINE_WIDTH_RANGE:
292        case GL_ALIASED_POINT_SIZE_RANGE:
293            needed = 2;
294            break;
295
296        case GL_BLEND_COLOR:
297        case GL_COLOR_CLEAR_VALUE:
298        case GL_COLOR_WRITEMASK:
299        case GL_SCISSOR_BOX:
300        case GL_VIEWPORT:
301            needed = 4;
302            break;
303
304        case GL_COMPRESSED_TEXTURE_FORMATS:
305            glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &needed);
306            break;
307
308        case GL_SHADER_BINARY_FORMATS:
309            glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &needed);
310            break;
311    }
312#endif
313
314#ifdef GL_VERSION_ES_CM_1_1
315    // GLES 1.x pnames
316    switch (pname) {
317        case GL_ALIASED_LINE_WIDTH_RANGE:
318        case GL_ALIASED_POINT_SIZE_RANGE:
319        case GL_DEPTH_RANGE:
320        case GL_SMOOTH_LINE_WIDTH_RANGE:
321        case GL_SMOOTH_POINT_SIZE_RANGE:
322            needed = 2;
323            break;
324
325        case GL_CURRENT_NORMAL:
326        case GL_POINT_DISTANCE_ATTENUATION:
327            needed = 3;
328            break;
329
330        case GL_COLOR_CLEAR_VALUE:
331        case GL_COLOR_WRITEMASK:
332        case GL_CURRENT_COLOR:
333        case GL_CURRENT_TEXTURE_COORDS:
334        case GL_FOG_COLOR:
335        case GL_LIGHT_MODEL_AMBIENT:
336        case GL_SCISSOR_BOX:
337        case GL_VIEWPORT:
338            needed = 4;
339            break;
340
341        case GL_MODELVIEW_MATRIX:
342        case GL_PROJECTION_MATRIX:
343        case GL_TEXTURE_MATRIX:
344            needed = 16;
345            break;
346
347        case GL_COMPRESSED_TEXTURE_FORMATS:
348            glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &needed);
349            break;
350    }
351#endif
352    return needed;
353}
354
355template <typename JTYPEARRAY, typename ARRAYGETTER, typename NTYPEARRAY,
356          typename ARRAYRELEASER, typename CTYPE, void GET(GLenum, CTYPE*)>
357static void
358get
359  (JNIEnv *_env, jobject _this, jint pname, JTYPEARRAY params_ref, jint offset) {
360    jint _exception = 0;
361    const char * _exceptionType;
362    const char * _exceptionMessage;
363    CTYPE *params_base = (CTYPE *) 0;
364    jint _remaining;
365    CTYPE *params = (CTYPE *) 0;
366    int _needed = 0;
367
368    if (!params_ref) {
369        _exception = 1;
370        _exceptionType = "java/lang/IllegalArgumentException";
371        _exceptionMessage = "params == null";
372        goto exit;
373    }
374    if (offset < 0) {
375        _exception = 1;
376        _exceptionType = "java/lang/IllegalArgumentException";
377        _exceptionMessage = "offset < 0";
378        goto exit;
379    }
380    _remaining = _env->GetArrayLength(params_ref) - offset;
381    _needed = getNeededCount(pname);
382    // if we didn't find this pname, we just assume the user passed
383    // an array of the right size -- this might happen with extensions
384    // or if we forget an enum here.
385    if (_remaining < _needed) {
386        _exception = 1;
387        _exceptionType = "java/lang/IllegalArgumentException";
388        _exceptionMessage = "length - offset < needed";
389        goto exit;
390    }
391    params_base = (CTYPE *) getArrayPointer<JTYPEARRAY, ARRAYGETTER>(
392        _env, params_ref, (jboolean *)0);
393    params = params_base + offset;
394
395    GET(
396        (GLenum)pname,
397        (CTYPE *)params
398    );
399
400exit:
401    if (params_base) {
402        releaseArrayPointer<JTYPEARRAY, NTYPEARRAY, ARRAYRELEASER>(
403            _env, params_ref, params_base, !_exception);
404    }
405    if (_exception) {
406        jniThrowException(_env, _exceptionType, _exceptionMessage);
407    }
408}
409
410
411template <typename CTYPE, typename JTYPEARRAY, typename ARRAYGETTER, typename NTYPEARRAY,
412          typename ARRAYRELEASER, void GET(GLenum, CTYPE*)>
413static void
414getarray
415  (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
416    jint _exception = 0;
417    const char * _exceptionType;
418    const char * _exceptionMessage;
419    JTYPEARRAY _array = (JTYPEARRAY) 0;
420    jint _bufferOffset = (jint) 0;
421    jint _remaining;
422    CTYPE *params = (CTYPE *) 0;
423    int _needed = 0;
424
425    params = (CTYPE *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
426    _remaining /= sizeof(CTYPE);    // convert from bytes to item count
427    _needed = getNeededCount(pname);
428    // if we didn't find this pname, we just assume the user passed
429    // an array of the right size -- this might happen with extensions
430    // or if we forget an enum here.
431    if (_needed>0 && _remaining < _needed) {
432        _exception = 1;
433        _exceptionType = "java/lang/IllegalArgumentException";
434        _exceptionMessage = "remaining() < needed";
435        goto exit;
436    }
437    if (params == NULL) {
438        char * _paramsBase = (char *) getArrayPointer<JTYPEARRAY, ARRAYGETTER>(
439            _env, _array, (jboolean *) 0);
440        params = (CTYPE *) (_paramsBase + _bufferOffset);
441    }
442    GET(
443        (GLenum)pname,
444        (CTYPE *)params
445    );
446
447exit:
448    if (_array) {
449        releaseArrayPointer<JTYPEARRAY, NTYPEARRAY, ARRAYRELEASER>(
450            _env, _array, (NTYPEARRAY)params, _exception ? JNI_FALSE : JNI_TRUE);
451    }
452    if (_exception) {
453        jniThrowException(_env, _exceptionType, _exceptionMessage);
454    }
455}
456
457// --------------------------------------------------------------------------
458/* void glActiveTexture ( GLenum texture ) */
459static void
460android_glActiveTexture__I
461  (JNIEnv *_env, jobject _this, jint texture) {
462    glActiveTexture(
463        (GLenum)texture
464    );
465}
466
467/* void glAttachShader ( GLuint program, GLuint shader ) */
468static void
469android_glAttachShader__II
470  (JNIEnv *_env, jobject _this, jint program, jint shader) {
471    glAttachShader(
472        (GLuint)program,
473        (GLuint)shader
474    );
475}
476
477/* void glBindAttribLocation ( GLuint program, GLuint index, const char *name ) */
478static void
479android_glBindAttribLocation__IILjava_lang_String_2
480  (JNIEnv *_env, jobject _this, jint program, jint index, jstring name) {
481    jint _exception = 0;
482    const char * _exceptionType = NULL;
483    const char * _exceptionMessage = NULL;
484    const char* _nativename = 0;
485
486    if (!name) {
487        _exception = 1;
488        _exceptionType = "java/lang/IllegalArgumentException";
489        _exceptionMessage = "name == null";
490        goto exit;
491    }
492    _nativename = _env->GetStringUTFChars(name, 0);
493
494    glBindAttribLocation(
495        (GLuint)program,
496        (GLuint)index,
497        (char *)_nativename
498    );
499
500exit:
501    if (_nativename) {
502        _env->ReleaseStringUTFChars(name, _nativename);
503    }
504
505    if (_exception) {
506        jniThrowException(_env, _exceptionType, _exceptionMessage);
507    }
508}
509
510/* void glBindBuffer ( GLenum target, GLuint buffer ) */
511static void
512android_glBindBuffer__II
513  (JNIEnv *_env, jobject _this, jint target, jint buffer) {
514    glBindBuffer(
515        (GLenum)target,
516        (GLuint)buffer
517    );
518}
519
520/* void glBindFramebuffer ( GLenum target, GLuint framebuffer ) */
521static void
522android_glBindFramebuffer__II
523  (JNIEnv *_env, jobject _this, jint target, jint framebuffer) {
524    glBindFramebuffer(
525        (GLenum)target,
526        (GLuint)framebuffer
527    );
528}
529
530/* void glBindRenderbuffer ( GLenum target, GLuint renderbuffer ) */
531static void
532android_glBindRenderbuffer__II
533  (JNIEnv *_env, jobject _this, jint target, jint renderbuffer) {
534    glBindRenderbuffer(
535        (GLenum)target,
536        (GLuint)renderbuffer
537    );
538}
539
540/* void glBindTexture ( GLenum target, GLuint texture ) */
541static void
542android_glBindTexture__II
543  (JNIEnv *_env, jobject _this, jint target, jint texture) {
544    glBindTexture(
545        (GLenum)target,
546        (GLuint)texture
547    );
548}
549
550/* void glBlendColor ( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) */
551static void
552android_glBlendColor__FFFF
553  (JNIEnv *_env, jobject _this, jfloat red, jfloat green, jfloat blue, jfloat alpha) {
554    glBlendColor(
555        (GLclampf)red,
556        (GLclampf)green,
557        (GLclampf)blue,
558        (GLclampf)alpha
559    );
560}
561
562/* void glBlendEquation ( GLenum mode ) */
563static void
564android_glBlendEquation__I
565  (JNIEnv *_env, jobject _this, jint mode) {
566    glBlendEquation(
567        (GLenum)mode
568    );
569}
570
571/* void glBlendEquationSeparate ( GLenum modeRGB, GLenum modeAlpha ) */
572static void
573android_glBlendEquationSeparate__II
574  (JNIEnv *_env, jobject _this, jint modeRGB, jint modeAlpha) {
575    glBlendEquationSeparate(
576        (GLenum)modeRGB,
577        (GLenum)modeAlpha
578    );
579}
580
581/* void glBlendFunc ( GLenum sfactor, GLenum dfactor ) */
582static void
583android_glBlendFunc__II
584  (JNIEnv *_env, jobject _this, jint sfactor, jint dfactor) {
585    glBlendFunc(
586        (GLenum)sfactor,
587        (GLenum)dfactor
588    );
589}
590
591/* void glBlendFuncSeparate ( GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha ) */
592static void
593android_glBlendFuncSeparate__IIII
594  (JNIEnv *_env, jobject _this, jint srcRGB, jint dstRGB, jint srcAlpha, jint dstAlpha) {
595    glBlendFuncSeparate(
596        (GLenum)srcRGB,
597        (GLenum)dstRGB,
598        (GLenum)srcAlpha,
599        (GLenum)dstAlpha
600    );
601}
602
603/* void glBufferData ( GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage ) */
604static void
605android_glBufferData__IILjava_nio_Buffer_2I
606  (JNIEnv *_env, jobject _this, jint target, jint size, jobject data_buf, jint usage) {
607    jint _exception = 0;
608    const char * _exceptionType = NULL;
609    const char * _exceptionMessage = NULL;
610    jarray _array = (jarray) 0;
611    jint _bufferOffset = (jint) 0;
612    jint _remaining;
613    GLvoid *data = (GLvoid *) 0;
614
615    if (data_buf) {
616        data = (GLvoid *)getPointer(_env, data_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
617        if (_remaining < size) {
618            _exception = 1;
619            _exceptionType = "java/lang/IllegalArgumentException";
620            _exceptionMessage = "remaining() < size < needed";
621            goto exit;
622        }
623    }
624    if (data_buf && data == NULL) {
625        char * _dataBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
626        data = (GLvoid *) (_dataBase + _bufferOffset);
627    }
628    glBufferData(
629        (GLenum)target,
630        (GLsizeiptr)size,
631        (GLvoid *)data,
632        (GLenum)usage
633    );
634
635exit:
636    if (_array) {
637        releasePointer(_env, _array, data, JNI_FALSE);
638    }
639    if (_exception) {
640        jniThrowException(_env, _exceptionType, _exceptionMessage);
641    }
642}
643
644/* void glBufferSubData ( GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data ) */
645static void
646android_glBufferSubData__IIILjava_nio_Buffer_2
647  (JNIEnv *_env, jobject _this, jint target, jint offset, jint size, jobject data_buf) {
648    jint _exception = 0;
649    const char * _exceptionType = NULL;
650    const char * _exceptionMessage = NULL;
651    jarray _array = (jarray) 0;
652    jint _bufferOffset = (jint) 0;
653    jint _remaining;
654    GLvoid *data = (GLvoid *) 0;
655
656    if (!data_buf) {
657        _exception = 1;
658        _exceptionType = "java/lang/IllegalArgumentException";
659        _exceptionMessage = "data == null";
660        goto exit;
661    }
662    data = (GLvoid *)getPointer(_env, data_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
663    if (_remaining < size) {
664        _exception = 1;
665        _exceptionType = "java/lang/IllegalArgumentException";
666        _exceptionMessage = "remaining() < size < needed";
667        goto exit;
668    }
669    if (data == NULL) {
670        char * _dataBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
671        data = (GLvoid *) (_dataBase + _bufferOffset);
672    }
673    glBufferSubData(
674        (GLenum)target,
675        (GLintptr)offset,
676        (GLsizeiptr)size,
677        (GLvoid *)data
678    );
679
680exit:
681    if (_array) {
682        releasePointer(_env, _array, data, JNI_FALSE);
683    }
684    if (_exception) {
685        jniThrowException(_env, _exceptionType, _exceptionMessage);
686    }
687}
688
689/* GLenum glCheckFramebufferStatus ( GLenum target ) */
690static jint
691android_glCheckFramebufferStatus__I
692  (JNIEnv *_env, jobject _this, jint target) {
693    GLenum _returnValue;
694    _returnValue = glCheckFramebufferStatus(
695        (GLenum)target
696    );
697    return (jint)_returnValue;
698}
699
700/* void glClear ( GLbitfield mask ) */
701static void
702android_glClear__I
703  (JNIEnv *_env, jobject _this, jint mask) {
704    glClear(
705        (GLbitfield)mask
706    );
707}
708
709/* void glClearColor ( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) */
710static void
711android_glClearColor__FFFF
712  (JNIEnv *_env, jobject _this, jfloat red, jfloat green, jfloat blue, jfloat alpha) {
713    glClearColor(
714        (GLclampf)red,
715        (GLclampf)green,
716        (GLclampf)blue,
717        (GLclampf)alpha
718    );
719}
720
721/* void glClearDepthf ( GLclampf depth ) */
722static void
723android_glClearDepthf__F
724  (JNIEnv *_env, jobject _this, jfloat depth) {
725    glClearDepthf(
726        (GLclampf)depth
727    );
728}
729
730/* void glClearStencil ( GLint s ) */
731static void
732android_glClearStencil__I
733  (JNIEnv *_env, jobject _this, jint s) {
734    glClearStencil(
735        (GLint)s
736    );
737}
738
739/* void glColorMask ( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ) */
740static void
741android_glColorMask__ZZZZ
742  (JNIEnv *_env, jobject _this, jboolean red, jboolean green, jboolean blue, jboolean alpha) {
743    glColorMask(
744        (GLboolean)red,
745        (GLboolean)green,
746        (GLboolean)blue,
747        (GLboolean)alpha
748    );
749}
750
751/* void glCompileShader ( GLuint shader ) */
752static void
753android_glCompileShader__I
754  (JNIEnv *_env, jobject _this, jint shader) {
755    glCompileShader(
756        (GLuint)shader
757    );
758}
759
760/* void glCompressedTexImage2D ( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data ) */
761static void
762android_glCompressedTexImage2D__IIIIIIILjava_nio_Buffer_2
763  (JNIEnv *_env, jobject _this, jint target, jint level, jint internalformat, jint width, jint height, jint border, jint imageSize, jobject data_buf) {
764    jint _exception = 0;
765    const char * _exceptionType = NULL;
766    const char * _exceptionMessage = NULL;
767    jarray _array = (jarray) 0;
768    jint _bufferOffset = (jint) 0;
769    jint _remaining;
770    GLvoid *data = (GLvoid *) 0;
771
772    if (!data_buf) {
773        _exception = 1;
774        _exceptionType = "java/lang/IllegalArgumentException";
775        _exceptionMessage = "data == null";
776        goto exit;
777    }
778    data = (GLvoid *)getPointer(_env, data_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
779    if (data == NULL) {
780        char * _dataBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
781        data = (GLvoid *) (_dataBase + _bufferOffset);
782    }
783    glCompressedTexImage2D(
784        (GLenum)target,
785        (GLint)level,
786        (GLenum)internalformat,
787        (GLsizei)width,
788        (GLsizei)height,
789        (GLint)border,
790        (GLsizei)imageSize,
791        (GLvoid *)data
792    );
793
794exit:
795    if (_array) {
796        releasePointer(_env, _array, data, JNI_FALSE);
797    }
798    if (_exception) {
799        jniThrowException(_env, _exceptionType, _exceptionMessage);
800    }
801}
802
803/* void glCompressedTexSubImage2D ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data ) */
804static void
805android_glCompressedTexSubImage2D__IIIIIIIILjava_nio_Buffer_2
806  (JNIEnv *_env, jobject _this, jint target, jint level, jint xoffset, jint yoffset, jint width, jint height, jint format, jint imageSize, jobject data_buf) {
807    jint _exception = 0;
808    const char * _exceptionType = NULL;
809    const char * _exceptionMessage = NULL;
810    jarray _array = (jarray) 0;
811    jint _bufferOffset = (jint) 0;
812    jint _remaining;
813    GLvoid *data = (GLvoid *) 0;
814
815    if (!data_buf) {
816        _exception = 1;
817        _exceptionType = "java/lang/IllegalArgumentException";
818        _exceptionMessage = "data == null";
819        goto exit;
820    }
821    data = (GLvoid *)getPointer(_env, data_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
822    if (data == NULL) {
823        char * _dataBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
824        data = (GLvoid *) (_dataBase + _bufferOffset);
825    }
826    glCompressedTexSubImage2D(
827        (GLenum)target,
828        (GLint)level,
829        (GLint)xoffset,
830        (GLint)yoffset,
831        (GLsizei)width,
832        (GLsizei)height,
833        (GLenum)format,
834        (GLsizei)imageSize,
835        (GLvoid *)data
836    );
837
838exit:
839    if (_array) {
840        releasePointer(_env, _array, data, JNI_FALSE);
841    }
842    if (_exception) {
843        jniThrowException(_env, _exceptionType, _exceptionMessage);
844    }
845}
846
847/* void glCopyTexImage2D ( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border ) */
848static void
849android_glCopyTexImage2D__IIIIIIII
850  (JNIEnv *_env, jobject _this, jint target, jint level, jint internalformat, jint x, jint y, jint width, jint height, jint border) {
851    glCopyTexImage2D(
852        (GLenum)target,
853        (GLint)level,
854        (GLenum)internalformat,
855        (GLint)x,
856        (GLint)y,
857        (GLsizei)width,
858        (GLsizei)height,
859        (GLint)border
860    );
861}
862
863/* void glCopyTexSubImage2D ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height ) */
864static void
865android_glCopyTexSubImage2D__IIIIIIII
866  (JNIEnv *_env, jobject _this, jint target, jint level, jint xoffset, jint yoffset, jint x, jint y, jint width, jint height) {
867    glCopyTexSubImage2D(
868        (GLenum)target,
869        (GLint)level,
870        (GLint)xoffset,
871        (GLint)yoffset,
872        (GLint)x,
873        (GLint)y,
874        (GLsizei)width,
875        (GLsizei)height
876    );
877}
878
879/* GLuint glCreateProgram ( void ) */
880static jint
881android_glCreateProgram__
882  (JNIEnv *_env, jobject _this) {
883    GLuint _returnValue;
884    _returnValue = glCreateProgram();
885    return (jint)_returnValue;
886}
887
888/* GLuint glCreateShader ( GLenum type ) */
889static jint
890android_glCreateShader__I
891  (JNIEnv *_env, jobject _this, jint type) {
892    GLuint _returnValue;
893    _returnValue = glCreateShader(
894        (GLenum)type
895    );
896    return (jint)_returnValue;
897}
898
899/* void glCullFace ( GLenum mode ) */
900static void
901android_glCullFace__I
902  (JNIEnv *_env, jobject _this, jint mode) {
903    glCullFace(
904        (GLenum)mode
905    );
906}
907
908/* void glDeleteBuffers ( GLsizei n, const GLuint *buffers ) */
909static void
910android_glDeleteBuffers__I_3II
911  (JNIEnv *_env, jobject _this, jint n, jintArray buffers_ref, jint offset) {
912    jint _exception = 0;
913    const char * _exceptionType = NULL;
914    const char * _exceptionMessage = NULL;
915    GLuint *buffers_base = (GLuint *) 0;
916    jint _remaining;
917    GLuint *buffers = (GLuint *) 0;
918
919    if (!buffers_ref) {
920        _exception = 1;
921        _exceptionType = "java/lang/IllegalArgumentException";
922        _exceptionMessage = "buffers == null";
923        goto exit;
924    }
925    if (offset < 0) {
926        _exception = 1;
927        _exceptionType = "java/lang/IllegalArgumentException";
928        _exceptionMessage = "offset < 0";
929        goto exit;
930    }
931    _remaining = _env->GetArrayLength(buffers_ref) - offset;
932    if (_remaining < n) {
933        _exception = 1;
934        _exceptionType = "java/lang/IllegalArgumentException";
935        _exceptionMessage = "length - offset < n < needed";
936        goto exit;
937    }
938    buffers_base = (GLuint *)
939        _env->GetIntArrayElements(buffers_ref, (jboolean *)0);
940    buffers = buffers_base + offset;
941
942    glDeleteBuffers(
943        (GLsizei)n,
944        (GLuint *)buffers
945    );
946
947exit:
948    if (buffers_base) {
949        _env->ReleaseIntArrayElements(buffers_ref, (jint*)buffers_base,
950            JNI_ABORT);
951    }
952    if (_exception) {
953        jniThrowException(_env, _exceptionType, _exceptionMessage);
954    }
955}
956
957/* void glDeleteBuffers ( GLsizei n, const GLuint *buffers ) */
958static void
959android_glDeleteBuffers__ILjava_nio_IntBuffer_2
960  (JNIEnv *_env, jobject _this, jint n, jobject buffers_buf) {
961    jint _exception = 0;
962    const char * _exceptionType = NULL;
963    const char * _exceptionMessage = NULL;
964    jintArray _array = (jintArray) 0;
965    jint _bufferOffset = (jint) 0;
966    jint _remaining;
967    GLuint *buffers = (GLuint *) 0;
968
969    if (!buffers_buf) {
970        _exception = 1;
971        _exceptionType = "java/lang/IllegalArgumentException";
972        _exceptionMessage = "buffers == null";
973        goto exit;
974    }
975    buffers = (GLuint *)getPointer(_env, buffers_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
976    if (_remaining < n) {
977        _exception = 1;
978        _exceptionType = "java/lang/IllegalArgumentException";
979        _exceptionMessage = "remaining() < n < needed";
980        goto exit;
981    }
982    if (buffers == NULL) {
983        char * _buffersBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
984        buffers = (GLuint *) (_buffersBase + _bufferOffset);
985    }
986    glDeleteBuffers(
987        (GLsizei)n,
988        (GLuint *)buffers
989    );
990
991exit:
992    if (_array) {
993        _env->ReleaseIntArrayElements(_array, (jint*)buffers, JNI_ABORT);
994    }
995    if (_exception) {
996        jniThrowException(_env, _exceptionType, _exceptionMessage);
997    }
998}
999
1000/* void glDeleteFramebuffers ( GLsizei n, const GLuint *framebuffers ) */
1001static void
1002android_glDeleteFramebuffers__I_3II
1003  (JNIEnv *_env, jobject _this, jint n, jintArray framebuffers_ref, jint offset) {
1004    jint _exception = 0;
1005    const char * _exceptionType = NULL;
1006    const char * _exceptionMessage = NULL;
1007    GLuint *framebuffers_base = (GLuint *) 0;
1008    jint _remaining;
1009    GLuint *framebuffers = (GLuint *) 0;
1010
1011    if (!framebuffers_ref) {
1012        _exception = 1;
1013        _exceptionType = "java/lang/IllegalArgumentException";
1014        _exceptionMessage = "framebuffers == null";
1015        goto exit;
1016    }
1017    if (offset < 0) {
1018        _exception = 1;
1019        _exceptionType = "java/lang/IllegalArgumentException";
1020        _exceptionMessage = "offset < 0";
1021        goto exit;
1022    }
1023    _remaining = _env->GetArrayLength(framebuffers_ref) - offset;
1024    if (_remaining < n) {
1025        _exception = 1;
1026        _exceptionType = "java/lang/IllegalArgumentException";
1027        _exceptionMessage = "length - offset < n < needed";
1028        goto exit;
1029    }
1030    framebuffers_base = (GLuint *)
1031        _env->GetIntArrayElements(framebuffers_ref, (jboolean *)0);
1032    framebuffers = framebuffers_base + offset;
1033
1034    glDeleteFramebuffers(
1035        (GLsizei)n,
1036        (GLuint *)framebuffers
1037    );
1038
1039exit:
1040    if (framebuffers_base) {
1041        _env->ReleaseIntArrayElements(framebuffers_ref, (jint*)framebuffers_base,
1042            JNI_ABORT);
1043    }
1044    if (_exception) {
1045        jniThrowException(_env, _exceptionType, _exceptionMessage);
1046    }
1047}
1048
1049/* void glDeleteFramebuffers ( GLsizei n, const GLuint *framebuffers ) */
1050static void
1051android_glDeleteFramebuffers__ILjava_nio_IntBuffer_2
1052  (JNIEnv *_env, jobject _this, jint n, jobject framebuffers_buf) {
1053    jint _exception = 0;
1054    const char * _exceptionType = NULL;
1055    const char * _exceptionMessage = NULL;
1056    jintArray _array = (jintArray) 0;
1057    jint _bufferOffset = (jint) 0;
1058    jint _remaining;
1059    GLuint *framebuffers = (GLuint *) 0;
1060
1061    if (!framebuffers_buf) {
1062        _exception = 1;
1063        _exceptionType = "java/lang/IllegalArgumentException";
1064        _exceptionMessage = "framebuffers == null";
1065        goto exit;
1066    }
1067    framebuffers = (GLuint *)getPointer(_env, framebuffers_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
1068    if (_remaining < n) {
1069        _exception = 1;
1070        _exceptionType = "java/lang/IllegalArgumentException";
1071        _exceptionMessage = "remaining() < n < needed";
1072        goto exit;
1073    }
1074    if (framebuffers == NULL) {
1075        char * _framebuffersBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
1076        framebuffers = (GLuint *) (_framebuffersBase + _bufferOffset);
1077    }
1078    glDeleteFramebuffers(
1079        (GLsizei)n,
1080        (GLuint *)framebuffers
1081    );
1082
1083exit:
1084    if (_array) {
1085        _env->ReleaseIntArrayElements(_array, (jint*)framebuffers, JNI_ABORT);
1086    }
1087    if (_exception) {
1088        jniThrowException(_env, _exceptionType, _exceptionMessage);
1089    }
1090}
1091
1092/* void glDeleteProgram ( GLuint program ) */
1093static void
1094android_glDeleteProgram__I
1095  (JNIEnv *_env, jobject _this, jint program) {
1096    glDeleteProgram(
1097        (GLuint)program
1098    );
1099}
1100
1101/* void glDeleteRenderbuffers ( GLsizei n, const GLuint *renderbuffers ) */
1102static void
1103android_glDeleteRenderbuffers__I_3II
1104  (JNIEnv *_env, jobject _this, jint n, jintArray renderbuffers_ref, jint offset) {
1105    jint _exception = 0;
1106    const char * _exceptionType = NULL;
1107    const char * _exceptionMessage = NULL;
1108    GLuint *renderbuffers_base = (GLuint *) 0;
1109    jint _remaining;
1110    GLuint *renderbuffers = (GLuint *) 0;
1111
1112    if (!renderbuffers_ref) {
1113        _exception = 1;
1114        _exceptionType = "java/lang/IllegalArgumentException";
1115        _exceptionMessage = "renderbuffers == null";
1116        goto exit;
1117    }
1118    if (offset < 0) {
1119        _exception = 1;
1120        _exceptionType = "java/lang/IllegalArgumentException";
1121        _exceptionMessage = "offset < 0";
1122        goto exit;
1123    }
1124    _remaining = _env->GetArrayLength(renderbuffers_ref) - offset;
1125    if (_remaining < n) {
1126        _exception = 1;
1127        _exceptionType = "java/lang/IllegalArgumentException";
1128        _exceptionMessage = "length - offset < n < needed";
1129        goto exit;
1130    }
1131    renderbuffers_base = (GLuint *)
1132        _env->GetIntArrayElements(renderbuffers_ref, (jboolean *)0);
1133    renderbuffers = renderbuffers_base + offset;
1134
1135    glDeleteRenderbuffers(
1136        (GLsizei)n,
1137        (GLuint *)renderbuffers
1138    );
1139
1140exit:
1141    if (renderbuffers_base) {
1142        _env->ReleaseIntArrayElements(renderbuffers_ref, (jint*)renderbuffers_base,
1143            JNI_ABORT);
1144    }
1145    if (_exception) {
1146        jniThrowException(_env, _exceptionType, _exceptionMessage);
1147    }
1148}
1149
1150/* void glDeleteRenderbuffers ( GLsizei n, const GLuint *renderbuffers ) */
1151static void
1152android_glDeleteRenderbuffers__ILjava_nio_IntBuffer_2
1153  (JNIEnv *_env, jobject _this, jint n, jobject renderbuffers_buf) {
1154    jint _exception = 0;
1155    const char * _exceptionType = NULL;
1156    const char * _exceptionMessage = NULL;
1157    jintArray _array = (jintArray) 0;
1158    jint _bufferOffset = (jint) 0;
1159    jint _remaining;
1160    GLuint *renderbuffers = (GLuint *) 0;
1161
1162    if (!renderbuffers_buf) {
1163        _exception = 1;
1164        _exceptionType = "java/lang/IllegalArgumentException";
1165        _exceptionMessage = "renderbuffers == null";
1166        goto exit;
1167    }
1168    renderbuffers = (GLuint *)getPointer(_env, renderbuffers_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
1169    if (_remaining < n) {
1170        _exception = 1;
1171        _exceptionType = "java/lang/IllegalArgumentException";
1172        _exceptionMessage = "remaining() < n < needed";
1173        goto exit;
1174    }
1175    if (renderbuffers == NULL) {
1176        char * _renderbuffersBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
1177        renderbuffers = (GLuint *) (_renderbuffersBase + _bufferOffset);
1178    }
1179    glDeleteRenderbuffers(
1180        (GLsizei)n,
1181        (GLuint *)renderbuffers
1182    );
1183
1184exit:
1185    if (_array) {
1186        _env->ReleaseIntArrayElements(_array, (jint*)renderbuffers, JNI_ABORT);
1187    }
1188    if (_exception) {
1189        jniThrowException(_env, _exceptionType, _exceptionMessage);
1190    }
1191}
1192
1193/* void glDeleteShader ( GLuint shader ) */
1194static void
1195android_glDeleteShader__I
1196  (JNIEnv *_env, jobject _this, jint shader) {
1197    glDeleteShader(
1198        (GLuint)shader
1199    );
1200}
1201
1202/* void glDeleteTextures ( GLsizei n, const GLuint *textures ) */
1203static void
1204android_glDeleteTextures__I_3II
1205  (JNIEnv *_env, jobject _this, jint n, jintArray textures_ref, jint offset) {
1206    jint _exception = 0;
1207    const char * _exceptionType = NULL;
1208    const char * _exceptionMessage = NULL;
1209    GLuint *textures_base = (GLuint *) 0;
1210    jint _remaining;
1211    GLuint *textures = (GLuint *) 0;
1212
1213    if (!textures_ref) {
1214        _exception = 1;
1215        _exceptionType = "java/lang/IllegalArgumentException";
1216        _exceptionMessage = "textures == null";
1217        goto exit;
1218    }
1219    if (offset < 0) {
1220        _exception = 1;
1221        _exceptionType = "java/lang/IllegalArgumentException";
1222        _exceptionMessage = "offset < 0";
1223        goto exit;
1224    }
1225    _remaining = _env->GetArrayLength(textures_ref) - offset;
1226    if (_remaining < n) {
1227        _exception = 1;
1228        _exceptionType = "java/lang/IllegalArgumentException";
1229        _exceptionMessage = "length - offset < n < needed";
1230        goto exit;
1231    }
1232    textures_base = (GLuint *)
1233        _env->GetIntArrayElements(textures_ref, (jboolean *)0);
1234    textures = textures_base + offset;
1235
1236    glDeleteTextures(
1237        (GLsizei)n,
1238        (GLuint *)textures
1239    );
1240
1241exit:
1242    if (textures_base) {
1243        _env->ReleaseIntArrayElements(textures_ref, (jint*)textures_base,
1244            JNI_ABORT);
1245    }
1246    if (_exception) {
1247        jniThrowException(_env, _exceptionType, _exceptionMessage);
1248    }
1249}
1250
1251/* void glDeleteTextures ( GLsizei n, const GLuint *textures ) */
1252static void
1253android_glDeleteTextures__ILjava_nio_IntBuffer_2
1254  (JNIEnv *_env, jobject _this, jint n, jobject textures_buf) {
1255    jint _exception = 0;
1256    const char * _exceptionType = NULL;
1257    const char * _exceptionMessage = NULL;
1258    jintArray _array = (jintArray) 0;
1259    jint _bufferOffset = (jint) 0;
1260    jint _remaining;
1261    GLuint *textures = (GLuint *) 0;
1262
1263    if (!textures_buf) {
1264        _exception = 1;
1265        _exceptionType = "java/lang/IllegalArgumentException";
1266        _exceptionMessage = "textures == null";
1267        goto exit;
1268    }
1269    textures = (GLuint *)getPointer(_env, textures_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
1270    if (_remaining < n) {
1271        _exception = 1;
1272        _exceptionType = "java/lang/IllegalArgumentException";
1273        _exceptionMessage = "remaining() < n < needed";
1274        goto exit;
1275    }
1276    if (textures == NULL) {
1277        char * _texturesBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
1278        textures = (GLuint *) (_texturesBase + _bufferOffset);
1279    }
1280    glDeleteTextures(
1281        (GLsizei)n,
1282        (GLuint *)textures
1283    );
1284
1285exit:
1286    if (_array) {
1287        _env->ReleaseIntArrayElements(_array, (jint*)textures, JNI_ABORT);
1288    }
1289    if (_exception) {
1290        jniThrowException(_env, _exceptionType, _exceptionMessage);
1291    }
1292}
1293
1294/* void glDepthFunc ( GLenum func ) */
1295static void
1296android_glDepthFunc__I
1297  (JNIEnv *_env, jobject _this, jint func) {
1298    glDepthFunc(
1299        (GLenum)func
1300    );
1301}
1302
1303/* void glDepthMask ( GLboolean flag ) */
1304static void
1305android_glDepthMask__Z
1306  (JNIEnv *_env, jobject _this, jboolean flag) {
1307    glDepthMask(
1308        (GLboolean)flag
1309    );
1310}
1311
1312/* void glDepthRangef ( GLclampf zNear, GLclampf zFar ) */
1313static void
1314android_glDepthRangef__FF
1315  (JNIEnv *_env, jobject _this, jfloat zNear, jfloat zFar) {
1316    glDepthRangef(
1317        (GLclampf)zNear,
1318        (GLclampf)zFar
1319    );
1320}
1321
1322/* void glDetachShader ( GLuint program, GLuint shader ) */
1323static void
1324android_glDetachShader__II
1325  (JNIEnv *_env, jobject _this, jint program, jint shader) {
1326    glDetachShader(
1327        (GLuint)program,
1328        (GLuint)shader
1329    );
1330}
1331
1332/* void glDisable ( GLenum cap ) */
1333static void
1334android_glDisable__I
1335  (JNIEnv *_env, jobject _this, jint cap) {
1336    glDisable(
1337        (GLenum)cap
1338    );
1339}
1340
1341/* void glDisableVertexAttribArray ( GLuint index ) */
1342static void
1343android_glDisableVertexAttribArray__I
1344  (JNIEnv *_env, jobject _this, jint index) {
1345    glDisableVertexAttribArray(
1346        (GLuint)index
1347    );
1348}
1349
1350/* void glDrawArrays ( GLenum mode, GLint first, GLsizei count ) */
1351static void
1352android_glDrawArrays__III
1353  (JNIEnv *_env, jobject _this, jint mode, jint first, jint count) {
1354    glDrawArrays(
1355        (GLenum)mode,
1356        (GLint)first,
1357        (GLsizei)count
1358    );
1359}
1360
1361/* void glDrawElements ( GLenum mode, GLsizei count, GLenum type, GLint offset ) */
1362static void
1363android_glDrawElements__IIII
1364  (JNIEnv *_env, jobject _this, jint mode, jint count, jint type, jint offset) {
1365    jint _exception = 0;
1366    const char * _exceptionType = NULL;
1367    const char * _exceptionMessage = NULL;
1368    glDrawElements(
1369        (GLenum)mode,
1370        (GLsizei)count,
1371        (GLenum)type,
1372        reinterpret_cast<GLvoid *>(offset)
1373    );
1374    if (_exception) {
1375        jniThrowException(_env, _exceptionType, _exceptionMessage);
1376    }
1377}
1378
1379/* void glDrawElements ( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices ) */
1380static void
1381android_glDrawElements__IIILjava_nio_Buffer_2
1382  (JNIEnv *_env, jobject _this, jint mode, jint count, jint type, jobject indices_buf) {
1383    jint _exception = 0;
1384    const char * _exceptionType = NULL;
1385    const char * _exceptionMessage = NULL;
1386    jarray _array = (jarray) 0;
1387    jint _bufferOffset = (jint) 0;
1388    jint _remaining;
1389    GLvoid *indices = (GLvoid *) 0;
1390
1391    if (!indices_buf) {
1392        _exception = 1;
1393        _exceptionType = "java/lang/IllegalArgumentException";
1394        _exceptionMessage = "indices == null";
1395        goto exit;
1396    }
1397    indices = (GLvoid *)getPointer(_env, indices_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
1398    if (_remaining < count) {
1399        _exception = 1;
1400        _exceptionType = "java/lang/ArrayIndexOutOfBoundsException";
1401        _exceptionMessage = "remaining() < count < needed";
1402        goto exit;
1403    }
1404    if (indices == NULL) {
1405        char * _indicesBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
1406        indices = (GLvoid *) (_indicesBase + _bufferOffset);
1407    }
1408    glDrawElements(
1409        (GLenum)mode,
1410        (GLsizei)count,
1411        (GLenum)type,
1412        (GLvoid *)indices
1413    );
1414
1415exit:
1416    if (_array) {
1417        releasePointer(_env, _array, indices, JNI_FALSE);
1418    }
1419    if (_exception) {
1420        jniThrowException(_env, _exceptionType, _exceptionMessage);
1421    }
1422}
1423
1424/* void glEnable ( GLenum cap ) */
1425static void
1426android_glEnable__I
1427  (JNIEnv *_env, jobject _this, jint cap) {
1428    glEnable(
1429        (GLenum)cap
1430    );
1431}
1432
1433/* void glEnableVertexAttribArray ( GLuint index ) */
1434static void
1435android_glEnableVertexAttribArray__I
1436  (JNIEnv *_env, jobject _this, jint index) {
1437    glEnableVertexAttribArray(
1438        (GLuint)index
1439    );
1440}
1441
1442/* void glFinish ( void ) */
1443static void
1444android_glFinish__
1445  (JNIEnv *_env, jobject _this) {
1446    glFinish();
1447}
1448
1449/* void glFlush ( void ) */
1450static void
1451android_glFlush__
1452  (JNIEnv *_env, jobject _this) {
1453    glFlush();
1454}
1455
1456/* void glFramebufferRenderbuffer ( GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer ) */
1457static void
1458android_glFramebufferRenderbuffer__IIII
1459  (JNIEnv *_env, jobject _this, jint target, jint attachment, jint renderbuffertarget, jint renderbuffer) {
1460    glFramebufferRenderbuffer(
1461        (GLenum)target,
1462        (GLenum)attachment,
1463        (GLenum)renderbuffertarget,
1464        (GLuint)renderbuffer
1465    );
1466}
1467
1468/* void glFramebufferTexture2D ( GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level ) */
1469static void
1470android_glFramebufferTexture2D__IIIII
1471  (JNIEnv *_env, jobject _this, jint target, jint attachment, jint textarget, jint texture, jint level) {
1472    glFramebufferTexture2D(
1473        (GLenum)target,
1474        (GLenum)attachment,
1475        (GLenum)textarget,
1476        (GLuint)texture,
1477        (GLint)level
1478    );
1479}
1480
1481/* void glFrontFace ( GLenum mode ) */
1482static void
1483android_glFrontFace__I
1484  (JNIEnv *_env, jobject _this, jint mode) {
1485    glFrontFace(
1486        (GLenum)mode
1487    );
1488}
1489
1490/* void glGenBuffers ( GLsizei n, GLuint *buffers ) */
1491static void
1492android_glGenBuffers__I_3II
1493  (JNIEnv *_env, jobject _this, jint n, jintArray buffers_ref, jint offset) {
1494    jint _exception = 0;
1495    const char * _exceptionType = NULL;
1496    const char * _exceptionMessage = NULL;
1497    GLuint *buffers_base = (GLuint *) 0;
1498    jint _remaining;
1499    GLuint *buffers = (GLuint *) 0;
1500
1501    if (!buffers_ref) {
1502        _exception = 1;
1503        _exceptionType = "java/lang/IllegalArgumentException";
1504        _exceptionMessage = "buffers == null";
1505        goto exit;
1506    }
1507    if (offset < 0) {
1508        _exception = 1;
1509        _exceptionType = "java/lang/IllegalArgumentException";
1510        _exceptionMessage = "offset < 0";
1511        goto exit;
1512    }
1513    _remaining = _env->GetArrayLength(buffers_ref) - offset;
1514    if (_remaining < n) {
1515        _exception = 1;
1516        _exceptionType = "java/lang/IllegalArgumentException";
1517        _exceptionMessage = "length - offset < n < needed";
1518        goto exit;
1519    }
1520    buffers_base = (GLuint *)
1521        _env->GetIntArrayElements(buffers_ref, (jboolean *)0);
1522    buffers = buffers_base + offset;
1523
1524    glGenBuffers(
1525        (GLsizei)n,
1526        (GLuint *)buffers
1527    );
1528
1529exit:
1530    if (buffers_base) {
1531        _env->ReleaseIntArrayElements(buffers_ref, (jint*)buffers_base,
1532            _exception ? JNI_ABORT: 0);
1533    }
1534    if (_exception) {
1535        jniThrowException(_env, _exceptionType, _exceptionMessage);
1536    }
1537}
1538
1539/* void glGenBuffers ( GLsizei n, GLuint *buffers ) */
1540static void
1541android_glGenBuffers__ILjava_nio_IntBuffer_2
1542  (JNIEnv *_env, jobject _this, jint n, jobject buffers_buf) {
1543    jint _exception = 0;
1544    const char * _exceptionType = NULL;
1545    const char * _exceptionMessage = NULL;
1546    jintArray _array = (jintArray) 0;
1547    jint _bufferOffset = (jint) 0;
1548    jint _remaining;
1549    GLuint *buffers = (GLuint *) 0;
1550
1551    if (!buffers_buf) {
1552        _exception = 1;
1553        _exceptionType = "java/lang/IllegalArgumentException";
1554        _exceptionMessage = "buffers == null";
1555        goto exit;
1556    }
1557    buffers = (GLuint *)getPointer(_env, buffers_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
1558    if (_remaining < n) {
1559        _exception = 1;
1560        _exceptionType = "java/lang/IllegalArgumentException";
1561        _exceptionMessage = "remaining() < n < needed";
1562        goto exit;
1563    }
1564    if (buffers == NULL) {
1565        char * _buffersBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
1566        buffers = (GLuint *) (_buffersBase + _bufferOffset);
1567    }
1568    glGenBuffers(
1569        (GLsizei)n,
1570        (GLuint *)buffers
1571    );
1572
1573exit:
1574    if (_array) {
1575        _env->ReleaseIntArrayElements(_array, (jint*)buffers, _exception ? JNI_ABORT : 0);
1576    }
1577    if (_exception) {
1578        jniThrowException(_env, _exceptionType, _exceptionMessage);
1579    }
1580}
1581
1582/* void glGenerateMipmap ( GLenum target ) */
1583static void
1584android_glGenerateMipmap__I
1585  (JNIEnv *_env, jobject _this, jint target) {
1586    glGenerateMipmap(
1587        (GLenum)target
1588    );
1589}
1590
1591/* void glGenFramebuffers ( GLsizei n, GLuint *framebuffers ) */
1592static void
1593android_glGenFramebuffers__I_3II
1594  (JNIEnv *_env, jobject _this, jint n, jintArray framebuffers_ref, jint offset) {
1595    jint _exception = 0;
1596    const char * _exceptionType = NULL;
1597    const char * _exceptionMessage = NULL;
1598    GLuint *framebuffers_base = (GLuint *) 0;
1599    jint _remaining;
1600    GLuint *framebuffers = (GLuint *) 0;
1601
1602    if (!framebuffers_ref) {
1603        _exception = 1;
1604        _exceptionType = "java/lang/IllegalArgumentException";
1605        _exceptionMessage = "framebuffers == null";
1606        goto exit;
1607    }
1608    if (offset < 0) {
1609        _exception = 1;
1610        _exceptionType = "java/lang/IllegalArgumentException";
1611        _exceptionMessage = "offset < 0";
1612        goto exit;
1613    }
1614    _remaining = _env->GetArrayLength(framebuffers_ref) - offset;
1615    if (_remaining < n) {
1616        _exception = 1;
1617        _exceptionType = "java/lang/IllegalArgumentException";
1618        _exceptionMessage = "length - offset < n < needed";
1619        goto exit;
1620    }
1621    framebuffers_base = (GLuint *)
1622        _env->GetIntArrayElements(framebuffers_ref, (jboolean *)0);
1623    framebuffers = framebuffers_base + offset;
1624
1625    glGenFramebuffers(
1626        (GLsizei)n,
1627        (GLuint *)framebuffers
1628    );
1629
1630exit:
1631    if (framebuffers_base) {
1632        _env->ReleaseIntArrayElements(framebuffers_ref, (jint*)framebuffers_base,
1633            _exception ? JNI_ABORT: 0);
1634    }
1635    if (_exception) {
1636        jniThrowException(_env, _exceptionType, _exceptionMessage);
1637    }
1638}
1639
1640/* void glGenFramebuffers ( GLsizei n, GLuint *framebuffers ) */
1641static void
1642android_glGenFramebuffers__ILjava_nio_IntBuffer_2
1643  (JNIEnv *_env, jobject _this, jint n, jobject framebuffers_buf) {
1644    jint _exception = 0;
1645    const char * _exceptionType = NULL;
1646    const char * _exceptionMessage = NULL;
1647    jintArray _array = (jintArray) 0;
1648    jint _bufferOffset = (jint) 0;
1649    jint _remaining;
1650    GLuint *framebuffers = (GLuint *) 0;
1651
1652    if (!framebuffers_buf) {
1653        _exception = 1;
1654        _exceptionType = "java/lang/IllegalArgumentException";
1655        _exceptionMessage = "framebuffers == null";
1656        goto exit;
1657    }
1658    framebuffers = (GLuint *)getPointer(_env, framebuffers_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
1659    if (_remaining < n) {
1660        _exception = 1;
1661        _exceptionType = "java/lang/IllegalArgumentException";
1662        _exceptionMessage = "remaining() < n < needed";
1663        goto exit;
1664    }
1665    if (framebuffers == NULL) {
1666        char * _framebuffersBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
1667        framebuffers = (GLuint *) (_framebuffersBase + _bufferOffset);
1668    }
1669    glGenFramebuffers(
1670        (GLsizei)n,
1671        (GLuint *)framebuffers
1672    );
1673
1674exit:
1675    if (_array) {
1676        _env->ReleaseIntArrayElements(_array, (jint*)framebuffers, _exception ? JNI_ABORT : 0);
1677    }
1678    if (_exception) {
1679        jniThrowException(_env, _exceptionType, _exceptionMessage);
1680    }
1681}
1682
1683/* void glGenRenderbuffers ( GLsizei n, GLuint *renderbuffers ) */
1684static void
1685android_glGenRenderbuffers__I_3II
1686  (JNIEnv *_env, jobject _this, jint n, jintArray renderbuffers_ref, jint offset) {
1687    jint _exception = 0;
1688    const char * _exceptionType = NULL;
1689    const char * _exceptionMessage = NULL;
1690    GLuint *renderbuffers_base = (GLuint *) 0;
1691    jint _remaining;
1692    GLuint *renderbuffers = (GLuint *) 0;
1693
1694    if (!renderbuffers_ref) {
1695        _exception = 1;
1696        _exceptionType = "java/lang/IllegalArgumentException";
1697        _exceptionMessage = "renderbuffers == null";
1698        goto exit;
1699    }
1700    if (offset < 0) {
1701        _exception = 1;
1702        _exceptionType = "java/lang/IllegalArgumentException";
1703        _exceptionMessage = "offset < 0";
1704        goto exit;
1705    }
1706    _remaining = _env->GetArrayLength(renderbuffers_ref) - offset;
1707    if (_remaining < n) {
1708        _exception = 1;
1709        _exceptionType = "java/lang/IllegalArgumentException";
1710        _exceptionMessage = "length - offset < n < needed";
1711        goto exit;
1712    }
1713    renderbuffers_base = (GLuint *)
1714        _env->GetIntArrayElements(renderbuffers_ref, (jboolean *)0);
1715    renderbuffers = renderbuffers_base + offset;
1716
1717    glGenRenderbuffers(
1718        (GLsizei)n,
1719        (GLuint *)renderbuffers
1720    );
1721
1722exit:
1723    if (renderbuffers_base) {
1724        _env->ReleaseIntArrayElements(renderbuffers_ref, (jint*)renderbuffers_base,
1725            _exception ? JNI_ABORT: 0);
1726    }
1727    if (_exception) {
1728        jniThrowException(_env, _exceptionType, _exceptionMessage);
1729    }
1730}
1731
1732/* void glGenRenderbuffers ( GLsizei n, GLuint *renderbuffers ) */
1733static void
1734android_glGenRenderbuffers__ILjava_nio_IntBuffer_2
1735  (JNIEnv *_env, jobject _this, jint n, jobject renderbuffers_buf) {
1736    jint _exception = 0;
1737    const char * _exceptionType = NULL;
1738    const char * _exceptionMessage = NULL;
1739    jintArray _array = (jintArray) 0;
1740    jint _bufferOffset = (jint) 0;
1741    jint _remaining;
1742    GLuint *renderbuffers = (GLuint *) 0;
1743
1744    if (!renderbuffers_buf) {
1745        _exception = 1;
1746        _exceptionType = "java/lang/IllegalArgumentException";
1747        _exceptionMessage = "renderbuffers == null";
1748        goto exit;
1749    }
1750    renderbuffers = (GLuint *)getPointer(_env, renderbuffers_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
1751    if (_remaining < n) {
1752        _exception = 1;
1753        _exceptionType = "java/lang/IllegalArgumentException";
1754        _exceptionMessage = "remaining() < n < needed";
1755        goto exit;
1756    }
1757    if (renderbuffers == NULL) {
1758        char * _renderbuffersBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
1759        renderbuffers = (GLuint *) (_renderbuffersBase + _bufferOffset);
1760    }
1761    glGenRenderbuffers(
1762        (GLsizei)n,
1763        (GLuint *)renderbuffers
1764    );
1765
1766exit:
1767    if (_array) {
1768        _env->ReleaseIntArrayElements(_array, (jint*)renderbuffers, _exception ? JNI_ABORT : 0);
1769    }
1770    if (_exception) {
1771        jniThrowException(_env, _exceptionType, _exceptionMessage);
1772    }
1773}
1774
1775/* void glGenTextures ( GLsizei n, GLuint *textures ) */
1776static void
1777android_glGenTextures__I_3II
1778  (JNIEnv *_env, jobject _this, jint n, jintArray textures_ref, jint offset) {
1779    jint _exception = 0;
1780    const char * _exceptionType = NULL;
1781    const char * _exceptionMessage = NULL;
1782    GLuint *textures_base = (GLuint *) 0;
1783    jint _remaining;
1784    GLuint *textures = (GLuint *) 0;
1785
1786    if (!textures_ref) {
1787        _exception = 1;
1788        _exceptionType = "java/lang/IllegalArgumentException";
1789        _exceptionMessage = "textures == null";
1790        goto exit;
1791    }
1792    if (offset < 0) {
1793        _exception = 1;
1794        _exceptionType = "java/lang/IllegalArgumentException";
1795        _exceptionMessage = "offset < 0";
1796        goto exit;
1797    }
1798    _remaining = _env->GetArrayLength(textures_ref) - offset;
1799    if (_remaining < n) {
1800        _exception = 1;
1801        _exceptionType = "java/lang/IllegalArgumentException";
1802        _exceptionMessage = "length - offset < n < needed";
1803        goto exit;
1804    }
1805    textures_base = (GLuint *)
1806        _env->GetIntArrayElements(textures_ref, (jboolean *)0);
1807    textures = textures_base + offset;
1808
1809    glGenTextures(
1810        (GLsizei)n,
1811        (GLuint *)textures
1812    );
1813
1814exit:
1815    if (textures_base) {
1816        _env->ReleaseIntArrayElements(textures_ref, (jint*)textures_base,
1817            _exception ? JNI_ABORT: 0);
1818    }
1819    if (_exception) {
1820        jniThrowException(_env, _exceptionType, _exceptionMessage);
1821    }
1822}
1823
1824/* void glGenTextures ( GLsizei n, GLuint *textures ) */
1825static void
1826android_glGenTextures__ILjava_nio_IntBuffer_2
1827  (JNIEnv *_env, jobject _this, jint n, jobject textures_buf) {
1828    jint _exception = 0;
1829    const char * _exceptionType = NULL;
1830    const char * _exceptionMessage = NULL;
1831    jintArray _array = (jintArray) 0;
1832    jint _bufferOffset = (jint) 0;
1833    jint _remaining;
1834    GLuint *textures = (GLuint *) 0;
1835
1836    if (!textures_buf) {
1837        _exception = 1;
1838        _exceptionType = "java/lang/IllegalArgumentException";
1839        _exceptionMessage = "textures == null";
1840        goto exit;
1841    }
1842    textures = (GLuint *)getPointer(_env, textures_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
1843    if (_remaining < n) {
1844        _exception = 1;
1845        _exceptionType = "java/lang/IllegalArgumentException";
1846        _exceptionMessage = "remaining() < n < needed";
1847        goto exit;
1848    }
1849    if (textures == NULL) {
1850        char * _texturesBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
1851        textures = (GLuint *) (_texturesBase + _bufferOffset);
1852    }
1853    glGenTextures(
1854        (GLsizei)n,
1855        (GLuint *)textures
1856    );
1857
1858exit:
1859    if (_array) {
1860        _env->ReleaseIntArrayElements(_array, (jint*)textures, _exception ? JNI_ABORT : 0);
1861    }
1862    if (_exception) {
1863        jniThrowException(_env, _exceptionType, _exceptionMessage);
1864    }
1865}
1866
1867/* void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */
1868static void
1869android_glGetActiveAttrib__III_3II_3II_3II_3BI
1870  (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) {
1871    jint _exception = 0;
1872    const char * _exceptionType;
1873    const char * _exceptionMessage;
1874    GLsizei *length_base = (GLsizei *) 0;
1875    jint _lengthRemaining;
1876    GLsizei *length = (GLsizei *) 0;
1877    GLint *size_base = (GLint *) 0;
1878    jint _sizeRemaining;
1879    GLint *size = (GLint *) 0;
1880    GLenum *type_base = (GLenum *) 0;
1881    jint _typeRemaining;
1882    GLenum *type = (GLenum *) 0;
1883    char *name_base = (char *) 0;
1884    jint _nameRemaining;
1885    char *name = (char *) 0;
1886
1887    if (length_ref) {
1888        if (lengthOffset < 0) {
1889            _exception = 1;
1890            _exceptionType = "java/lang/IllegalArgumentException";
1891            _exceptionMessage = "lengthOffset < 0";
1892            goto exit;
1893        }
1894        _lengthRemaining = _env->GetArrayLength(length_ref) - lengthOffset;
1895        length_base = (GLsizei *)
1896            _env->GetIntArrayElements(length_ref, (jboolean *)0);
1897        length = length_base + lengthOffset;
1898    }
1899
1900    if (!size_ref) {
1901        _exception = 1;
1902        _exceptionType = "java/lang/IllegalArgumentException";
1903        _exceptionMessage = "size == null";
1904        goto exit;
1905    }
1906    if (sizeOffset < 0) {
1907        _exception = 1;
1908        _exceptionType = "java/lang/IllegalArgumentException";
1909        _exceptionMessage = "sizeOffset < 0";
1910        goto exit;
1911    }
1912    _sizeRemaining = _env->GetArrayLength(size_ref) - sizeOffset;
1913    size_base = (GLint *)
1914        _env->GetIntArrayElements(size_ref, (jboolean *)0);
1915    size = size_base + sizeOffset;
1916
1917    if (!type_ref) {
1918        _exception = 1;
1919        _exceptionType = "java/lang/IllegalArgumentException";
1920        _exceptionMessage = "type == null";
1921        goto exit;
1922    }
1923    if (typeOffset < 0) {
1924        _exception = 1;
1925        _exceptionType = "java/lang/IllegalArgumentException";
1926        _exceptionMessage = "typeOffset < 0";
1927        goto exit;
1928    }
1929    _typeRemaining = _env->GetArrayLength(type_ref) - typeOffset;
1930    type_base = (GLenum *)
1931        _env->GetIntArrayElements(type_ref, (jboolean *)0);
1932    type = type_base + typeOffset;
1933
1934    if (!name_ref) {
1935        _exception = 1;
1936        _exceptionType = "java/lang/IllegalArgumentException";
1937        _exceptionMessage = "name == null";
1938        goto exit;
1939    }
1940    if (nameOffset < 0) {
1941        _exception = 1;
1942        _exceptionType = "java/lang/IllegalArgumentException";
1943        _exceptionMessage = "nameOffset < 0";
1944        goto exit;
1945    }
1946    _nameRemaining = _env->GetArrayLength(name_ref) - nameOffset;
1947    name_base = (char *)
1948        _env->GetByteArrayElements(name_ref, (jboolean *)0);
1949    name = name_base + nameOffset;
1950
1951    glGetActiveAttrib(
1952        (GLuint)program,
1953        (GLuint)index,
1954        (GLsizei)bufsize,
1955        (GLsizei *)length,
1956        (GLint *)size,
1957        (GLenum *)type,
1958        (char *)name
1959    );
1960
1961exit:
1962    if (name_base) {
1963        _env->ReleaseByteArrayElements(name_ref, (jbyte*)name_base,
1964            _exception ? JNI_ABORT: 0);
1965    }
1966    if (type_base) {
1967        _env->ReleaseIntArrayElements(type_ref, (jint*)type_base,
1968            _exception ? JNI_ABORT: 0);
1969    }
1970    if (size_base) {
1971        _env->ReleaseIntArrayElements(size_ref, (jint*)size_base,
1972            _exception ? JNI_ABORT: 0);
1973    }
1974    if (length_base) {
1975        _env->ReleaseIntArrayElements(length_ref, (jint*)length_base,
1976            _exception ? JNI_ABORT: 0);
1977    }
1978    if (_exception) {
1979        jniThrowException(_env, _exceptionType, _exceptionMessage);
1980    }
1981}
1982
1983/* void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */
1984static void
1985android_glGetActiveAttrib__IIILjava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2B
1986  (JNIEnv *_env, jobject _this, jint program, jint index, jint bufsize, jobject length_buf, jobject size_buf, jobject type_buf, jbyte name) {
1987    jintArray _lengthArray = (jintArray) 0;
1988    jint _lengthBufferOffset = (jint) 0;
1989    jintArray _sizeArray = (jintArray) 0;
1990    jint _sizeBufferOffset = (jint) 0;
1991    jintArray _typeArray = (jintArray) 0;
1992    jint _typeBufferOffset = (jint) 0;
1993    jint _lengthRemaining;
1994    GLsizei *length = (GLsizei *) 0;
1995    jint _sizeRemaining;
1996    GLint *size = (GLint *) 0;
1997    jint _typeRemaining;
1998    GLenum *type = (GLenum *) 0;
1999
2000    length = (GLsizei *)getPointer(_env, length_buf, (jarray*)&_lengthArray, &_lengthRemaining, &_lengthBufferOffset);
2001    size = (GLint *)getPointer(_env, size_buf, (jarray*)&_sizeArray, &_sizeRemaining, &_sizeBufferOffset);
2002    type = (GLenum *)getPointer(_env, type_buf, (jarray*)&_typeArray, &_typeRemaining, &_typeBufferOffset);
2003    if (length == NULL) {
2004        char * _lengthBase = (char *)_env->GetIntArrayElements(_lengthArray, (jboolean *) 0);
2005        length = (GLsizei *) (_lengthBase + _lengthBufferOffset);
2006    }
2007    if (size == NULL) {
2008        char * _sizeBase = (char *)_env->GetIntArrayElements(_sizeArray, (jboolean *) 0);
2009        size = (GLint *) (_sizeBase + _sizeBufferOffset);
2010    }
2011    if (type == NULL) {
2012        char * _typeBase = (char *)_env->GetIntArrayElements(_typeArray, (jboolean *) 0);
2013        type = (GLenum *) (_typeBase + _typeBufferOffset);
2014    }
2015    glGetActiveAttrib(
2016        (GLuint)program,
2017        (GLuint)index,
2018        (GLsizei)bufsize,
2019        (GLsizei *)length,
2020        (GLint *)size,
2021        (GLenum *)type,
2022        reinterpret_cast<char *>(name)
2023    );
2024    if (_typeArray) {
2025        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _typeArray, (jint*)type, JNI_TRUE);
2026    }
2027    if (_sizeArray) {
2028        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _sizeArray, (jint*)size, JNI_TRUE);
2029    }
2030    if (_lengthArray) {
2031        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _lengthArray, (jint*)length, JNI_TRUE);
2032    }
2033}
2034
2035/* void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */
2036static jstring
2037android_glGetActiveAttrib1
2038  (JNIEnv *_env, jobject _this, jint program, jint index, jintArray size_ref, jint sizeOffset, jintArray type_ref, jint typeOffset) {
2039    jint _exception = 0;
2040    const char * _exceptionType;
2041    const char * _exceptionMessage;
2042    GLint *size_base = (GLint *) 0;
2043    jint _sizeRemaining;
2044    GLint *size = (GLint *) 0;
2045    GLenum *type_base = (GLenum *) 0;
2046    jint _typeRemaining;
2047    GLenum *type = (GLenum *) 0;
2048
2049    jstring result = 0;
2050
2051    GLint len = 0;
2052    glGetProgramiv((GLuint)program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &len);
2053    if (!len) {
2054        return _env->NewStringUTF("");
2055    }
2056    char* buf = (char*) malloc(len);
2057
2058    if (buf == NULL) {
2059        jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory");
2060        return NULL;
2061    }
2062    if (!size_ref) {
2063        _exception = 1;
2064        _exceptionType = "java/lang/IllegalArgumentException";
2065        _exceptionMessage = "size == null";
2066        goto exit;
2067    }
2068    if (sizeOffset < 0) {
2069        _exception = 1;
2070        _exceptionType = "java/lang/IllegalArgumentException";
2071        _exceptionMessage = "sizeOffset < 0";
2072        goto exit;
2073    }
2074    _sizeRemaining = _env->GetArrayLength(size_ref) - sizeOffset;
2075    size_base = (GLint *)
2076        _env->GetIntArrayElements(size_ref, (jboolean *)0);
2077    size = size_base + sizeOffset;
2078
2079    if (!type_ref) {
2080        _exception = 1;
2081        _exceptionType = "java/lang/IllegalArgumentException";
2082        _exceptionMessage = "type == null";
2083        goto exit;
2084    }
2085    if (typeOffset < 0) {
2086        _exception = 1;
2087        _exceptionType = "java/lang/IllegalArgumentException";
2088        _exceptionMessage = "typeOffset < 0";
2089        goto exit;
2090    }
2091    _typeRemaining = _env->GetArrayLength(type_ref) - typeOffset;
2092    type_base = (GLenum *)
2093        _env->GetIntArrayElements(type_ref, (jboolean *)0);
2094    type = type_base + typeOffset;
2095
2096    glGetActiveAttrib(
2097        (GLuint)program,
2098        (GLuint)index,
2099        (GLsizei)len,
2100        NULL,
2101        (GLint *)size,
2102        (GLenum *)type,
2103        (char *)buf
2104    );
2105exit:
2106    if (type_base) {
2107        _env->ReleaseIntArrayElements(type_ref, (jint*)type_base,
2108            _exception ? JNI_ABORT: 0);
2109    }
2110    if (size_base) {
2111        _env->ReleaseIntArrayElements(size_ref, (jint*)size_base,
2112            _exception ? JNI_ABORT: 0);
2113    }
2114    if (_exception != 1) {
2115        result = _env->NewStringUTF(buf);
2116    }
2117    if (buf) {
2118        free(buf);
2119    }
2120    if (_exception) {
2121        jniThrowException(_env, _exceptionType, _exceptionMessage);
2122    }
2123    if (result == 0) {
2124        result = _env->NewStringUTF("");
2125    }
2126
2127    return result;
2128}
2129
2130/* void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */
2131static jstring
2132android_glGetActiveAttrib2
2133  (JNIEnv *_env, jobject _this, jint program, jint index, jobject size_buf, jobject type_buf) {
2134    jintArray _sizeArray = (jintArray) 0;
2135    jint _sizeBufferOffset = (jint) 0;
2136    jintArray _typeArray = (jintArray) 0;
2137    jint _typeBufferOffset = (jint) 0;
2138    jint _lengthRemaining;
2139    GLsizei *length = (GLsizei *) 0;
2140    jint _sizeRemaining;
2141    GLint *size = (GLint *) 0;
2142    jint _typeRemaining;
2143    GLenum *type = (GLenum *) 0;
2144
2145    jstring result = 0;
2146
2147    GLint len = 0;
2148    glGetProgramiv((GLuint)program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &len);
2149    if (!len) {
2150        return _env->NewStringUTF("");
2151    }
2152    char* buf = (char*) malloc(len);
2153
2154    if (buf == NULL) {
2155        jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory");
2156        return NULL;
2157    }
2158
2159    size = (GLint *)getPointer(_env, size_buf, (jarray*)&_sizeArray, &_sizeRemaining, &_sizeBufferOffset);
2160    type = (GLenum *)getPointer(_env, type_buf, (jarray*)&_typeArray, &_typeRemaining, &_typeBufferOffset);
2161    if (size == NULL) {
2162        char * _sizeBase = (char *)_env->GetIntArrayElements(_sizeArray, (jboolean *) 0);
2163        size = (GLint *) (_sizeBase + _sizeBufferOffset);
2164    }
2165    if (type == NULL) {
2166        char * _typeBase = (char *)_env->GetIntArrayElements(_typeArray, (jboolean *) 0);
2167        type = (GLenum *) (_typeBase + _typeBufferOffset);
2168    }
2169    glGetActiveAttrib(
2170        (GLuint)program,
2171        (GLuint)index,
2172        (GLsizei)len,
2173        NULL,
2174        (GLint *)size,
2175        (GLenum *)type,
2176        (char *)buf
2177    );
2178
2179    if (_typeArray) {
2180        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _typeArray, (jint*)type, JNI_TRUE);
2181    }
2182    if (_sizeArray) {
2183        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _sizeArray, (jint*)size, JNI_TRUE);
2184    }
2185    result = _env->NewStringUTF(buf);
2186    if (buf) {
2187        free(buf);
2188    }
2189    return result;
2190}
2191/* void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */
2192static void
2193android_glGetActiveUniform__III_3II_3II_3II_3BI
2194  (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) {
2195    jint _exception = 0;
2196    const char * _exceptionType;
2197    const char * _exceptionMessage;
2198    GLsizei *length_base = (GLsizei *) 0;
2199    jint _lengthRemaining;
2200    GLsizei *length = (GLsizei *) 0;
2201    GLint *size_base = (GLint *) 0;
2202    jint _sizeRemaining;
2203    GLint *size = (GLint *) 0;
2204    GLenum *type_base = (GLenum *) 0;
2205    jint _typeRemaining;
2206    GLenum *type = (GLenum *) 0;
2207    char *name_base = (char *) 0;
2208    jint _nameRemaining;
2209    char *name = (char *) 0;
2210
2211    if (length_ref) {
2212        if (lengthOffset < 0) {
2213            _exception = 1;
2214            _exceptionType = "java/lang/IllegalArgumentException";
2215            _exceptionMessage = "lengthOffset < 0";
2216            goto exit;
2217        }
2218        _lengthRemaining = _env->GetArrayLength(length_ref) - lengthOffset;
2219        length_base = (GLsizei *)
2220            _env->GetIntArrayElements(length_ref, (jboolean *)0);
2221        length = length_base + lengthOffset;
2222    }
2223
2224    if (!size_ref) {
2225        _exception = 1;
2226        _exceptionType = "java/lang/IllegalArgumentException";
2227        _exceptionMessage = "size == null";
2228        goto exit;
2229    }
2230    if (sizeOffset < 0) {
2231        _exception = 1;
2232        _exceptionType = "java/lang/IllegalArgumentException";
2233        _exceptionMessage = "sizeOffset < 0";
2234        goto exit;
2235    }
2236    _sizeRemaining = _env->GetArrayLength(size_ref) - sizeOffset;
2237    size_base = (GLint *)
2238        _env->GetIntArrayElements(size_ref, (jboolean *)0);
2239    size = size_base + sizeOffset;
2240
2241    if (!type_ref) {
2242        _exception = 1;
2243        _exceptionType = "java/lang/IllegalArgumentException";
2244        _exceptionMessage = "type == null";
2245        goto exit;
2246    }
2247    if (typeOffset < 0) {
2248        _exception = 1;
2249        _exceptionType = "java/lang/IllegalArgumentException";
2250        _exceptionMessage = "typeOffset < 0";
2251        goto exit;
2252    }
2253    _typeRemaining = _env->GetArrayLength(type_ref) - typeOffset;
2254    type_base = (GLenum *)
2255        _env->GetIntArrayElements(type_ref, (jboolean *)0);
2256    type = type_base + typeOffset;
2257
2258    if (!name_ref) {
2259        _exception = 1;
2260        _exceptionType = "java/lang/IllegalArgumentException";
2261        _exceptionMessage = "name == null";
2262        goto exit;
2263    }
2264    if (nameOffset < 0) {
2265        _exception = 1;
2266        _exceptionType = "java/lang/IllegalArgumentException";
2267        _exceptionMessage = "nameOffset < 0";
2268        goto exit;
2269    }
2270    _nameRemaining = _env->GetArrayLength(name_ref) - nameOffset;
2271    name_base = (char *)
2272        _env->GetByteArrayElements(name_ref, (jboolean *)0);
2273    name = name_base + nameOffset;
2274
2275    glGetActiveUniform(
2276        (GLuint)program,
2277        (GLuint)index,
2278        (GLsizei)bufsize,
2279        (GLsizei *)length,
2280        (GLint *)size,
2281        (GLenum *)type,
2282        (char *)name
2283    );
2284
2285exit:
2286    if (name_base) {
2287        _env->ReleaseByteArrayElements(name_ref, (jbyte*)name_base,
2288            _exception ? JNI_ABORT: 0);
2289    }
2290    if (type_base) {
2291        _env->ReleaseIntArrayElements(type_ref, (jint*)type_base,
2292            _exception ? JNI_ABORT: 0);
2293    }
2294    if (size_base) {
2295        _env->ReleaseIntArrayElements(size_ref, (jint*)size_base,
2296            _exception ? JNI_ABORT: 0);
2297    }
2298    if (length_base) {
2299        _env->ReleaseIntArrayElements(length_ref, (jint*)length_base,
2300            _exception ? JNI_ABORT: 0);
2301    }
2302    if (_exception) {
2303        jniThrowException(_env, _exceptionType, _exceptionMessage);
2304    }
2305}
2306
2307/* void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */
2308static void
2309android_glGetActiveUniform__IIILjava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2B
2310  (JNIEnv *_env, jobject _this, jint program, jint index, jint bufsize, jobject length_buf, jobject size_buf, jobject type_buf, jbyte name) {
2311    jintArray _lengthArray = (jintArray) 0;
2312    jint _lengthBufferOffset = (jint) 0;
2313    jintArray _sizeArray = (jintArray) 0;
2314    jint _sizeBufferOffset = (jint) 0;
2315    jintArray _typeArray = (jintArray) 0;
2316    jint _typeBufferOffset = (jint) 0;
2317    jint _lengthRemaining;
2318    GLsizei *length = (GLsizei *) 0;
2319    jint _sizeRemaining;
2320    GLint *size = (GLint *) 0;
2321    jint _typeRemaining;
2322    GLenum *type = (GLenum *) 0;
2323
2324    length = (GLsizei *)getPointer(_env, length_buf, (jarray*)&_lengthArray, &_lengthRemaining, &_lengthBufferOffset);
2325    size = (GLint *)getPointer(_env, size_buf, (jarray*)&_sizeArray, &_sizeRemaining, &_sizeBufferOffset);
2326    type = (GLenum *)getPointer(_env, type_buf, (jarray*)&_typeArray, &_typeRemaining, &_typeBufferOffset);
2327    if (length == NULL) {
2328        char * _lengthBase = (char *)_env->GetIntArrayElements(_lengthArray, (jboolean *) 0);
2329        length = (GLsizei *) (_lengthBase + _lengthBufferOffset);
2330    }
2331    if (size == NULL) {
2332        char * _sizeBase = (char *)_env->GetIntArrayElements(_sizeArray, (jboolean *) 0);
2333        size = (GLint *) (_sizeBase + _sizeBufferOffset);
2334    }
2335    if (type == NULL) {
2336        char * _typeBase = (char *)_env->GetIntArrayElements(_typeArray, (jboolean *) 0);
2337        type = (GLenum *) (_typeBase + _typeBufferOffset);
2338    }
2339    glGetActiveUniform(
2340        (GLuint)program,
2341        (GLuint)index,
2342        (GLsizei)bufsize,
2343        (GLsizei *)length,
2344        (GLint *)size,
2345        (GLenum *)type,
2346        reinterpret_cast<char *>(name)
2347    );
2348    if (_typeArray) {
2349        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _typeArray, (jint*)type, JNI_TRUE);
2350    }
2351    if (_sizeArray) {
2352        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _sizeArray, (jint*)size, JNI_TRUE);
2353    }
2354    if (_lengthArray) {
2355        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _lengthArray, (jint*)length, JNI_TRUE);
2356    }
2357}
2358
2359/* void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */
2360static jstring
2361android_glGetActiveUniform1
2362  (JNIEnv *_env, jobject _this, jint program, jint index, jintArray size_ref, jint sizeOffset, jintArray type_ref, jint typeOffset) {
2363    jint _exception = 0;
2364    const char * _exceptionType;
2365    const char * _exceptionMessage;
2366
2367    GLint *size_base = (GLint *) 0;
2368    jint _sizeRemaining;
2369    GLint *size = (GLint *) 0;
2370
2371    GLenum *type_base = (GLenum *) 0;
2372    jint _typeRemaining;
2373    GLenum *type = (GLenum *) 0;
2374
2375    jstring result = 0;
2376
2377    GLint len = 0;
2378    glGetProgramiv((GLuint)program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &len);
2379    if (!len) {
2380        return _env->NewStringUTF("");
2381    }
2382    char* buf = (char*) malloc(len);
2383
2384    if (buf == NULL) {
2385        jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory");
2386        return NULL;
2387    }
2388
2389    if (!size_ref) {
2390        _exception = 1;
2391        _exceptionType = "java/lang/IllegalArgumentException";
2392        _exceptionMessage = "size == null";
2393        goto exit;
2394    }
2395    if (sizeOffset < 0) {
2396        _exception = 1;
2397        _exceptionType = "java/lang/IllegalArgumentException";
2398        _exceptionMessage = "sizeOffset < 0";
2399        goto exit;
2400    }
2401    _sizeRemaining = _env->GetArrayLength(size_ref) - sizeOffset;
2402    size_base = (GLint *)
2403        _env->GetIntArrayElements(size_ref, (jboolean *)0);
2404    size = size_base + sizeOffset;
2405
2406    if (!type_ref) {
2407        _exception = 1;
2408        _exceptionType = "java/lang/IllegalArgumentException";
2409        _exceptionMessage = "type == null";
2410        goto exit;
2411    }
2412    if (typeOffset < 0) {
2413        _exception = 1;
2414        _exceptionType = "java/lang/IllegalArgumentException";
2415        _exceptionMessage = "typeOffset < 0";
2416        goto exit;
2417    }
2418    _typeRemaining = _env->GetArrayLength(type_ref) - typeOffset;
2419    type_base = (GLenum *)
2420        _env->GetIntArrayElements(type_ref, (jboolean *)0);
2421    type = type_base + typeOffset;
2422
2423    glGetActiveUniform(
2424        (GLuint)program,
2425        (GLuint)index,
2426        (GLsizei)len,
2427        NULL,
2428        (GLint *)size,
2429        (GLenum *)type,
2430        (char *)buf
2431    );
2432
2433exit:
2434    if (type_base) {
2435        _env->ReleaseIntArrayElements(type_ref, (jint*)type_base,
2436            _exception ? JNI_ABORT: 0);
2437    }
2438    if (size_base) {
2439        _env->ReleaseIntArrayElements(size_ref, (jint*)size_base,
2440            _exception ? JNI_ABORT: 0);
2441    }
2442    if (_exception != 1) {
2443        result = _env->NewStringUTF(buf);
2444    }
2445    if (buf) {
2446        free(buf);
2447    }
2448    if (_exception) {
2449        jniThrowException(_env, _exceptionType, _exceptionMessage);
2450    }
2451    if (result == 0) {
2452        result = _env->NewStringUTF("");
2453    }
2454    return result;
2455}
2456
2457/* void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) */
2458static jstring
2459android_glGetActiveUniform2
2460  (JNIEnv *_env, jobject _this, jint program, jint index, jobject size_buf, jobject type_buf) {
2461    jintArray _sizeArray = (jintArray) 0;
2462    jint _sizeBufferOffset = (jint) 0;
2463    jintArray _typeArray = (jintArray) 0;
2464    jint _typeBufferOffset = (jint) 0;
2465    jint _sizeRemaining;
2466    GLint *size = (GLint *) 0;
2467    jint _typeRemaining;
2468    GLenum *type = (GLenum *) 0;
2469
2470    jstring result = 0;
2471    GLint len = 0;
2472    glGetProgramiv((GLuint)program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &len);
2473    if (!len) {
2474        return _env->NewStringUTF("");
2475    }
2476    char* buf = (char*) malloc(len);
2477
2478    if (buf == NULL) {
2479        jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory");
2480        return NULL;
2481    }
2482
2483    size = (GLint *)getPointer(_env, size_buf, (jarray*)&_sizeArray, &_sizeRemaining, &_sizeBufferOffset);
2484    type = (GLenum *)getPointer(_env, type_buf, (jarray*)&_typeArray, &_typeRemaining, &_typeBufferOffset);
2485
2486    if (size == NULL) {
2487        char * _sizeBase = (char *)_env->GetIntArrayElements(_sizeArray, (jboolean *) 0);
2488        size = (GLint *) (_sizeBase + _sizeBufferOffset);
2489    }
2490    if (type == NULL) {
2491        char * _typeBase = (char *)_env->GetIntArrayElements(_typeArray, (jboolean *) 0);
2492        type = (GLenum *) (_typeBase + _typeBufferOffset);
2493    }
2494    glGetActiveUniform(
2495        (GLuint)program,
2496        (GLuint)index,
2497        len,
2498        NULL,
2499        (GLint *)size,
2500        (GLenum *)type,
2501        (char *)buf
2502    );
2503
2504    if (_typeArray) {
2505        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _typeArray, (jint*)type, JNI_TRUE);
2506    }
2507    if (_sizeArray) {
2508        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _sizeArray, (jint*)size, JNI_TRUE);
2509    }
2510    result = _env->NewStringUTF(buf);
2511    if (buf) {
2512        free(buf);
2513    }
2514    return result;
2515}
2516/* void glGetAttachedShaders ( GLuint program, GLsizei maxcount, GLsizei *count, GLuint *shaders ) */
2517static void
2518android_glGetAttachedShaders__II_3II_3II
2519  (JNIEnv *_env, jobject _this, jint program, jint maxcount, jintArray count_ref, jint countOffset, jintArray shaders_ref, jint shadersOffset) {
2520    jint _exception = 0;
2521    const char * _exceptionType = NULL;
2522    const char * _exceptionMessage = NULL;
2523    GLsizei *count_base = (GLsizei *) 0;
2524    jint _countRemaining;
2525    GLsizei *count = (GLsizei *) 0;
2526    GLuint *shaders_base = (GLuint *) 0;
2527    jint _shadersRemaining;
2528    GLuint *shaders = (GLuint *) 0;
2529
2530    if (count_ref) {
2531        if (countOffset < 0) {
2532            _exception = 1;
2533            _exceptionType = "java/lang/IllegalArgumentException";
2534            _exceptionMessage = "countOffset < 0";
2535            goto exit;
2536        }
2537        _countRemaining = _env->GetArrayLength(count_ref) - countOffset;
2538        if (_countRemaining < 1) {
2539            _exception = 1;
2540            _exceptionType = "java/lang/IllegalArgumentException";
2541            _exceptionMessage = "length - countOffset < 1 < needed";
2542            goto exit;
2543        }
2544        count_base = (GLsizei *)
2545            _env->GetIntArrayElements(count_ref, (jboolean *)0);
2546        count = count_base + countOffset;
2547    }
2548
2549    if (!shaders_ref) {
2550        _exception = 1;
2551        _exceptionType = "java/lang/IllegalArgumentException";
2552        _exceptionMessage = "shaders == null";
2553        goto exit;
2554    }
2555    if (shadersOffset < 0) {
2556        _exception = 1;
2557        _exceptionType = "java/lang/IllegalArgumentException";
2558        _exceptionMessage = "shadersOffset < 0";
2559        goto exit;
2560    }
2561    _shadersRemaining = _env->GetArrayLength(shaders_ref) - shadersOffset;
2562    if (_shadersRemaining < maxcount) {
2563        _exception = 1;
2564        _exceptionType = "java/lang/IllegalArgumentException";
2565        _exceptionMessage = "length - shadersOffset < maxcount < needed";
2566        goto exit;
2567    }
2568    shaders_base = (GLuint *)
2569        _env->GetIntArrayElements(shaders_ref, (jboolean *)0);
2570    shaders = shaders_base + shadersOffset;
2571
2572    glGetAttachedShaders(
2573        (GLuint)program,
2574        (GLsizei)maxcount,
2575        (GLsizei *)count,
2576        (GLuint *)shaders
2577    );
2578
2579exit:
2580    if (shaders_base) {
2581        _env->ReleaseIntArrayElements(shaders_ref, (jint*)shaders_base,
2582            _exception ? JNI_ABORT: 0);
2583    }
2584    if (count_base) {
2585        _env->ReleaseIntArrayElements(count_ref, (jint*)count_base,
2586            _exception ? JNI_ABORT: 0);
2587    }
2588    if (_exception) {
2589        jniThrowException(_env, _exceptionType, _exceptionMessage);
2590    }
2591}
2592
2593/* void glGetAttachedShaders ( GLuint program, GLsizei maxcount, GLsizei *count, GLuint *shaders ) */
2594static void
2595android_glGetAttachedShaders__IILjava_nio_IntBuffer_2Ljava_nio_IntBuffer_2
2596  (JNIEnv *_env, jobject _this, jint program, jint maxcount, jobject count_buf, jobject shaders_buf) {
2597    jint _exception = 0;
2598    const char * _exceptionType = NULL;
2599    const char * _exceptionMessage = NULL;
2600    jintArray _countArray = (jintArray) 0;
2601    jint _countBufferOffset = (jint) 0;
2602    jintArray _shadersArray = (jintArray) 0;
2603    jint _shadersBufferOffset = (jint) 0;
2604    jint _countRemaining;
2605    GLsizei *count = (GLsizei *) 0;
2606    jint _shadersRemaining;
2607    GLuint *shaders = (GLuint *) 0;
2608
2609    if (count_buf) {
2610        count = (GLsizei *)getPointer(_env, count_buf, (jarray*)&_countArray, &_countRemaining, &_countBufferOffset);
2611        if (_countRemaining < 1) {
2612            _exception = 1;
2613            _exceptionType = "java/lang/IllegalArgumentException";
2614            _exceptionMessage = "remaining() < 1 < needed";
2615            goto exit;
2616        }
2617    }
2618    if (!shaders_buf) {
2619        _exception = 1;
2620        _exceptionType = "java/lang/IllegalArgumentException";
2621        _exceptionMessage = "shaders == null";
2622        goto exit;
2623    }
2624    shaders = (GLuint *)getPointer(_env, shaders_buf, (jarray*)&_shadersArray, &_shadersRemaining, &_shadersBufferOffset);
2625    if (_shadersRemaining < maxcount) {
2626        _exception = 1;
2627        _exceptionType = "java/lang/IllegalArgumentException";
2628        _exceptionMessage = "remaining() < maxcount < needed";
2629        goto exit;
2630    }
2631    if (count_buf && count == NULL) {
2632        char * _countBase = (char *)_env->GetIntArrayElements(_countArray, (jboolean *) 0);
2633        count = (GLsizei *) (_countBase + _countBufferOffset);
2634    }
2635    if (shaders == NULL) {
2636        char * _shadersBase = (char *)_env->GetIntArrayElements(_shadersArray, (jboolean *) 0);
2637        shaders = (GLuint *) (_shadersBase + _shadersBufferOffset);
2638    }
2639    glGetAttachedShaders(
2640        (GLuint)program,
2641        (GLsizei)maxcount,
2642        (GLsizei *)count,
2643        (GLuint *)shaders
2644    );
2645
2646exit:
2647    if (_shadersArray) {
2648        _env->ReleaseIntArrayElements(_shadersArray, (jint*)shaders, _exception ? JNI_ABORT : 0);
2649    }
2650    if (_countArray) {
2651        _env->ReleaseIntArrayElements(_countArray, (jint*)count, _exception ? JNI_ABORT : 0);
2652    }
2653    if (_exception) {
2654        jniThrowException(_env, _exceptionType, _exceptionMessage);
2655    }
2656}
2657
2658/* GLint glGetAttribLocation ( GLuint program, const char *name ) */
2659static jint
2660android_glGetAttribLocation__ILjava_lang_String_2
2661  (JNIEnv *_env, jobject _this, jint program, jstring name) {
2662    jint _exception = 0;
2663    const char * _exceptionType = NULL;
2664    const char * _exceptionMessage = NULL;
2665    GLint _returnValue = 0;
2666    const char* _nativename = 0;
2667
2668    if (!name) {
2669        _exception = 1;
2670        _exceptionType = "java/lang/IllegalArgumentException";
2671        _exceptionMessage = "name == null";
2672        goto exit;
2673    }
2674    _nativename = _env->GetStringUTFChars(name, 0);
2675
2676    _returnValue = glGetAttribLocation(
2677        (GLuint)program,
2678        (char *)_nativename
2679    );
2680
2681exit:
2682    if (_nativename) {
2683        _env->ReleaseStringUTFChars(name, _nativename);
2684    }
2685
2686    if (_exception) {
2687        jniThrowException(_env, _exceptionType, _exceptionMessage);
2688    }
2689    return (jint)_returnValue;
2690}
2691
2692/* void glGetBooleanv ( GLenum pname, GLboolean *params ) */
2693static void
2694android_glGetBooleanv__I_3ZI
2695  (JNIEnv *_env, jobject _this, jint pname, jbooleanArray params_ref, jint offset) {
2696    get<jbooleanArray, BooleanArrayGetter, jboolean*, BooleanArrayReleaser, GLboolean, glGetBooleanv>(
2697        _env, _this, pname, params_ref, offset);
2698}
2699
2700/* void glGetBooleanv ( GLenum pname, GLboolean *params ) */
2701static void
2702android_glGetBooleanv__ILjava_nio_IntBuffer_2
2703  (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
2704    getarray<GLboolean, jintArray, IntArrayGetter, jint*, IntArrayReleaser, glGetBooleanv>(
2705        _env, _this, pname, params_buf);
2706}
2707/* void glGetBufferParameteriv ( GLenum target, GLenum pname, GLint *params ) */
2708static void
2709android_glGetBufferParameteriv__II_3II
2710  (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
2711    jint _exception = 0;
2712    const char * _exceptionType = NULL;
2713    const char * _exceptionMessage = NULL;
2714    GLint *params_base = (GLint *) 0;
2715    jint _remaining;
2716    GLint *params = (GLint *) 0;
2717
2718    if (!params_ref) {
2719        _exception = 1;
2720        _exceptionType = "java/lang/IllegalArgumentException";
2721        _exceptionMessage = "params == null";
2722        goto exit;
2723    }
2724    if (offset < 0) {
2725        _exception = 1;
2726        _exceptionType = "java/lang/IllegalArgumentException";
2727        _exceptionMessage = "offset < 0";
2728        goto exit;
2729    }
2730    _remaining = _env->GetArrayLength(params_ref) - offset;
2731    if (_remaining < 1) {
2732        _exception = 1;
2733        _exceptionType = "java/lang/IllegalArgumentException";
2734        _exceptionMessage = "length - offset < 1 < needed";
2735        goto exit;
2736    }
2737    params_base = (GLint *)
2738        _env->GetIntArrayElements(params_ref, (jboolean *)0);
2739    params = params_base + offset;
2740
2741    glGetBufferParameteriv(
2742        (GLenum)target,
2743        (GLenum)pname,
2744        (GLint *)params
2745    );
2746
2747exit:
2748    if (params_base) {
2749        _env->ReleaseIntArrayElements(params_ref, (jint*)params_base,
2750            _exception ? JNI_ABORT: 0);
2751    }
2752    if (_exception) {
2753        jniThrowException(_env, _exceptionType, _exceptionMessage);
2754    }
2755}
2756
2757/* void glGetBufferParameteriv ( GLenum target, GLenum pname, GLint *params ) */
2758static void
2759android_glGetBufferParameteriv__IILjava_nio_IntBuffer_2
2760  (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
2761    jint _exception = 0;
2762    const char * _exceptionType = NULL;
2763    const char * _exceptionMessage = NULL;
2764    jintArray _array = (jintArray) 0;
2765    jint _bufferOffset = (jint) 0;
2766    jint _remaining;
2767    GLint *params = (GLint *) 0;
2768
2769    if (!params_buf) {
2770        _exception = 1;
2771        _exceptionType = "java/lang/IllegalArgumentException";
2772        _exceptionMessage = "params == null";
2773        goto exit;
2774    }
2775    params = (GLint *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
2776    if (_remaining < 1) {
2777        _exception = 1;
2778        _exceptionType = "java/lang/IllegalArgumentException";
2779        _exceptionMessage = "remaining() < 1 < needed";
2780        goto exit;
2781    }
2782    if (params == NULL) {
2783        char * _paramsBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
2784        params = (GLint *) (_paramsBase + _bufferOffset);
2785    }
2786    glGetBufferParameteriv(
2787        (GLenum)target,
2788        (GLenum)pname,
2789        (GLint *)params
2790    );
2791
2792exit:
2793    if (_array) {
2794        _env->ReleaseIntArrayElements(_array, (jint*)params, _exception ? JNI_ABORT : 0);
2795    }
2796    if (_exception) {
2797        jniThrowException(_env, _exceptionType, _exceptionMessage);
2798    }
2799}
2800
2801/* GLenum glGetError ( void ) */
2802static jint
2803android_glGetError__
2804  (JNIEnv *_env, jobject _this) {
2805    GLenum _returnValue;
2806    _returnValue = glGetError();
2807    return (jint)_returnValue;
2808}
2809
2810/* void glGetFloatv ( GLenum pname, GLfloat *params ) */
2811static void
2812android_glGetFloatv__I_3FI
2813  (JNIEnv *_env, jobject _this, jint pname, jfloatArray params_ref, jint offset) {
2814    get<jfloatArray, FloatArrayGetter, jfloat*, FloatArrayReleaser, GLfloat, glGetFloatv>(
2815        _env, _this, pname, params_ref, offset);
2816}
2817
2818/* void glGetFloatv ( GLenum pname, GLfloat *params ) */
2819static void
2820android_glGetFloatv__ILjava_nio_FloatBuffer_2
2821  (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
2822    getarray<GLfloat, jfloatArray, FloatArrayGetter, jfloat*, FloatArrayReleaser, glGetFloatv>(
2823        _env, _this, pname, params_buf);
2824}
2825/* void glGetFramebufferAttachmentParameteriv ( GLenum target, GLenum attachment, GLenum pname, GLint *params ) */
2826static void
2827android_glGetFramebufferAttachmentParameteriv__III_3II
2828  (JNIEnv *_env, jobject _this, jint target, jint attachment, jint pname, jintArray params_ref, jint offset) {
2829    jint _exception = 0;
2830    const char * _exceptionType = NULL;
2831    const char * _exceptionMessage = NULL;
2832    GLint *params_base = (GLint *) 0;
2833    jint _remaining;
2834    GLint *params = (GLint *) 0;
2835
2836    if (!params_ref) {
2837        _exception = 1;
2838        _exceptionType = "java/lang/IllegalArgumentException";
2839        _exceptionMessage = "params == null";
2840        goto exit;
2841    }
2842    if (offset < 0) {
2843        _exception = 1;
2844        _exceptionType = "java/lang/IllegalArgumentException";
2845        _exceptionMessage = "offset < 0";
2846        goto exit;
2847    }
2848    _remaining = _env->GetArrayLength(params_ref) - offset;
2849    params_base = (GLint *)
2850        _env->GetIntArrayElements(params_ref, (jboolean *)0);
2851    params = params_base + offset;
2852
2853    glGetFramebufferAttachmentParameteriv(
2854        (GLenum)target,
2855        (GLenum)attachment,
2856        (GLenum)pname,
2857        (GLint *)params
2858    );
2859
2860exit:
2861    if (params_base) {
2862        _env->ReleaseIntArrayElements(params_ref, (jint*)params_base,
2863            _exception ? JNI_ABORT: 0);
2864    }
2865    if (_exception) {
2866        jniThrowException(_env, _exceptionType, _exceptionMessage);
2867    }
2868}
2869
2870/* void glGetFramebufferAttachmentParameteriv ( GLenum target, GLenum attachment, GLenum pname, GLint *params ) */
2871static void
2872android_glGetFramebufferAttachmentParameteriv__IIILjava_nio_IntBuffer_2
2873  (JNIEnv *_env, jobject _this, jint target, jint attachment, jint pname, jobject params_buf) {
2874    jint _exception = 0;
2875    const char * _exceptionType = NULL;
2876    const char * _exceptionMessage = NULL;
2877    jintArray _array = (jintArray) 0;
2878    jint _bufferOffset = (jint) 0;
2879    jint _remaining;
2880    GLint *params = (GLint *) 0;
2881
2882    if (!params_buf) {
2883        _exception = 1;
2884        _exceptionType = "java/lang/IllegalArgumentException";
2885        _exceptionMessage = "params == null";
2886        goto exit;
2887    }
2888    params = (GLint *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
2889    if (params == NULL) {
2890        char * _paramsBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
2891        params = (GLint *) (_paramsBase + _bufferOffset);
2892    }
2893    glGetFramebufferAttachmentParameteriv(
2894        (GLenum)target,
2895        (GLenum)attachment,
2896        (GLenum)pname,
2897        (GLint *)params
2898    );
2899
2900exit:
2901    if (_array) {
2902        _env->ReleaseIntArrayElements(_array, (jint*)params, _exception ? JNI_ABORT : 0);
2903    }
2904    if (_exception) {
2905        jniThrowException(_env, _exceptionType, _exceptionMessage);
2906    }
2907}
2908
2909/* void glGetIntegerv ( GLenum pname, GLint *params ) */
2910static void
2911android_glGetIntegerv__I_3II
2912  (JNIEnv *_env, jobject _this, jint pname, jintArray params_ref, jint offset) {
2913    get<jintArray, IntArrayGetter, jint*, IntArrayReleaser, GLint, glGetIntegerv>(
2914        _env, _this, pname, params_ref, offset);
2915}
2916
2917/* void glGetIntegerv ( GLenum pname, GLint *params ) */
2918static void
2919android_glGetIntegerv__ILjava_nio_IntBuffer_2
2920  (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
2921    getarray<GLint, jintArray, IntArrayGetter, jint*, IntArrayReleaser, glGetIntegerv>(
2922        _env, _this, pname, params_buf);
2923}
2924/* void glGetProgramiv ( GLuint program, GLenum pname, GLint *params ) */
2925static void
2926android_glGetProgramiv__II_3II
2927  (JNIEnv *_env, jobject _this, jint program, jint pname, jintArray params_ref, jint offset) {
2928    jint _exception = 0;
2929    const char * _exceptionType = NULL;
2930    const char * _exceptionMessage = NULL;
2931    GLint *params_base = (GLint *) 0;
2932    jint _remaining;
2933    GLint *params = (GLint *) 0;
2934
2935    if (!params_ref) {
2936        _exception = 1;
2937        _exceptionType = "java/lang/IllegalArgumentException";
2938        _exceptionMessage = "params == null";
2939        goto exit;
2940    }
2941    if (offset < 0) {
2942        _exception = 1;
2943        _exceptionType = "java/lang/IllegalArgumentException";
2944        _exceptionMessage = "offset < 0";
2945        goto exit;
2946    }
2947    _remaining = _env->GetArrayLength(params_ref) - offset;
2948    if (_remaining < 1) {
2949        _exception = 1;
2950        _exceptionType = "java/lang/IllegalArgumentException";
2951        _exceptionMessage = "length - offset < 1 < needed";
2952        goto exit;
2953    }
2954    params_base = (GLint *)
2955        _env->GetIntArrayElements(params_ref, (jboolean *)0);
2956    params = params_base + offset;
2957
2958    glGetProgramiv(
2959        (GLuint)program,
2960        (GLenum)pname,
2961        (GLint *)params
2962    );
2963
2964exit:
2965    if (params_base) {
2966        _env->ReleaseIntArrayElements(params_ref, (jint*)params_base,
2967            _exception ? JNI_ABORT: 0);
2968    }
2969    if (_exception) {
2970        jniThrowException(_env, _exceptionType, _exceptionMessage);
2971    }
2972}
2973
2974/* void glGetProgramiv ( GLuint program, GLenum pname, GLint *params ) */
2975static void
2976android_glGetProgramiv__IILjava_nio_IntBuffer_2
2977  (JNIEnv *_env, jobject _this, jint program, jint pname, jobject params_buf) {
2978    jint _exception = 0;
2979    const char * _exceptionType = NULL;
2980    const char * _exceptionMessage = NULL;
2981    jintArray _array = (jintArray) 0;
2982    jint _bufferOffset = (jint) 0;
2983    jint _remaining;
2984    GLint *params = (GLint *) 0;
2985
2986    if (!params_buf) {
2987        _exception = 1;
2988        _exceptionType = "java/lang/IllegalArgumentException";
2989        _exceptionMessage = "params == null";
2990        goto exit;
2991    }
2992    params = (GLint *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
2993    if (_remaining < 1) {
2994        _exception = 1;
2995        _exceptionType = "java/lang/IllegalArgumentException";
2996        _exceptionMessage = "remaining() < 1 < needed";
2997        goto exit;
2998    }
2999    if (params == NULL) {
3000        char * _paramsBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
3001        params = (GLint *) (_paramsBase + _bufferOffset);
3002    }
3003    glGetProgramiv(
3004        (GLuint)program,
3005        (GLenum)pname,
3006        (GLint *)params
3007    );
3008
3009exit:
3010    if (_array) {
3011        _env->ReleaseIntArrayElements(_array, (jint*)params, _exception ? JNI_ABORT : 0);
3012    }
3013    if (_exception) {
3014        jniThrowException(_env, _exceptionType, _exceptionMessage);
3015    }
3016}
3017
3018#include <stdlib.h>
3019
3020/* void glGetProgramInfoLog ( GLuint shader, GLsizei maxLength, GLsizei* length, GLchar* infoLog ) */
3021static jstring android_glGetProgramInfoLog(JNIEnv *_env, jobject, jint shader) {
3022    GLint infoLen = 0;
3023    glGetProgramiv(shader, GL_INFO_LOG_LENGTH, &infoLen);
3024    if (!infoLen) {
3025        return _env->NewStringUTF("");
3026    }
3027    char* buf = (char*) malloc(infoLen);
3028    if (buf == NULL) {
3029        jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory");
3030        return NULL;
3031    }
3032    glGetProgramInfoLog(shader, infoLen, NULL, buf);
3033    jstring result = _env->NewStringUTF(buf);
3034    free(buf);
3035    return result;
3036}
3037/* void glGetRenderbufferParameteriv ( GLenum target, GLenum pname, GLint *params ) */
3038static void
3039android_glGetRenderbufferParameteriv__II_3II
3040  (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
3041    jint _exception = 0;
3042    const char * _exceptionType = NULL;
3043    const char * _exceptionMessage = NULL;
3044    GLint *params_base = (GLint *) 0;
3045    jint _remaining;
3046    GLint *params = (GLint *) 0;
3047
3048    if (!params_ref) {
3049        _exception = 1;
3050        _exceptionType = "java/lang/IllegalArgumentException";
3051        _exceptionMessage = "params == null";
3052        goto exit;
3053    }
3054    if (offset < 0) {
3055        _exception = 1;
3056        _exceptionType = "java/lang/IllegalArgumentException";
3057        _exceptionMessage = "offset < 0";
3058        goto exit;
3059    }
3060    _remaining = _env->GetArrayLength(params_ref) - offset;
3061    if (_remaining < 1) {
3062        _exception = 1;
3063        _exceptionType = "java/lang/IllegalArgumentException";
3064        _exceptionMessage = "length - offset < 1 < needed";
3065        goto exit;
3066    }
3067    params_base = (GLint *)
3068        _env->GetIntArrayElements(params_ref, (jboolean *)0);
3069    params = params_base + offset;
3070
3071    glGetRenderbufferParameteriv(
3072        (GLenum)target,
3073        (GLenum)pname,
3074        (GLint *)params
3075    );
3076
3077exit:
3078    if (params_base) {
3079        _env->ReleaseIntArrayElements(params_ref, (jint*)params_base,
3080            _exception ? JNI_ABORT: 0);
3081    }
3082    if (_exception) {
3083        jniThrowException(_env, _exceptionType, _exceptionMessage);
3084    }
3085}
3086
3087/* void glGetRenderbufferParameteriv ( GLenum target, GLenum pname, GLint *params ) */
3088static void
3089android_glGetRenderbufferParameteriv__IILjava_nio_IntBuffer_2
3090  (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
3091    jint _exception = 0;
3092    const char * _exceptionType = NULL;
3093    const char * _exceptionMessage = NULL;
3094    jintArray _array = (jintArray) 0;
3095    jint _bufferOffset = (jint) 0;
3096    jint _remaining;
3097    GLint *params = (GLint *) 0;
3098
3099    if (!params_buf) {
3100        _exception = 1;
3101        _exceptionType = "java/lang/IllegalArgumentException";
3102        _exceptionMessage = "params == null";
3103        goto exit;
3104    }
3105    params = (GLint *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
3106    if (_remaining < 1) {
3107        _exception = 1;
3108        _exceptionType = "java/lang/IllegalArgumentException";
3109        _exceptionMessage = "remaining() < 1 < needed";
3110        goto exit;
3111    }
3112    if (params == NULL) {
3113        char * _paramsBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
3114        params = (GLint *) (_paramsBase + _bufferOffset);
3115    }
3116    glGetRenderbufferParameteriv(
3117        (GLenum)target,
3118        (GLenum)pname,
3119        (GLint *)params
3120    );
3121
3122exit:
3123    if (_array) {
3124        _env->ReleaseIntArrayElements(_array, (jint*)params, _exception ? JNI_ABORT : 0);
3125    }
3126    if (_exception) {
3127        jniThrowException(_env, _exceptionType, _exceptionMessage);
3128    }
3129}
3130
3131/* void glGetShaderiv ( GLuint shader, GLenum pname, GLint *params ) */
3132static void
3133android_glGetShaderiv__II_3II
3134  (JNIEnv *_env, jobject _this, jint shader, jint pname, jintArray params_ref, jint offset) {
3135    jint _exception = 0;
3136    const char * _exceptionType = NULL;
3137    const char * _exceptionMessage = NULL;
3138    GLint *params_base = (GLint *) 0;
3139    jint _remaining;
3140    GLint *params = (GLint *) 0;
3141
3142    if (!params_ref) {
3143        _exception = 1;
3144        _exceptionType = "java/lang/IllegalArgumentException";
3145        _exceptionMessage = "params == null";
3146        goto exit;
3147    }
3148    if (offset < 0) {
3149        _exception = 1;
3150        _exceptionType = "java/lang/IllegalArgumentException";
3151        _exceptionMessage = "offset < 0";
3152        goto exit;
3153    }
3154    _remaining = _env->GetArrayLength(params_ref) - offset;
3155    if (_remaining < 1) {
3156        _exception = 1;
3157        _exceptionType = "java/lang/IllegalArgumentException";
3158        _exceptionMessage = "length - offset < 1 < needed";
3159        goto exit;
3160    }
3161    params_base = (GLint *)
3162        _env->GetIntArrayElements(params_ref, (jboolean *)0);
3163    params = params_base + offset;
3164
3165    glGetShaderiv(
3166        (GLuint)shader,
3167        (GLenum)pname,
3168        (GLint *)params
3169    );
3170
3171exit:
3172    if (params_base) {
3173        _env->ReleaseIntArrayElements(params_ref, (jint*)params_base,
3174            _exception ? JNI_ABORT: 0);
3175    }
3176    if (_exception) {
3177        jniThrowException(_env, _exceptionType, _exceptionMessage);
3178    }
3179}
3180
3181/* void glGetShaderiv ( GLuint shader, GLenum pname, GLint *params ) */
3182static void
3183android_glGetShaderiv__IILjava_nio_IntBuffer_2
3184  (JNIEnv *_env, jobject _this, jint shader, jint pname, jobject params_buf) {
3185    jint _exception = 0;
3186    const char * _exceptionType = NULL;
3187    const char * _exceptionMessage = NULL;
3188    jintArray _array = (jintArray) 0;
3189    jint _bufferOffset = (jint) 0;
3190    jint _remaining;
3191    GLint *params = (GLint *) 0;
3192
3193    if (!params_buf) {
3194        _exception = 1;
3195        _exceptionType = "java/lang/IllegalArgumentException";
3196        _exceptionMessage = "params == null";
3197        goto exit;
3198    }
3199    params = (GLint *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
3200    if (_remaining < 1) {
3201        _exception = 1;
3202        _exceptionType = "java/lang/IllegalArgumentException";
3203        _exceptionMessage = "remaining() < 1 < needed";
3204        goto exit;
3205    }
3206    if (params == NULL) {
3207        char * _paramsBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
3208        params = (GLint *) (_paramsBase + _bufferOffset);
3209    }
3210    glGetShaderiv(
3211        (GLuint)shader,
3212        (GLenum)pname,
3213        (GLint *)params
3214    );
3215
3216exit:
3217    if (_array) {
3218        _env->ReleaseIntArrayElements(_array, (jint*)params, _exception ? JNI_ABORT : 0);
3219    }
3220    if (_exception) {
3221        jniThrowException(_env, _exceptionType, _exceptionMessage);
3222    }
3223}
3224
3225#include <stdlib.h>
3226
3227/* void glGetShaderInfoLog ( GLuint shader, GLsizei maxLength, GLsizei* length, GLchar* infoLog ) */
3228static jstring android_glGetShaderInfoLog(JNIEnv *_env, jobject, jint shader) {
3229    GLint infoLen = 0;
3230    glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen);
3231    if (!infoLen) {
3232        infoLen = 512;
3233    }
3234    char* buf = (char*) malloc(infoLen);
3235    if (buf == NULL) {
3236        jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory");
3237        return NULL;
3238    }
3239    GLsizei outLen = 0;
3240    glGetShaderInfoLog(shader, infoLen, &outLen, buf);
3241    jstring result = _env->NewStringUTF(outLen == 0 ? "" : buf);
3242    free(buf);
3243    return result;
3244}
3245/* void glGetShaderPrecisionFormat ( GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision ) */
3246static void
3247android_glGetShaderPrecisionFormat__II_3II_3II
3248  (JNIEnv *_env, jobject _this, jint shadertype, jint precisiontype, jintArray range_ref, jint rangeOffset, jintArray precision_ref, jint precisionOffset) {
3249    jint _exception = 0;
3250    const char * _exceptionType = NULL;
3251    const char * _exceptionMessage = NULL;
3252    GLint *range_base = (GLint *) 0;
3253    jint _rangeRemaining;
3254    GLint *range = (GLint *) 0;
3255    GLint *precision_base = (GLint *) 0;
3256    jint _precisionRemaining;
3257    GLint *precision = (GLint *) 0;
3258
3259    if (!range_ref) {
3260        _exception = 1;
3261        _exceptionType = "java/lang/IllegalArgumentException";
3262        _exceptionMessage = "range == null";
3263        goto exit;
3264    }
3265    if (rangeOffset < 0) {
3266        _exception = 1;
3267        _exceptionType = "java/lang/IllegalArgumentException";
3268        _exceptionMessage = "rangeOffset < 0";
3269        goto exit;
3270    }
3271    _rangeRemaining = _env->GetArrayLength(range_ref) - rangeOffset;
3272    if (_rangeRemaining < 1) {
3273        _exception = 1;
3274        _exceptionType = "java/lang/IllegalArgumentException";
3275        _exceptionMessage = "length - rangeOffset < 1 < needed";
3276        goto exit;
3277    }
3278    range_base = (GLint *)
3279        _env->GetIntArrayElements(range_ref, (jboolean *)0);
3280    range = range_base + rangeOffset;
3281
3282    if (!precision_ref) {
3283        _exception = 1;
3284        _exceptionType = "java/lang/IllegalArgumentException";
3285        _exceptionMessage = "precision == null";
3286        goto exit;
3287    }
3288    if (precisionOffset < 0) {
3289        _exception = 1;
3290        _exceptionType = "java/lang/IllegalArgumentException";
3291        _exceptionMessage = "precisionOffset < 0";
3292        goto exit;
3293    }
3294    _precisionRemaining = _env->GetArrayLength(precision_ref) - precisionOffset;
3295    if (_precisionRemaining < 1) {
3296        _exception = 1;
3297        _exceptionType = "java/lang/IllegalArgumentException";
3298        _exceptionMessage = "length - precisionOffset < 1 < needed";
3299        goto exit;
3300    }
3301    precision_base = (GLint *)
3302        _env->GetIntArrayElements(precision_ref, (jboolean *)0);
3303    precision = precision_base + precisionOffset;
3304
3305    glGetShaderPrecisionFormat(
3306        (GLenum)shadertype,
3307        (GLenum)precisiontype,
3308        (GLint *)range,
3309        (GLint *)precision
3310    );
3311
3312