From 5eb750b25376344c5c44ffd6069b3835ff555bf6 Mon Sep 17 00:00:00 2001 From: Markuss Broks Date: Sat, 12 Oct 2024 15:11:20 +0300 Subject: [PATCH] GLImpl: more implementations --- src/api-impl-jni/android_opengl_GLES20.c | 50 +++++++++++ .../com_google_android_gles_jni_GLImpl.h | 84 +------------------ .../com/google/android/gles_jni/GLImpl.java | 68 ++++++++++----- 3 files changed, 100 insertions(+), 102 deletions(-) diff --git a/src/api-impl-jni/android_opengl_GLES20.c b/src/api-impl-jni/android_opengl_GLES20.c index 9d1ff87d..1f7b4d83 100644 --- a/src/api-impl-jni/android_opengl_GLES20.c +++ b/src/api-impl-jni/android_opengl_GLES20.c @@ -12,6 +12,11 @@ JNIEXPORT jstring JNICALL Java_android_opengl_GLES20_glGetString(JNIEnv *env, jc return _JSTRING(chars); } +JNIEXPORT jint JNICALL Java_android_opengl_GLES20_glGetError(JNIEnv *env, jclass) +{ + return (jint) glGetError(); +} + JNIEXPORT void JNICALL Java_android_opengl_GLES20_glGetIntegerv__I_3II(JNIEnv *env, jclass, jint pname, jintArray params_ref, jint offset) { jint *params = (*env)->GetIntArrayElements(env, params_ref, NULL); @@ -24,16 +29,37 @@ JNIEXPORT void JNICALL Java_android_opengl_GLES20_glEnableVertexAttribArray(JNIE glEnableVertexAttribArray((GLuint)index); } +JNIEXPORT void JNICALL Java_android_opengl_GLES20_glVertexAttribPointerBounds(JNIEnv *env, jclass, jint index, jint size, jint type, jboolean normalized, jint stride, jobject pointer, jint count) +{ + jarray array_ref; + jbyte *array; + GLvoid *pixels = get_nio_buffer(env, pointer, &array_ref, &array); + + glVertexAttribPointer(index, size, type, normalized, stride, pixels); + release_nio_buffer(env, array_ref, array); +} + + JNIEXPORT void JNICALL Java_android_opengl_GLES20_glDisable(JNIEnv *env, jclass, jint cap) { glDisable((GLenum)cap); } +JNIEXPORT void JNICALL Java_android_opengl_GLES20_glActiveTexture(JNIEnv *env, jclass, jint texture) +{ + glActiveTexture((GLenum)texture); +} + JNIEXPORT void JNICALL Java_android_opengl_GLES20_glEnable(JNIEnv *env, jclass, jint cap) { glEnable((GLenum)cap); } +JNIEXPORT void JNICALL Java_android_opengl_GLES20_glFrontFace(JNIEnv *env, jclass, jint mode) +{ + glEnable((GLenum)mode); +} + JNIEXPORT void JNICALL Java_android_opengl_GLES20_glViewport(JNIEnv *env, jclass, jint x, jint y, jint width, jint height) { glViewport((GLint)x, (GLint)y, (GLsizei)width, (GLsizei)height); @@ -201,6 +227,15 @@ JNIEXPORT void JNICALL Java_android_opengl_GLES20_glDeleteShader(JNIEnv *env, jc glDeleteShader((GLuint)shader); } +JNIEXPORT void JNICALL Java_android_opengl_GLES20_glDeleteTextures(JNIEnv *env, jclass, jint n, jintArray textures, jint offset) +{ + jint *tex = (*env)->GetIntArrayElements(env, textures, NULL); + + glDeleteTextures((GLsizei) n, (const GLuint*) tex + (4 * offset)); + + (*env)->ReleaseIntArrayElements(env, textures, tex, 0); +} + JNIEXPORT void JNICALL Java_android_opengl_GLES20_glUseProgram(JNIEnv *env, jclass, jint program) { glUseProgram((GLuint)program); @@ -223,11 +258,26 @@ JNIEXPORT void JNICALL Java_android_opengl_GLES20_glUniform1i(JNIEnv *env, jclas glUniform1i((GLint)location, (GLint)x); } +JNIEXPORT void JNICALL Java_android_opengl_GLES20_glUniform4f(JNIEnv *env, jclass, jint location, jfloat x, jfloat y, jfloat z, jfloat w) +{ + glUniform4f((GLint)location, (GLfloat)x, (GLfloat)y, (GLfloat)z, (GLfloat)w); +} + JNIEXPORT void JNICALL Java_android_opengl_GLES20_glDrawArrays(JNIEnv *env, jclass, jint mode, jint first, jint count) { glDrawArrays((GLenum)mode, (GLint)first, (GLsizei)count); } +JNIEXPORT void JNICALL Java_android_opengl_GLES20_glDrawElements(JNIEnv *env, jclass, jint mode, jint count, jint type, jobject indices) +{ + jarray array_ref; + jbyte *array; + GLvoid *data = get_nio_buffer(env, indices, &array_ref, &array); + + glDrawElements((GLenum)mode, (GLsizei)type, (GLenum)type, data); + release_nio_buffer(env, array_ref, array); +} + JNIEXPORT void JNICALL Java_android_opengl_GLES20_glClearColor(JNIEnv *env, jclass, jfloat red, jfloat green, jfloat blue, jfloat alpha) { glClearColor((GLclampf)red, (GLclampf)green, (GLclampf)blue, (GLclampf)alpha); 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 e3e1d244..a9ad4bd2 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 @@ -31,14 +31,6 @@ JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glAlphaFunc JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glAlphaFuncx (JNIEnv *, jobject, jint, jint); -/* - * Class: com_google_android_gles_jni_GLImpl - * Method: glBindTexture - * Signature: (II)V - */ -JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glBindTexture - (JNIEnv *, jobject, jint, jint); - /* * Class: com_google_android_gles_jni_GLImpl * Method: glBlendFunc @@ -159,22 +151,6 @@ JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glCopyTexSubImag JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glCullFace (JNIEnv *, jobject, jint); -/* - * Class: com_google_android_gles_jni_GLImpl - * Method: glDeleteTextures - * Signature: (I[II)V - */ -JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glDeleteTextures__I_3II - (JNIEnv *, jobject, jint, jintArray, jint); - -/* - * Class: com_google_android_gles_jni_GLImpl - * Method: glDeleteTextures - * Signature: (ILjava/nio/IntBuffer;)V - */ -JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glDeleteTextures__ILjava_nio_IntBuffer_2 - (JNIEnv *, jobject, jint, jobject); - /* * Class: com_google_android_gles_jni_GLImpl * Method: glDepthFunc @@ -207,14 +183,6 @@ JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glDepthRangef JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glDepthRangex (JNIEnv *, jobject, jint, jint); -/* - * Class: com_google_android_gles_jni_GLImpl - * Method: glDisable - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glDisable - (JNIEnv *, jobject, jint); - /* * Class: com_google_android_gles_jni_GLImpl * Method: glDisableClientState @@ -231,22 +199,6 @@ JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glDisableClientS JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glDrawArrays (JNIEnv *, jobject, jint, jint, jint); -/* - * Class: com_google_android_gles_jni_GLImpl - * Method: glDrawElements - * Signature: (IIILjava/nio/Buffer;)V - */ -JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glDrawElements__IIILjava_nio_Buffer_2 - (JNIEnv *, jobject, jint, jint, jint, jobject); - -/* - * Class: com_google_android_gles_jni_GLImpl - * Method: glEnable - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glEnable - (JNIEnv *, jobject, jint); - /* * Class: com_google_android_gles_jni_GLImpl * Method: glEnableClientState @@ -311,14 +263,6 @@ JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glFogxv__I_3II JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glFogxv__ILjava_nio_IntBuffer_2 (JNIEnv *, jobject, jint, jobject); -/* - * Class: com_google_android_gles_jni_GLImpl - * Method: glFrontFace - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glFrontFace - (JNIEnv *, jobject, jint); - /* * Class: com_google_android_gles_jni_GLImpl * Method: glFrustumf @@ -335,20 +279,12 @@ JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glFrustumf JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glFrustumx (JNIEnv *, jobject, jint, jint, jint, jint, jint, jint); -/* - * Class: com_google_android_gles_jni_GLImpl - * Method: glGenTextures - * Signature: (I[II)V - */ -JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glGenTextures__I_3II - (JNIEnv *, jobject, jint, jintArray, jint); - /* * Class: com_google_android_gles_jni_GLImpl * Method: glGenTextures * Signature: (ILjava/nio/IntBuffer;)V */ -JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glGenTextures__ILjava_nio_IntBuffer_2 +JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glGenTextures (JNIEnv *, jobject, jint, jobject); /* @@ -903,14 +839,6 @@ JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glTexEnvxv__IILj JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glTexImage2D (JNIEnv *, jobject, jint, jint, jint, jint, jint, jint, jint, jint, jobject); -/* - * Class: com_google_android_gles_jni_GLImpl - * Method: glTexParameterf - * Signature: (IIF)V - */ -JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glTexParameterf - (JNIEnv *, jobject, jint, jint, jfloat); - /* * Class: com_google_android_gles_jni_GLImpl * Method: glTexParameterx @@ -951,14 +879,6 @@ JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glTranslatex JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glVertexPointerBounds (JNIEnv *, jobject, jint, jint, jint, jobject, jint); -/* - * Class: com_google_android_gles_jni_GLImpl - * Method: glViewport - * Signature: (IIII)V - */ -JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glViewport - (JNIEnv *, jobject, jint, jint, jint, jint); - /* * Class: com_google_android_gles_jni_GLImpl * Method: glQueryMatrixxOES @@ -1068,7 +988,7 @@ JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glDeleteBuffers_ * Method: glDrawElements * Signature: (IIII)V */ -JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glDrawElements__IIII +JNIEXPORT void JNICALL Java_com_google_android_gles_1jni_GLImpl_glDrawElements (JNIEnv *, jobject, jint, jint, jint, jint); /* 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 dbe134e1..b3ccbfd7 100644 --- a/src/api-impl/com/google/android/gles_jni/GLImpl.java +++ b/src/api-impl/com/google/android/gles_jni/GLImpl.java @@ -106,9 +106,12 @@ public class GLImpl implements GL10, GL10Ext, GL11, GL11Ext, GL11ExtensionPack { // C function void glBindTexture ( GLenum target, GLuint texture ) - public native void glBindTexture( + public void glBindTexture( int target, - int texture); + int texture) + { + GLES10.glBindTexture(target, texture); + } // C function void glBlendFunc ( GLenum sfactor, GLenum dfactor ) @@ -270,16 +273,21 @@ public class GLImpl implements GL10, GL10Ext, GL11, GL11Ext, GL11ExtensionPack { // C function void glDeleteTextures ( GLsizei n, const GLuint *textures ) - public native void glDeleteTextures( + public void glDeleteTextures( int n, int[] textures, - int offset); + int offset) { + GLES10.glDeleteTextures(n, textures, offset); + } // C function void glDeleteTextures ( GLsizei n, const GLuint *textures ) - public native void glDeleteTextures( + public void glDeleteTextures( int n, - java.nio.IntBuffer textures); + java.nio.IntBuffer textures) + { + GLES10.glDeleteTextures(n, textures); + } // C function void glDepthFunc ( GLenum func ) @@ -305,8 +313,11 @@ public class GLImpl implements GL10, GL10Ext, GL11, GL11Ext, GL11ExtensionPack { // C function void glDisable ( GLenum cap ) - public native void glDisable( - int cap); + public void glDisable( + int cap) + { + GLES10.glDisable(cap); + } // C function void glDisableClientState ( GLenum array ) @@ -322,16 +333,22 @@ public class GLImpl implements GL10, GL10Ext, GL11, GL11Ext, GL11ExtensionPack { // C function void glDrawElements ( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices ) - public native void glDrawElements( + public void glDrawElements( int mode, int count, int type, - java.nio.Buffer indices); + java.nio.Buffer indices) + { + GLES10.glDrawElements(mode, count, type, indices); + } // C function void glEnable ( GLenum cap ) - public native void glEnable( - int cap); + public void glEnable( + int cap) + { + GLES10.glEnable(cap); + } // C function void glEnableClientState ( GLenum array ) @@ -388,8 +405,11 @@ public class GLImpl implements GL10, GL10Ext, GL11, GL11Ext, GL11ExtensionPack { // C function void glFrontFace ( GLenum mode ) - public native void glFrontFace( - int mode); + public void glFrontFace( + int mode) + { + GLES10.glFrontFace(mode); + } // C function void glFrustumf ( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar ) @@ -413,10 +433,13 @@ public class GLImpl implements GL10, GL10Ext, GL11, GL11Ext, GL11ExtensionPack { // C function void glGenTextures ( GLsizei n, GLuint *textures ) - public native void glGenTextures( + public void glGenTextures( int n, int[] textures, - int offset); + int offset) + { + GLES10.glGenTextures(n, textures, offset); + } // C function void glGenTextures ( GLsizei n, GLuint *textures ) @@ -948,10 +971,13 @@ public class GLImpl implements GL10, GL10Ext, GL11, GL11Ext, GL11ExtensionPack { // C function void glTexParameterf ( GLenum target, GLenum pname, GLfloat param ) - public native void glTexParameterf( + public void glTexParameterf( int target, int pname, - float param); + float param) + { + GLES10.glTexParameterf(target, pname, param); + } // C function void glTexParameterx ( GLenum target, GLenum pname, GLfixed param ) @@ -1021,11 +1047,13 @@ public class GLImpl implements GL10, GL10Ext, GL11, GL11Ext, GL11ExtensionPack { // C function void glViewport ( GLint x, GLint y, GLsizei width, GLsizei height ) - public native void glViewport( + public void glViewport( int x, int y, int width, - int height); + int height) { + GLES10.glViewport(x, y, width, height); + } // C function GLbitfield glQueryMatrixxOES ( GLfixed *mantissa, GLint *exponent )