2012-07-19 23:50:08 +00:00
|
|
|
/* void glGetShaderSource ( GLuint shader, GLsizei bufsize, GLsizei *length, char *source ) */
|
|
|
|
static void
|
|
|
|
android_glGetShaderSource__II_3II_3BI
|
|
|
|
(JNIEnv *_env, jobject _this, jint shader, jint bufsize, jintArray length_ref, jint lengthOffset, jbyteArray source_ref, jint sourceOffset) {
|
|
|
|
jint _exception = 0;
|
|
|
|
const char * _exceptionType;
|
|
|
|
const char * _exceptionMessage;
|
|
|
|
GLsizei *length_base = (GLsizei *) 0;
|
|
|
|
jint _lengthRemaining;
|
|
|
|
GLsizei *length = (GLsizei *) 0;
|
|
|
|
char *source_base = (char *) 0;
|
|
|
|
jint _sourceRemaining;
|
|
|
|
char *source = (char *) 0;
|
|
|
|
|
|
|
|
if (!length_ref) {
|
|
|
|
_exception = 1;
|
|
|
|
_exceptionType = "java/lang/IllegalArgumentException";
|
|
|
|
_exceptionMessage = "length == null";
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
if (lengthOffset < 0) {
|
|
|
|
_exception = 1;
|
|
|
|
_exceptionType = "java/lang/IllegalArgumentException";
|
|
|
|
_exceptionMessage = "lengthOffset < 0";
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
_lengthRemaining = _env->GetArrayLength(length_ref) - lengthOffset;
|
|
|
|
length_base = (GLsizei *)
|
2015-05-09 00:54:55 +00:00
|
|
|
_env->GetIntArrayElements(length_ref, (jboolean *)0);
|
2012-07-19 23:50:08 +00:00
|
|
|
length = length_base + lengthOffset;
|
|
|
|
|
|
|
|
if (!source_ref) {
|
|
|
|
_exception = 1;
|
|
|
|
_exceptionType = "java/lang/IllegalArgumentException";
|
|
|
|
_exceptionMessage = "source == null";
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
if (sourceOffset < 0) {
|
|
|
|
_exception = 1;
|
|
|
|
_exceptionType = "java/lang/IllegalArgumentException";
|
|
|
|
_exceptionMessage = "sourceOffset < 0";
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
_sourceRemaining = _env->GetArrayLength(source_ref) - sourceOffset;
|
|
|
|
source_base = (char *)
|
2015-05-09 00:54:55 +00:00
|
|
|
_env->GetByteArrayElements(source_ref, (jboolean *)0);
|
2012-07-19 23:50:08 +00:00
|
|
|
source = source_base + sourceOffset;
|
|
|
|
|
|
|
|
glGetShaderSource(
|
|
|
|
(GLuint)shader,
|
|
|
|
(GLsizei)bufsize,
|
|
|
|
(GLsizei *)length,
|
|
|
|
(char *)source
|
|
|
|
);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
if (source_base) {
|
2015-05-09 00:54:55 +00:00
|
|
|
_env->ReleaseByteArrayElements(source_ref, (jbyte*)source_base,
|
2012-07-19 23:50:08 +00:00
|
|
|
_exception ? JNI_ABORT: 0);
|
|
|
|
}
|
|
|
|
if (length_base) {
|
2015-05-09 00:54:55 +00:00
|
|
|
_env->ReleaseIntArrayElements(length_ref, (jint*)length_base,
|
2012-07-19 23:50:08 +00:00
|
|
|
_exception ? JNI_ABORT: 0);
|
|
|
|
}
|
|
|
|
if (_exception) {
|
|
|
|
jniThrowException(_env, _exceptionType, _exceptionMessage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* void glGetShaderSource ( GLuint shader, GLsizei bufsize, GLsizei *length, char *source ) */
|
|
|
|
static void
|
|
|
|
android_glGetShaderSource__IILjava_nio_IntBuffer_2B
|
|
|
|
(JNIEnv *_env, jobject _this, jint shader, jint bufsize, jobject length_buf, jbyte source) {
|
2015-05-09 00:54:55 +00:00
|
|
|
jintArray _array = (jintArray) 0;
|
2012-07-19 23:50:08 +00:00
|
|
|
jint _bufferOffset = (jint) 0;
|
|
|
|
jint _remaining;
|
|
|
|
GLsizei *length = (GLsizei *) 0;
|
|
|
|
|
2015-05-09 00:54:55 +00:00
|
|
|
length = (GLsizei *)getPointer(_env, length_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
|
2012-07-19 23:50:08 +00:00
|
|
|
if (length == NULL) {
|
2015-05-09 00:54:55 +00:00
|
|
|
char * _lengthBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
|
2012-07-19 23:50:08 +00:00
|
|
|
length = (GLsizei *) (_lengthBase + _bufferOffset);
|
|
|
|
}
|
|
|
|
glGetShaderSource(
|
|
|
|
(GLuint)shader,
|
|
|
|
(GLsizei)bufsize,
|
|
|
|
(GLsizei *)length,
|
2014-02-15 12:51:43 +00:00
|
|
|
reinterpret_cast<char *>(source)
|
2012-07-19 23:50:08 +00:00
|
|
|
);
|
|
|
|
if (_array) {
|
2015-05-09 00:54:55 +00:00
|
|
|
releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _array, (jint*)length, JNI_TRUE);
|
2012-07-19 23:50:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* void glGetShaderSource ( GLuint shader, GLsizei bufsize, GLsizei *length, char *source ) */
|
|
|
|
static jstring android_glGetShaderSource(JNIEnv *_env, jobject, jint shader) {
|
|
|
|
GLint shaderLen = 0;
|
|
|
|
glGetShaderiv((GLuint)shader, GL_SHADER_SOURCE_LENGTH, &shaderLen);
|
|
|
|
if (!shaderLen) {
|
|
|
|
return _env->NewStringUTF("");
|
|
|
|
}
|
|
|
|
char* buf = (char*) malloc(shaderLen);
|
|
|
|
if (buf == NULL) {
|
|
|
|
jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
glGetShaderSource(shader, shaderLen, NULL, buf);
|
|
|
|
jstring result = _env->NewStringUTF(buf);
|
|
|
|
free(buf);
|
|
|
|
return result;
|
|
|
|
}
|