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