From 26d6337a34257cadd75d8bc14027d938f97e03b5 Mon Sep 17 00:00:00 2001 From: Mis012 Date: Fri, 28 Jun 2024 21:35:13 +0200 Subject: [PATCH] api-impl: GLES20: add glReadPixels --- src/api-impl-jni/android_opengl_GLES20.c | 9 +++++++++ .../com_google_android_gles_jni_GLImpl.h | 8 -------- src/api-impl/com/google/android/gles_jni/GLImpl.java | 6 ++++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/api-impl-jni/android_opengl_GLES20.c b/src/api-impl-jni/android_opengl_GLES20.c index 9422173d..9d1ff87d 100644 --- a/src/api-impl-jni/android_opengl_GLES20.c +++ b/src/api-impl-jni/android_opengl_GLES20.c @@ -257,3 +257,12 @@ JNIEXPORT void JNICALL Java_android_opengl_GLES20_glFlush(JNIEnv *env, jclass th { glFlush(); } + +JNIEXPORT void JNICALL Java_android_opengl_GLES20_glReadPixels(JNIEnv *env, jclass this, jint x, jint y, jint width, jint height, jint format, jint type, jobject pixels_buf) +{ + jarray array_ref; + jbyte *array; + GLvoid *pixels = get_nio_buffer(env, pixels_buf, &array_ref, &array); + glReadPixels(x, y, width, height, format, type, pixels); + release_nio_buffer(env, array_ref, array); +} diff --git a/src/api-impl-jni/generated_headers/com_google_android_gles_jni_GLImpl.h b/src/api-impl-jni/generated_headers/com_google_android_gles_jni_GLImpl.h index acefdf7a..e3e1d244 100644 --- a/src/api-impl-jni/generated_headers/com_google_android_gles_jni_GLImpl.h +++ b/src/api-impl-jni/generated_headers/com_google_android_gles_jni_GLImpl.h @@ -751,14 +751,6 @@ JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glPopMatrix JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glPushMatrix (JNIEnv *, jobject); -/* - * Class: com_google_android_gles_jni_GLImpl - * Method: glReadPixels - * Signature: (IIIIIILjava/nio/Buffer;)V - */ -JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glReadPixels - (JNIEnv *, jobject, jint, jint, jint, jint, jint, jint, jobject); - /* * Class: com_google_android_gles_jni_GLImpl * Method: glRotatef diff --git a/src/api-impl/com/google/android/gles_jni/GLImpl.java b/src/api-impl/com/google/android/gles_jni/GLImpl.java index 2d770d02..dbe134e1 100644 --- a/src/api-impl/com/google/android/gles_jni/GLImpl.java +++ b/src/api-impl/com/google/android/gles_jni/GLImpl.java @@ -772,14 +772,16 @@ public class GLImpl implements GL10, GL10Ext, GL11, GL11Ext, GL11ExtensionPack { // C function void glReadPixels ( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels ) - public native void glReadPixels( + public void glReadPixels( int x, int y, int width, int height, int format, int type, - java.nio.Buffer pixels); + java.nio.Buffer pixels) { + GLES10.glReadPixels(x, y, width, height, format, type, pixels); + } // C function void glRotatef ( GLfloat angle, GLfloat x, GLfloat y, GLfloat z )