17ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/*
27ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall * Copyright 2014 The Android Open Source Project
37ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall *
47ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall * Licensed under the Apache License, Version 2.0 (the "License");
57ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall * you may not use this file except in compliance with the License.
67ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall * You may obtain a copy of the License at
77ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall *
87ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall *      http://www.apache.org/licenses/LICENSE-2.0
97ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall *
107ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall * Unless required by applicable law or agreed to in writing, software
117ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall * distributed under the License is distributed on an "AS IS" BASIS,
127ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
137ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall * See the License for the specific language governing permissions and
147ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall * limitations under the License.
157ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall */
167ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
177ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall// This source file is automatically generated
187ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
19bfe6333c3cf529600f41f14e3b8c5846e632c9a2Andreas Gampe#pragma GCC diagnostic ignored "-Wunused-variable"
20bfe6333c3cf529600f41f14e3b8c5846e632c9a2Andreas Gampe#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
21bfe6333c3cf529600f41f14e3b8c5846e632c9a2Andreas Gampe#pragma GCC diagnostic ignored "-Wunused-function"
22bfe6333c3cf529600f41f14e3b8c5846e632c9a2Andreas Gampe
237ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall#include <stdint.h>
247ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall#include <GLES3/gl31.h>
259626f8203a8c222b8960a49cdc66d540fdb688b0Jesse Hall#include <jni.h>
269626f8203a8c222b8960a49cdc66d540fdb688b0Jesse Hall#include <JNIHelp.h>
277ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall#include <android_runtime/AndroidRuntime.h>
287ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall#include <utils/misc.h>
297ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall#include <assert.h>
307ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
317ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic int initialized = 0;
327ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
337ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic jclass nioAccessClass;
347ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic jclass bufferClass;
357ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic jmethodID getBasePointerID;
367ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic jmethodID getBaseArrayID;
377ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic jmethodID getBaseArrayOffsetID;
387ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic jfieldID positionID;
397ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic jfieldID limitID;
407ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic jfieldID elementSizeShiftID;
417ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
427ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
437ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* special calls implemented in Android's GLES wrapper used to more
447ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall * efficiently bound-check passed arrays */
457ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallextern "C" {
467ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall#ifdef GL_VERSION_ES_CM_1_1
477ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse HallGL_API void GL_APIENTRY glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
487ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        const GLvoid *ptr, GLsizei count);
497ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse HallGL_API void GL_APIENTRY glNormalPointerBounds(GLenum type, GLsizei stride,
507ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        const GLvoid *pointer, GLsizei count);
517ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse HallGL_API void GL_APIENTRY glTexCoordPointerBounds(GLint size, GLenum type,
527ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        GLsizei stride, const GLvoid *pointer, GLsizei count);
537ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse HallGL_API void GL_APIENTRY glVertexPointerBounds(GLint size, GLenum type,
547ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        GLsizei stride, const GLvoid *pointer, GLsizei count);
557ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse HallGL_API void GL_APIENTRY glPointSizePointerOESBounds(GLenum type,
567ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        GLsizei stride, const GLvoid *pointer, GLsizei count);
577ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse HallGL_API void GL_APIENTRY glMatrixIndexPointerOESBounds(GLint size, GLenum type,
587ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        GLsizei stride, const GLvoid *pointer, GLsizei count);
597ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse HallGL_API void GL_APIENTRY glWeightPointerOESBounds(GLint size, GLenum type,
607ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        GLsizei stride, const GLvoid *pointer, GLsizei count);
617ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall#endif
627ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall#ifdef GL_ES_VERSION_2_0
637ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void glVertexAttribPointerBounds(GLuint indx, GLint size, GLenum type,
647ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        GLboolean normalized, GLsizei stride, const GLvoid *pointer, GLsizei count) {
657ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    glVertexAttribPointer(indx, size, type, normalized, stride, pointer);
667ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
677ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall#endif
687ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall#ifdef GL_ES_VERSION_3_0
697ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void glVertexAttribIPointerBounds(GLuint indx, GLint size, GLenum type,
707ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        GLsizei stride, const GLvoid *pointer, GLsizei count) {
717ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    glVertexAttribIPointer(indx, size, type, stride, pointer);
727ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
737ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall#endif
747ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
757ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
767ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* Cache method IDs each time the class is loaded. */
777ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
787ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void
797ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse HallnativeClassInit(JNIEnv *_env, jclass glImplClass)
807ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall{
817ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess");
827ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    nioAccessClass = (jclass) _env->NewGlobalRef(nioAccessClassLocal);
837ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
847ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jclass bufferClassLocal = _env->FindClass("java/nio/Buffer");
857ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    bufferClass = (jclass) _env->NewGlobalRef(bufferClassLocal);
867ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
877ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    getBasePointerID = _env->GetStaticMethodID(nioAccessClass,
887ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            "getBasePointer", "(Ljava/nio/Buffer;)J");
897ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    getBaseArrayID = _env->GetStaticMethodID(nioAccessClass,
907ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            "getBaseArray", "(Ljava/nio/Buffer;)Ljava/lang/Object;");
917ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    getBaseArrayOffsetID = _env->GetStaticMethodID(nioAccessClass,
927ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            "getBaseArrayOffset", "(Ljava/nio/Buffer;)I");
937ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
947ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    positionID = _env->GetFieldID(bufferClass, "position", "I");
957ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    limitID = _env->GetFieldID(bufferClass, "limit", "I");
967ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    elementSizeShiftID =
977ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _env->GetFieldID(bufferClass, "_elementSizeShift", "I");
987ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
997ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
1007ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void *
1017ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse HallgetPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining, jint *offset)
1027ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall{
1037ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint position;
1047ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint limit;
1057ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint elementSizeShift;
1067ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jlong pointer;
1077ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
1087ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    position = _env->GetIntField(buffer, positionID);
1097ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    limit = _env->GetIntField(buffer, limitID);
1107ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    elementSizeShift = _env->GetIntField(buffer, elementSizeShiftID);
1117ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    *remaining = (limit - position) << elementSizeShift;
1127ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    pointer = _env->CallStaticLongMethod(nioAccessClass,
1137ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            getBasePointerID, buffer);
1147ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (pointer != 0L) {
1157ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        *array = NULL;
1167ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        return reinterpret_cast<void*>(pointer);
1177ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
1187ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
1197ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    *array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
1207ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            getBaseArrayID, buffer);
1217ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    *offset = _env->CallStaticIntMethod(nioAccessClass,
1227ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            getBaseArrayOffsetID, buffer);
1237ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
1247ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    return NULL;
1257ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
1267ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
1275b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchiclass ByteArrayGetter {
1285b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchipublic:
1295b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    static void* Get(JNIEnv* _env, jbyteArray array, jboolean* is_copy) {
1305b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        return _env->GetByteArrayElements(array, is_copy);
1315b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    }
1325b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi};
1335b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchiclass BooleanArrayGetter {
1345b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchipublic:
1355b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    static void* Get(JNIEnv* _env, jbooleanArray array, jboolean* is_copy) {
1365b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        return _env->GetBooleanArrayElements(array, is_copy);
1375b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    }
1385b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi};
1395b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchiclass CharArrayGetter {
1405b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchipublic:
1415b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    static void* Get(JNIEnv* _env, jcharArray array, jboolean* is_copy) {
1425b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        return _env->GetCharArrayElements(array, is_copy);
1435b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    }
1445b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi};
1455b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchiclass ShortArrayGetter {
1465b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchipublic:
1475b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    static void* Get(JNIEnv* _env, jshortArray array, jboolean* is_copy) {
1485b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        return _env->GetShortArrayElements(array, is_copy);
1495b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    }
1505b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi};
1515b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchiclass IntArrayGetter {
1525b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchipublic:
1535b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    static void* Get(JNIEnv* _env, jintArray array, jboolean* is_copy) {
1545b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        return _env->GetIntArrayElements(array, is_copy);
1555b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    }
1565b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi};
1575b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchiclass LongArrayGetter {
1585b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchipublic:
1595b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    static void* Get(JNIEnv* _env, jlongArray array, jboolean* is_copy) {
1605b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        return _env->GetLongArrayElements(array, is_copy);
1615b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    }
1625b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi};
1635b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchiclass FloatArrayGetter {
1645b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchipublic:
1655b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    static void* Get(JNIEnv* _env, jfloatArray array, jboolean* is_copy) {
1665b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        return _env->GetFloatArrayElements(array, is_copy);
1675b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    }
1685b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi};
1695b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchiclass DoubleArrayGetter {
1705b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchipublic:
1715b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    static void* Get(JNIEnv* _env, jdoubleArray array, jboolean* is_copy) {
1725b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        return _env->GetDoubleArrayElements(array, is_copy);
1735b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    }
1745b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi};
1755b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi
1765b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchitemplate<typename JTYPEARRAY, typename ARRAYGETTER>
1775b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchistatic void*
1785b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi YamauchigetArrayPointer(JNIEnv *_env, JTYPEARRAY array, jboolean* is_copy) {
1795b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    return ARRAYGETTER::Get(_env, array, is_copy);
1805b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi}
1815b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi
1825b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchiclass ByteArrayReleaser {
1835b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchipublic:
1845b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    static void Release(JNIEnv* _env, jbyteArray array, jbyte* data, jboolean commit) {
1855b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->ReleaseByteArrayElements(array, data, commit ? 0 : JNI_ABORT);
1865b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    }
1875b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi};
1885b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchiclass BooleanArrayReleaser {
1895b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchipublic:
1905b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    static void Release(JNIEnv* _env, jbooleanArray array, jboolean* data, jboolean commit) {
1915b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->ReleaseBooleanArrayElements(array, data, commit ? 0 : JNI_ABORT);
1925b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    }
1935b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi};
1945b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchiclass CharArrayReleaser {
1955b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchipublic:
1965b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    static void Release(JNIEnv* _env, jcharArray array, jchar* data, jboolean commit) {
1975b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->ReleaseCharArrayElements(array, data, commit ? 0 : JNI_ABORT);
1985b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    }
1995b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi};
2005b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchiclass ShortArrayReleaser {
2015b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchipublic:
2025b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    static void Release(JNIEnv* _env, jshortArray array, jshort* data, jboolean commit) {
2035b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->ReleaseShortArrayElements(array, data, commit ? 0 : JNI_ABORT);
2045b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    }
2055b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi};
2065b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchiclass IntArrayReleaser {
2075b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchipublic:
2085b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    static void Release(JNIEnv* _env, jintArray array, jint* data, jboolean commit) {
2095b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->ReleaseIntArrayElements(array, data, commit ? 0 : JNI_ABORT);
2105b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    }
2115b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi};
2125b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchiclass LongArrayReleaser {
2135b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchipublic:
2145b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    static void Release(JNIEnv* _env, jlongArray array, jlong* data, jboolean commit) {
2155b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->ReleaseLongArrayElements(array, data, commit ? 0 : JNI_ABORT);
2165b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    }
2175b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi};
2185b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchiclass FloatArrayReleaser {
2195b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchipublic:
2205b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    static void Release(JNIEnv* _env, jfloatArray array, jfloat* data, jboolean commit) {
2215b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->ReleaseFloatArrayElements(array, data, commit ? 0 : JNI_ABORT);
2225b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    }
2235b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi};
2245b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchiclass DoubleArrayReleaser {
2255b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchipublic:
2265b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    static void Release(JNIEnv* _env, jdoubleArray array, jdouble* data, jboolean commit) {
2275b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->ReleaseDoubleArrayElements(array, data, commit ? 0 : JNI_ABORT);
2285b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    }
2295b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi};
2305b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi
2315b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchitemplate<typename JTYPEARRAY, typename NTYPEARRAY, typename ARRAYRELEASER>
2325b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchistatic void
2335b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi YamauchireleaseArrayPointer(JNIEnv *_env, JTYPEARRAY array, NTYPEARRAY data, jboolean commit) {
2345b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    ARRAYRELEASER::Release(_env, array, data, commit);
2355b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi}
2365b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi
2377ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void
2387ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse HallreleasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit)
2397ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall{
2407ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    _env->ReleasePrimitiveArrayCritical(array, data,
2417ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall                       commit ? 0 : JNI_ABORT);
2427ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
2437ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
2447ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void *
2457ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse HallgetDirectBufferPointer(JNIEnv *_env, jobject buffer) {
2467ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    char* buf = (char*) _env->GetDirectBufferAddress(buffer);
2477ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (buf) {
2487ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        jint position = _env->GetIntField(buffer, positionID);
2497ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        jint elementSizeShift = _env->GetIntField(buffer, elementSizeShiftID);
2507ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        buf += position << elementSizeShift;
2517ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    } else {
2527ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        jniThrowException(_env, "java/lang/IllegalArgumentException",
2537ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall                          "Must use a native order direct Buffer");
2547ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
2557ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    return (void*) buf;
2567ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
2577ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
2587ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall// --------------------------------------------------------------------------
2597ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
2607ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/*
2617ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall * returns the number of values glGet returns for a given pname.
2627ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall *
2637ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall * The code below is written such that pnames requiring only one values
2647ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall * are the default (and are not explicitely tested for). This makes the
2657ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall * checking code much shorter/readable/efficient.
2667ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall *
2677ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall * This means that unknown pnames (e.g.: extensions) will default to 1. If
2687ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall * that unknown pname needs more than 1 value, then the validation check
2697ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall * is incomplete and the app may crash if it passed the wrong number params.
2707ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall */
2717ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic int getNeededCount(GLint pname) {
2727ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    int needed = 1;
2737ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall#ifdef GL_ES_VERSION_2_0
2747ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    // GLES 2.x pnames
2757ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    switch (pname) {
2767ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_ALIASED_LINE_WIDTH_RANGE:
2777ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_ALIASED_POINT_SIZE_RANGE:
2787ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            needed = 2;
2797ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            break;
2807ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
2817ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_BLEND_COLOR:
2827ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_COLOR_CLEAR_VALUE:
2837ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_COLOR_WRITEMASK:
2847ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_SCISSOR_BOX:
2857ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_VIEWPORT:
2867ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            needed = 4;
2877ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            break;
2887ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
2897ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_COMPRESSED_TEXTURE_FORMATS:
2907ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &needed);
2917ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            break;
2927ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
2937ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_SHADER_BINARY_FORMATS:
2947ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &needed);
2957ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            break;
2967ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
2977ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall#endif
2987ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
2997ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall#ifdef GL_VERSION_ES_CM_1_1
3007ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    // GLES 1.x pnames
3017ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    switch (pname) {
3027ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_ALIASED_LINE_WIDTH_RANGE:
3037ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_ALIASED_POINT_SIZE_RANGE:
3047ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_DEPTH_RANGE:
3057ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_SMOOTH_LINE_WIDTH_RANGE:
3067ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_SMOOTH_POINT_SIZE_RANGE:
3077ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            needed = 2;
3087ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            break;
3097ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
3107ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_CURRENT_NORMAL:
3117ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_POINT_DISTANCE_ATTENUATION:
3127ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            needed = 3;
3137ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            break;
3147ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
3157ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_COLOR_CLEAR_VALUE:
3167ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_COLOR_WRITEMASK:
3177ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_CURRENT_COLOR:
3187ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_CURRENT_TEXTURE_COORDS:
3197ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_FOG_COLOR:
3207ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_LIGHT_MODEL_AMBIENT:
3217ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_SCISSOR_BOX:
3227ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_VIEWPORT:
3237ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            needed = 4;
3247ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            break;
3257ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
3267ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_MODELVIEW_MATRIX:
3277ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_PROJECTION_MATRIX:
3287ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_TEXTURE_MATRIX:
3297ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            needed = 16;
3307ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            break;
3317ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
3327ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        case GL_COMPRESSED_TEXTURE_FORMATS:
3337ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &needed);
3347ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            break;
3357ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
3367ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall#endif
3377ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    return needed;
3387ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
3397ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
3405b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchitemplate <typename JTYPEARRAY, typename ARRAYGETTER, typename NTYPEARRAY,
3415b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi          typename ARRAYRELEASER, typename CTYPE, void GET(GLenum, CTYPE*)>
3427ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void
3437ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallget
3447ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall  (JNIEnv *_env, jobject _this, jint pname, JTYPEARRAY params_ref, jint offset) {
3457ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _exception = 0;
3467ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    const char * _exceptionType;
3477ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    const char * _exceptionMessage;
3487ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    CTYPE *params_base = (CTYPE *) 0;
3497ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _remaining;
3507ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    CTYPE *params = (CTYPE *) 0;
3517ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    int _needed = 0;
3527ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
3537ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (!params_ref) {
3547ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exception = 1;
3557ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionType = "java/lang/IllegalArgumentException";
3567ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionMessage = "params == null";
3577ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        goto exit;
3587ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
3597ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (offset < 0) {
3607ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exception = 1;
3617ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionType = "java/lang/IllegalArgumentException";
3627ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionMessage = "offset < 0";
3637ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        goto exit;
3647ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
3657ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    _remaining = _env->GetArrayLength(params_ref) - offset;
3667ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    _needed = getNeededCount(pname);
3677ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    // if we didn't find this pname, we just assume the user passed
3687ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    // an array of the right size -- this might happen with extensions
3697ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    // or if we forget an enum here.
3707ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (_remaining < _needed) {
3717ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exception = 1;
3727ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionType = "java/lang/IllegalArgumentException";
3737ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionMessage = "length - offset < needed";
3747ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        goto exit;
3757ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
3765b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    params_base = (CTYPE *) getArrayPointer<JTYPEARRAY, ARRAYGETTER>(
3775b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env, params_ref, (jboolean *)0);
3787ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    params = params_base + offset;
3797ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
3807ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GET(
3817ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLenum)pname,
3827ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (CTYPE *)params
3837ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    );
3847ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
3857ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallexit:
3867ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (params_base) {
3875b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        releaseArrayPointer<JTYPEARRAY, NTYPEARRAY, ARRAYRELEASER>(
3885b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi            _env, params_ref, params_base, !_exception);
3897ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
3907ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (_exception) {
3917ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        jniThrowException(_env, _exceptionType, _exceptionMessage);
3927ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
3937ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
3947ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
3957ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
3965b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchitemplate <typename CTYPE, typename JTYPEARRAY, typename ARRAYGETTER, typename NTYPEARRAY,
3975b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi          typename ARRAYRELEASER, void GET(GLenum, CTYPE*)>
3987ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void
3997ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallgetarray
4007ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall  (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
4017ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _exception = 0;
4027ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    const char * _exceptionType;
4037ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    const char * _exceptionMessage;
4045b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    JTYPEARRAY _array = (JTYPEARRAY) 0;
4057ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _bufferOffset = (jint) 0;
4067ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _remaining;
4077ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    CTYPE *params = (CTYPE *) 0;
4087ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    int _needed = 0;
4097ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
4105b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    params = (CTYPE *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
4117ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    _remaining /= sizeof(CTYPE);    // convert from bytes to item count
4127ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    _needed = getNeededCount(pname);
4137ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    // if we didn't find this pname, we just assume the user passed
4147ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    // an array of the right size -- this might happen with extensions
4157ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    // or if we forget an enum here.
4167ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (_needed>0 && _remaining < _needed) {
4177ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exception = 1;
4187ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionType = "java/lang/IllegalArgumentException";
4197ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionMessage = "remaining() < needed";
4207ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        goto exit;
4217ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
4227ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (params == NULL) {
4235b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        char * _paramsBase = (char *) getArrayPointer<JTYPEARRAY, ARRAYGETTER>(
4245b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi            _env, _array, (jboolean *) 0);
4257ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        params = (CTYPE *) (_paramsBase + _bufferOffset);
4267ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
4277ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GET(
4287ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLenum)pname,
4297ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (CTYPE *)params
4307ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    );
4317ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
4327ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallexit:
4337ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (_array) {
4345b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        releaseArrayPointer<JTYPEARRAY, NTYPEARRAY, ARRAYRELEASER>(
4355b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi            _env, _array, (NTYPEARRAY)params, _exception ? JNI_FALSE : JNI_TRUE);
4367ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
4377ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (_exception) {
4387ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        jniThrowException(_env, _exceptionType, _exceptionMessage);
4397ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
4407ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
4417ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
4427ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall// --------------------------------------------------------------------------
4437ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* void glDispatchCompute ( GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z ) */
4447ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void
4457ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallandroid_glDispatchCompute__III
4467ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall  (JNIEnv *_env, jobject _this, jint num_groups_x, jint num_groups_y, jint num_groups_z) {
4477ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    glDispatchCompute(
4487ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLuint)num_groups_x,
4497ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLuint)num_groups_y,
4507ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLuint)num_groups_z
4517ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    );
4527ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
4537ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
4547ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* void glDispatchComputeIndirect ( GLintptr indirect ) */
4557ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void android_glDispatchComputeIndirect(JNIEnv *_env, jobject, jlong indirect) {
4567ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    // 'indirect' is a byte offset, not a pointer. GL checks for negative and too-large values.
4577ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    // Here we only need to check for successful 64-bit to 32-bit conversion.
4587ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    // - jlong is a int64_t (jni.h)
4597ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    // - GLintptr is a long (khrplatform.h)
4607ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (sizeof(GLintptr) != sizeof(jlong) && (indirect < LONG_MIN || indirect > LONG_MAX)) {
4617ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        jniThrowException(_env, "java/lang/IllegalArgumentException", "indirect offset too large");
4627ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        return;
4637ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
4647ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    glDispatchComputeIndirect((GLintptr)indirect);
4657ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
4667ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
4677ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* void glDrawArraysIndirect ( GLenum mode, const void *indirect ) */
4687ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void android_glDrawArraysIndirect(JNIEnv *_env, jobject, int mode, jlong indirect) {
4697ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    // In OpenGL ES, 'indirect' is a byte offset into a buffer, not a raw pointer.
4707ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    // GL checks for too-large values. Here we only need to check for successful signed 64-bit
4717ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    // to unsigned 32-bit conversion.
472bfe6333c3cf529600f41f14e3b8c5846e632c9a2Andreas Gampe    if (sizeof(void*) != sizeof(jlong) && indirect > static_cast<jlong>(UINT32_MAX)) {
4737ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        jniThrowException(_env, "java/lang/IllegalArgumentException", "indirect offset too large");
4747ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        return;
4757ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
4767ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    glDrawArraysIndirect(mode, (const void*)indirect);
4777ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
4787ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
4797ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* void glDrawElementsIndirect ( GLenum mode, GLenum type, const void *indirect ) */
4807ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void android_glDrawElementsIndirect(JNIEnv *_env, jobject, jint mode, jint type, jlong indirect) {
4817ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    // In OpenGL ES, 'indirect' is a byte offset into a buffer, not a raw pointer.
4827ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    // GL checks for too-large values. Here we only need to check for successful signed 64-bit
4837ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    // to unsigned 32-bit conversion.
484bfe6333c3cf529600f41f14e3b8c5846e632c9a2Andreas Gampe    if (sizeof(void*) != sizeof(jlong) && indirect > static_cast<jlong>(UINT32_MAX)) {
4857ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        jniThrowException(_env, "java/lang/IllegalArgumentException", "indirect offset too large");
4867ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        return;
4877ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
4887ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    glDrawElementsIndirect(mode, type, (const void*)indirect);
4897ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
4907ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
4917ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* void glFramebufferParameteri ( GLenum target, GLenum pname, GLint param ) */
4927ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void
4937ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallandroid_glFramebufferParameteri__III
4947ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall  (JNIEnv *_env, jobject _this, jint target, jint pname, jint param) {
4957ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    glFramebufferParameteri(
4967ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLenum)target,
4977ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLenum)pname,
4987ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLint)param
4997ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    );
5007ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
5017ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
5027ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* void glGetFramebufferParameteriv ( GLenum target, GLenum pname, GLint *params ) */
5037ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void
5047ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallandroid_glGetFramebufferParameteriv__II_3II
5057ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall  (JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
5067ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _exception = 0;
5077ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    const char * _exceptionType = NULL;
5087ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    const char * _exceptionMessage = NULL;
5097ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLint *params_base = (GLint *) 0;
5107ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _remaining;
5117ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLint *params = (GLint *) 0;
5127ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
5137ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (!params_ref) {
5147ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exception = 1;
5157ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionType = "java/lang/IllegalArgumentException";
5167ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionMessage = "params == null";
5177ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        goto exit;
5187ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
5197ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (offset < 0) {
5207ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exception = 1;
5217ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionType = "java/lang/IllegalArgumentException";
5227ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionMessage = "offset < 0";
5237ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        goto exit;
5247ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
5257ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    _remaining = _env->GetArrayLength(params_ref) - offset;
5267ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    params_base = (GLint *)
5275b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->GetIntArrayElements(params_ref, (jboolean *)0);
5287ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    params = params_base + offset;
5297ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
5307ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    glGetFramebufferParameteriv(
5317ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLenum)target,
5327ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLenum)pname,
5337ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLint *)params
5347ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    );
5357ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
5367ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallexit:
5377ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (params_base) {
5385b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->ReleaseIntArrayElements(params_ref, (jint*)params_base,
5397ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            _exception ? JNI_ABORT: 0);
5407ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
5417ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (_exception) {
5427ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        jniThrowException(_env, _exceptionType, _exceptionMessage);
5437ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
5447ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
5457ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
5467ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* void glGetFramebufferParameteriv ( GLenum target, GLenum pname, GLint *params ) */
5477ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void
5487ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallandroid_glGetFramebufferParameteriv__IILjava_nio_IntBuffer_2
5497ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall  (JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
5505b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    jintArray _array = (jintArray) 0;
5517ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _bufferOffset = (jint) 0;
5527ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _remaining;
5537ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLint *params = (GLint *) 0;
5547ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
5555b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    params = (GLint *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
5567ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (params == NULL) {
5575b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        char * _paramsBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
5587ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        params = (GLint *) (_paramsBase + _bufferOffset);
5597ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
5607ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    glGetFramebufferParameteriv(
5617ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLenum)target,
5627ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLenum)pname,
5637ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLint *)params
5647ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    );
5657ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (_array) {
5665b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->ReleaseIntArrayElements(_array, (jint*)params, 0);
5677ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
5687ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
5697ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
5707ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* void glGetProgramInterfaceiv ( GLuint program, GLenum programInterface, GLenum pname, GLint *params ) */
5717ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void
5727ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallandroid_glGetProgramInterfaceiv__III_3II
5737ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall  (JNIEnv *_env, jobject _this, jint program, jint programInterface, jint pname, jintArray params_ref, jint offset) {
5747ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _exception = 0;
5757ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    const char * _exceptionType = NULL;
5767ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    const char * _exceptionMessage = NULL;
5777ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLint *params_base = (GLint *) 0;
5787ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _remaining;
5797ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLint *params = (GLint *) 0;
5807ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
5817ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (!params_ref) {
5827ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exception = 1;
5837ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionType = "java/lang/IllegalArgumentException";
5847ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionMessage = "params == null";
5857ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        goto exit;
5867ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
5877ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (offset < 0) {
5887ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exception = 1;
5897ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionType = "java/lang/IllegalArgumentException";
5907ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionMessage = "offset < 0";
5917ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        goto exit;
5927ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
5937ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    _remaining = _env->GetArrayLength(params_ref) - offset;
5947ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    params_base = (GLint *)
5955b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->GetIntArrayElements(params_ref, (jboolean *)0);
5967ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    params = params_base + offset;
5977ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
5987ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    glGetProgramInterfaceiv(
5997ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLuint)program,
6007ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLenum)programInterface,
6017ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLenum)pname,
6027ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLint *)params
6037ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    );
6047ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
6057ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallexit:
6067ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (params_base) {
6075b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->ReleaseIntArrayElements(params_ref, (jint*)params_base,
6087ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            _exception ? JNI_ABORT: 0);
6097ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
6107ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (_exception) {
6117ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        jniThrowException(_env, _exceptionType, _exceptionMessage);
6127ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
6137ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
6147ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
6157ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* void glGetProgramInterfaceiv ( GLuint program, GLenum programInterface, GLenum pname, GLint *params ) */
6167ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void
6177ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallandroid_glGetProgramInterfaceiv__IIILjava_nio_IntBuffer_2
6187ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall  (JNIEnv *_env, jobject _this, jint program, jint programInterface, jint pname, jobject params_buf) {
6195b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    jintArray _array = (jintArray) 0;
6207ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _bufferOffset = (jint) 0;
6217ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _remaining;
6227ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLint *params = (GLint *) 0;
6237ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
6245b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    params = (GLint *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
6257ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (params == NULL) {
6265b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        char * _paramsBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
6277ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        params = (GLint *) (_paramsBase + _bufferOffset);
6287ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
6297ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    glGetProgramInterfaceiv(
6307ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLuint)program,
6317ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLenum)programInterface,
6327ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLenum)pname,
6337ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLint *)params
6347ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    );
6357ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (_array) {
6365b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->ReleaseIntArrayElements(_array, (jint*)params, 0);
6377ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
6387ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
6397ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
6407ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* GLuint glGetProgramResourceIndex ( GLuint program, GLenum programInterface, const GLchar *name ) */
6417ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic jint
6427ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallandroid_glGetProgramResourceIndex__IILjava_lang_String_2
6437ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall  (JNIEnv *_env, jobject _this, jint program, jint programInterface, jstring name) {
6447ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _exception = 0;
6457ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    const char * _exceptionType = NULL;
6467ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    const char * _exceptionMessage = NULL;
6477ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLuint _returnValue = 0;
6487ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    const char* _nativename = 0;
6497ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
6507ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (!name) {
6517ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exception = 1;
6527ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionType = "java/lang/IllegalArgumentException";
6537ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionMessage = "name == null";
6547ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        goto exit;
6557ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
6567ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    _nativename = _env->GetStringUTFChars(name, 0);
6577ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
6587ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    _returnValue = glGetProgramResourceIndex(
6597ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLuint)program,
6607ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLenum)programInterface,
6617ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLchar *)_nativename
6627ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    );
6637ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
6647ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallexit:
6657ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (_nativename) {
6667ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _env->ReleaseStringUTFChars(name, _nativename);
6677ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
6687ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
6697ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (_exception) {
6707ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        jniThrowException(_env, _exceptionType, _exceptionMessage);
6717ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
6727ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    return (jint)_returnValue;
6737ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
6747ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
6757ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* void glGetProgramResourceName ( GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name ) */
6767ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic jstring
6777ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallandroid_glGetProgramResourceName
6787ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall  (JNIEnv *_env, jobject _this, jint program, jint programInterface, jint index) {
6797ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jniThrowException(_env, "java/lang/UnsupportedOperationException", "not yet implemented");
6807ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    return NULL;
6817ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
6827ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
6837ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* void glGetProgramResourceiv ( GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params ) */
6847ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void
6857ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallandroid_glGetProgramResourceiv__IIII_3III_3II_3II
6867ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall  (JNIEnv *_env, jobject _this, jint program, jint programInterface, jint index, jint propCount, jintArray props_ref, jint propsOffset, jint bufSize, jintArray length_ref, jint lengthOffset, jintArray params_ref, jint paramsOffset) {
6877ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _exception = 0;
6887ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    const char * _exceptionType = NULL;
6897ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    const char * _exceptionMessage = NULL;
6907ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLenum *props_base = (GLenum *) 0;
6917ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _propsRemaining;
6927ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLenum *props = (GLenum *) 0;
6937ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLsizei *length_base = (GLsizei *) 0;
6947ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _lengthRemaining;
6957ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLsizei *length = (GLsizei *) 0;
6967ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLint *params_base = (GLint *) 0;
6977ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _paramsRemaining;
6987ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLint *params = (GLint *) 0;
6997ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
7007ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (!props_ref) {
7017ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exception = 1;
7027ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionType = "java/lang/IllegalArgumentException";
7037ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionMessage = "props == null";
7047ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        goto exit;
7057ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
7067ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (propsOffset < 0) {
7077ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exception = 1;
7087ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionType = "java/lang/IllegalArgumentException";
7097ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionMessage = "propsOffset < 0";
7107ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        goto exit;
7117ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
7127ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    _propsRemaining = _env->GetArrayLength(props_ref) - propsOffset;
7137ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    props_base = (GLenum *)
7145b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->GetIntArrayElements(props_ref, (jboolean *)0);
7157ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    props = props_base + propsOffset;
7167ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
7177ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (!length_ref) {
7187ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exception = 1;
7197ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionType = "java/lang/IllegalArgumentException";
7207ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionMessage = "length == null";
7217ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        goto exit;
7227ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
7237ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (lengthOffset < 0) {
7247ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exception = 1;
7257ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionType = "java/lang/IllegalArgumentException";
7267ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionMessage = "lengthOffset < 0";
7277ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        goto exit;
7287ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
7297ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    _lengthRemaining = _env->GetArrayLength(length_ref) - lengthOffset;
7307ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    length_base = (GLsizei *)
7315b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->GetIntArrayElements(length_ref, (jboolean *)0);
7327ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    length = length_base + lengthOffset;
7337ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
7347ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (!params_ref) {
7357ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exception = 1;
7367ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionType = "java/lang/IllegalArgumentException";
7377ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionMessage = "params == null";
7387ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        goto exit;
7397ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
7407ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (paramsOffset < 0) {
7417ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exception = 1;
7427ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionType = "java/lang/IllegalArgumentException";
7437ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionMessage = "paramsOffset < 0";
7447ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        goto exit;
7457ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
7467ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    _paramsRemaining = _env->GetArrayLength(params_ref) - paramsOffset;
7477ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    params_base = (GLint *)
7485b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->GetIntArrayElements(params_ref, (jboolean *)0);
7497ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    params = params_base + paramsOffset;
7507ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
7517ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    glGetProgramResourceiv(
7527ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLuint)program,
7537ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLenum)programInterface,
7547ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLuint)index,
7557ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLsizei)propCount,
7567ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLenum *)props,
7577ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLsizei)bufSize,
7587ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLsizei *)length,
7597ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLint *)params
7607ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    );
7617ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
7627ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallexit:
7637ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (params_base) {
7645b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->ReleaseIntArrayElements(params_ref, (jint*)params_base,
7657ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            _exception ? JNI_ABORT: 0);
7667ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
7677ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (length_base) {
7685b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->ReleaseIntArrayElements(length_ref, (jint*)length_base,
7697ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            _exception ? JNI_ABORT: 0);
7707ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
7717ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (props_base) {
7725b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->ReleaseIntArrayElements(props_ref, (jint*)props_base,
7737ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            JNI_ABORT);
7747ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
7757ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (_exception) {
7767ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        jniThrowException(_env, _exceptionType, _exceptionMessage);
7777ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
7787ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
7797ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
7807ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* void glGetProgramResourceiv ( GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params ) */
7817ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void
7827ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallandroid_glGetProgramResourceiv__IIIILjava_nio_IntBuffer_2ILjava_nio_IntBuffer_2Ljava_nio_IntBuffer_2
7837ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall  (JNIEnv *_env, jobject _this, jint program, jint programInterface, jint index, jint propCount, jobject props_buf, jint bufSize, jobject length_buf, jobject params_buf) {
7845b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    jintArray _propsArray = (jintArray) 0;
7857ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _propsBufferOffset = (jint) 0;
7865b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    jintArray _lengthArray = (jintArray) 0;
7877ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _lengthBufferOffset = (jint) 0;
7885b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    jintArray _paramsArray = (jintArray) 0;
7897ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _paramsBufferOffset = (jint) 0;
7907ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _propsRemaining;
7917ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLenum *props = (GLenum *) 0;
7927ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _lengthRemaining;
7937ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLsizei *length = (GLsizei *) 0;
7947ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _paramsRemaining;
7957ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLint *params = (GLint *) 0;
7967ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
7975b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    props = (GLenum *)getPointer(_env, props_buf, (jarray*)&_propsArray, &_propsRemaining, &_propsBufferOffset);
7985b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    length = (GLsizei *)getPointer(_env, length_buf, (jarray*)&_lengthArray, &_lengthRemaining, &_lengthBufferOffset);
7995b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    params = (GLint *)getPointer(_env, params_buf, (jarray*)&_paramsArray, &_paramsRemaining, &_paramsBufferOffset);
8007ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (props == NULL) {
8015b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        char * _propsBase = (char *)_env->GetIntArrayElements(_propsArray, (jboolean *) 0);
8027ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        props = (GLenum *) (_propsBase + _propsBufferOffset);
8037ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
8047ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (length == NULL) {
8055b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        char * _lengthBase = (char *)_env->GetIntArrayElements(_lengthArray, (jboolean *) 0);
8067ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        length = (GLsizei *) (_lengthBase + _lengthBufferOffset);
8077ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
8087ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (params == NULL) {
8095b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        char * _paramsBase = (char *)_env->GetIntArrayElements(_paramsArray, (jboolean *) 0);
8107ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        params = (GLint *) (_paramsBase + _paramsBufferOffset);
8117ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
8127ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    glGetProgramResourceiv(
8137ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLuint)program,
8147ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLenum)programInterface,
8157ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLuint)index,
8167ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLsizei)propCount,
8177ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLenum *)props,
8187ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLsizei)bufSize,
8197ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLsizei *)length,
8207ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLint *)params
8217ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    );
8227ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (_paramsArray) {
8235b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->ReleaseIntArrayElements(_paramsArray, (jint*)params, 0);
8247ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
8257ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (_lengthArray) {
8265b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->ReleaseIntArrayElements(_lengthArray, (jint*)length, 0);
8277ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
8287ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (_propsArray) {
8295b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->ReleaseIntArrayElements(_propsArray, (jint*)props, JNI_ABORT);
8307ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
8317ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
8327ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
8337ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* GLint glGetProgramResourceLocation ( GLuint program, GLenum programInterface, const GLchar *name ) */
8347ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic jint
8357ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallandroid_glGetProgramResourceLocation__IILjava_lang_String_2
8367ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall  (JNIEnv *_env, jobject _this, jint program, jint programInterface, jstring name) {
8377ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _exception = 0;
8387ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    const char * _exceptionType = NULL;
8397ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    const char * _exceptionMessage = NULL;
8407ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLint _returnValue = 0;
8417ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    const char* _nativename = 0;
8427ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
8437ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (!name) {
8447ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exception = 1;
8457ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionType = "java/lang/IllegalArgumentException";
8467ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionMessage = "name == null";
8477ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        goto exit;
8487ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
8497ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    _nativename = _env->GetStringUTFChars(name, 0);
8507ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
8517ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    _returnValue = glGetProgramResourceLocation(
8527ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLuint)program,
8537ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLenum)programInterface,
8547ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLchar *)_nativename
8557ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    );
8567ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
8577ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallexit:
8587ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (_nativename) {
8597ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _env->ReleaseStringUTFChars(name, _nativename);
8607ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
8617ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
8627ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (_exception) {
8637ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        jniThrowException(_env, _exceptionType, _exceptionMessage);
8647ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
8657ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    return (jint)_returnValue;
8667ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
8677ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
8687ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* void glUseProgramStages ( GLuint pipeline, GLbitfield stages, GLuint program ) */
8697ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void
8707ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallandroid_glUseProgramStages__III
8717ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall  (JNIEnv *_env, jobject _this, jint pipeline, jint stages, jint program) {
8727ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    glUseProgramStages(
8737ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLuint)pipeline,
8747ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLbitfield)stages,
8757ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLuint)program
8767ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    );
8777ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
8787ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
8797ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* void glActiveShaderProgram ( GLuint pipeline, GLuint program ) */
8807ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void
8817ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallandroid_glActiveShaderProgram__II
8827ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall  (JNIEnv *_env, jobject _this, jint pipeline, jint program) {
8837ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    glActiveShaderProgram(
8847ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLuint)pipeline,
8857ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLuint)program
8867ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    );
8877ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
8887ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
8897ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* GLuint glCreateShaderProgramv ( GLenum type, GLsizei count, const GLchar *const *strings ) */
8907ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic jint
8917ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallandroid_glCreateShaderProgramv
8927ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall  (JNIEnv *_env, jobject _this, jint type, jobjectArray strings) {
8937ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
8947ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jniThrowException(_env, "java/lang/UnsupportedOperationException", "not yet implemented");
8957ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    return 0;
8967ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
8977ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* void glBindProgramPipeline ( GLuint pipeline ) */
8987ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void
8997ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallandroid_glBindProgramPipeline__I
9007ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall  (JNIEnv *_env, jobject _this, jint pipeline) {
9017ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    glBindProgramPipeline(
9027ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLuint)pipeline
9037ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    );
9047ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
9057ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
9067ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* void glDeleteProgramPipelines ( GLsizei n, const GLuint *pipelines ) */
9077ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void
9087ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallandroid_glDeleteProgramPipelines__I_3II
9097ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall  (JNIEnv *_env, jobject _this, jint n, jintArray pipelines_ref, jint offset) {
9107ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _exception = 0;
9117ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    const char * _exceptionType = NULL;
9127ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    const char * _exceptionMessage = NULL;
9137ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLuint *pipelines_base = (GLuint *) 0;
9147ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _remaining;
9157ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLuint *pipelines = (GLuint *) 0;
9167ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
9177ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (!pipelines_ref) {
9187ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exception = 1;
9197ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionType = "java/lang/IllegalArgumentException";
9207ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionMessage = "pipelines == null";
9217ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        goto exit;
9227ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
9237ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (offset < 0) {
9247ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exception = 1;
9257ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionType = "java/lang/IllegalArgumentException";
9267ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionMessage = "offset < 0";
9277ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        goto exit;
9287ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
9297ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    _remaining = _env->GetArrayLength(pipelines_ref) - offset;
9307ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    pipelines_base = (GLuint *)
9315b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->GetIntArrayElements(pipelines_ref, (jboolean *)0);
9327ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    pipelines = pipelines_base + offset;
9337ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
9347ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    glDeleteProgramPipelines(
9357ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLsizei)n,
9367ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLuint *)pipelines
9377ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    );
9387ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
9397ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallexit:
9407ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (pipelines_base) {
9415b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->ReleaseIntArrayElements(pipelines_ref, (jint*)pipelines_base,
9427ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            JNI_ABORT);
9437ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
9447ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (_exception) {
9457ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        jniThrowException(_env, _exceptionType, _exceptionMessage);
9467ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
9477ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
9487ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
9497ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* void glDeleteProgramPipelines ( GLsizei n, const GLuint *pipelines ) */
9507ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void
9517ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallandroid_glDeleteProgramPipelines__ILjava_nio_IntBuffer_2
9527ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall  (JNIEnv *_env, jobject _this, jint n, jobject pipelines_buf) {
9535b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    jintArray _array = (jintArray) 0;
9547ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _bufferOffset = (jint) 0;
9557ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _remaining;
9567ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLuint *pipelines = (GLuint *) 0;
9577ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
9585b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    pipelines = (GLuint *)getPointer(_env, pipelines_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
9597ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (pipelines == NULL) {
9605b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        char * _pipelinesBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
9617ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        pipelines = (GLuint *) (_pipelinesBase + _bufferOffset);
9627ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
9637ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    glDeleteProgramPipelines(
9647ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLsizei)n,
9657ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLuint *)pipelines
9667ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    );
9677ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (_array) {
9685b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->ReleaseIntArrayElements(_array, (jint*)pipelines, JNI_ABORT);
9697ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
9707ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
9717ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
9727ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* void glGenProgramPipelines ( GLsizei n, GLuint *pipelines ) */
9737ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void
9747ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallandroid_glGenProgramPipelines__I_3II
9757ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall  (JNIEnv *_env, jobject _this, jint n, jintArray pipelines_ref, jint offset) {
9767ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _exception = 0;
9777ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    const char * _exceptionType = NULL;
9787ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    const char * _exceptionMessage = NULL;
9797ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLuint *pipelines_base = (GLuint *) 0;
9807ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _remaining;
9817ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLuint *pipelines = (GLuint *) 0;
9827ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
9837ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (!pipelines_ref) {
9847ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exception = 1;
9857ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionType = "java/lang/IllegalArgumentException";
9867ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionMessage = "pipelines == null";
9877ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        goto exit;
9887ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
9897ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (offset < 0) {
9907ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exception = 1;
9917ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionType = "java/lang/IllegalArgumentException";
9927ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        _exceptionMessage = "offset < 0";
9937ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        goto exit;
9947ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
9957ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    _remaining = _env->GetArrayLength(pipelines_ref) - offset;
9967ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    pipelines_base = (GLuint *)
9975b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->GetIntArrayElements(pipelines_ref, (jboolean *)0);
9987ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    pipelines = pipelines_base + offset;
9997ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
10007ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    glGenProgramPipelines(
10017ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLsizei)n,
10027ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        (GLuint *)pipelines
10037ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    );
10047ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
10057ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallexit:
10067ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (pipelines_base) {
10075b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        _env->ReleaseIntArrayElements(pipelines_ref, (jint*)pipelines_base,
10087ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall            _exception ? JNI_ABORT: 0);
10097ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
10107ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (_exception) {
10117ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        jniThrowException(_env, _exceptionType, _exceptionMessage);
10127ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
10137ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall}
10147ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
10157ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall/* void glGenProgramPipelines ( GLsizei n, GLuint *pipelines ) */
10167ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallstatic void
10177ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hallandroid_glGenProgramPipelines__ILjava_nio_IntBuffer_2
10187ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall  (JNIEnv *_env, jobject _this, jint n, jobject pipelines_buf) {
10195b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    jintArray _array = (jintArray) 0;
10207ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _bufferOffset = (jint) 0;
10217ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    jint _remaining;
10227ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    GLuint *pipelines = (GLuint *) 0;
10237ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall
10245b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi    pipelines = (GLuint *)getPointer(_env, pipelines_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
10257ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    if (pipelines == NULL) {
10265b406cb7b548443b589f0acb235c8a7465ffb82bHiroshi Yamauchi        char * _pipelinesBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
10277ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall        pipelines = (GLuint *) (_pipelinesBase + _bufferOffset);
10287ab63acdd0a257272512d0bcf5e06036fa0b9fdfJesse Hall    }
1029