To be able to experiment with various OpenGL Blending setups, I included the following code in my GLSurfaceView.Renderer
's onSurfaceCreated()
method, the whole project being set up for API level 8:
GLES20.glEnable(GLES20.GL_BLEND);
GLES20.glBlendFuncSeparate(GLES20.GL_SRC_ALPHA, [etc...]);
GLES20.glBlendEquationSeparate(GLES20.GL_FUNC_ADD, [etc...]);
All was going well on my AVD with host GPU support (besides my disappointment regarding the missing GL_MAX
, that is), but when I installed the app on two test devices, the app crashed on both, indicating that e.g. GLES20.glBlendFuncSeparate()
wasn't implemented.
A bit of try-and-error was required until I found that out of the following set:
glBlendFunc()
glBlendFuncSeparate()
glBlendEquation()
glBlendEquationSeparate()
both devices only support glBlendFunc()
.
From where I stand, it's now hard to tell what to rely on. I clearly hadn't expected that and did not find any information what is commonly implemented on the Web so far.
Can someone confirm that at least glBlendFunc()
is supported on all/most/... devices or point me to some detailed information?
Edit: Here's the logcat for GLES20.glBlendEquation(GLES20.GL_FUNC_ADD)
:
D/libEGL ( 4393): loaded /system/lib/egl/libGLES_android.so
D/libEGL ( 4393): loaded /system/lib/egl/libEGL_POWERVR_SGX530_125.so
D/libEGL ( 4393): loaded /system/lib/egl/libGLESv1_CM_POWERVR_SGX530_125.so
D/libEGL ( 4393): loaded /system/lib/egl/libGLESv2_POWERVR_SGX530_125.so
W/dalvikvm( 4393): threadid=8: thread exiting with uncaught exception (group=0x4001d8a8)
E/AndroidRuntime( 4393): FATAL EXCEPTION: GLThread 9
E/AndroidRuntime( 4393): java.lang.UnsupportedOperationException: glBlendEquation
E/AndroidRuntime( 4393): at android.opengl.GLES20.glBlendEquation(Native Method)
E/AndroidRuntime( 4393): at org.blah.test.TestApplication$OGLBackground.onSurfaceCreated(TestApplication.java:209)
E/AndroidRuntime( 4393): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1317)
E/AndroidRuntime( 4393): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)
W/ActivityManager( 1297): Force finishing activity org.blah.test/.MainActivity