0

I have a working Opengl ES 1.0 Android program that includes blend function code that looks like this:

public void draw(GL10 gl) {

    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnable(GL10.GL_TEXTURE_2D);
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glEnable(GL10.GL_BLEND);
    gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    ...

However, this blend function does not quite meet my needs and I would like to replace the first parameter of glBlendFunc, the GL_SRC_ALPHA, with GL_SRC_COLOR. Unfortunately, this results in a GLException of "invalid enum." This would normally indicate that the parameter I am giving it is not a valid parameter for that object, but according to the OpenGL ES docs, this parameter is one of the accepted values for this function. Any idea why it might be generating this error?

2

but according to the OpenGL ES docs, this parameter is one of the accepted values for this function

No, it is not. From the GLES 1.1 spec:

The functions DST_COLOR, ONE_MINUS_DST_COLOR, and SRC_ALPHA_SATURATE are valid only for src, and the functions SRC_COLOR andONE_MINUS_SRC_COLOR are valid only for dst. All other functions are valid for either src or dst.

GLES 1.x is quite limited in this regard, but that is how things are.

|improve this answer|||||
  • Sure enough. I missed that in examining the documents. Thank you! – ike Jun 30 '14 at 21:02
  • Does anybody know what the motivation behind this was? I looked it up when I originally saw the question, and was very surprised when I found the restrictions that @derhass quotes. It seems very arbitrary. ES 1.1 is kind of historical by now, but I'm still curious... – Reto Koradi Jul 1 '14 at 2:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.