0

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
class stacker
  • 5,357
  • 2
  • 32
  • 65
  • Just to confirm, you *are* using OpenGL ES 2.0, right? The call is `setEGLContextClientVersion(2);`. – Delyan Apr 11 '13 at 07:25
  • @Delyan That's right. In my `Activity`'s `onCreate()`, where I create the `GLSurfaceView` and set my renderer, I also call `setEGLContextClientVersion(2);` (and even in the right order regarding the other calls, as far as I can tell). Also, I'm using shaders and programs and as far as I understand it, this wouldn't work if I hadn't set up 2.0? – class stacker Apr 11 '13 at 07:29
  • @Delyan Also, the exceptions were thrown on the devices even in cases where I called the unsupported method with a parameter which is supposed to be the default (like `glBlendEquation(GLES20.GL_FUNC_ADD)`) and, in the case of `glBlendFuncSeparate()`, when I specified the same functions twice. So I'd exclude the possibility that only some settings are unsupported. It looks like the methods are really not implemented (and that's what the exception says). – class stacker Apr 11 '13 at 07:38
  • I would be surprised if thats really true. I'm writing an app which also based on API Level 8, and which uses glBlendFunc(), glBlendEquation() and I tested it on 7 different devices and never had a problem. What devices are you testing on? – D-rk Apr 11 '13 at 07:50
  • @Dirk An Archos 70 internet tablet running a stock Android 2.2.1 and a HANNspree HannsPAD SN10T130/1653 running a Flashback/gTablet/cyanogenmod 3.0.1. -- What else could be the cause? Wrong initialization? – class stacker Apr 11 '13 at 07:57
  • @Dirk I have now validated the problem also with an off-the-shelf Android 2.3.6 device. – class stacker Apr 20 '13 at 08:18

0 Answers0