I am working on a project that is in GLES 1.1. It has to be GLES 1.1.
But it has to do some premultiplication i.e. get every pixel, and change it from rgba = r*a,b*a,g*a,a. And then later reverse it.
If i had access to shaders it would be no problem but of course being gles 1.1 I don't.
Doing it via readpixels and then doing it on the CPU and putting it back is horribly slow so I trying to think of someway i can cheat.
Now one way I could do the premultiply is by taking advantage of glTexEnvi
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE0);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_TEXTURE1);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_ALPHA);
but then afterwards, i need to reverse the operation. For the life of me I can not think of a way to reverse it.
If everything had the same alpha i could abuse the glLighting functions but sadly they do not.
I get the feeling i am a little doomed.
Perhaps i could just use shared contexts and do a snippet of GLES 2.0...but I feel that will come with its own overhead
if anyone has any ideas or thoughts on this at all I would greatly appreciate hearing them!
Couldn't find an Answer myself or on here. It's been a while so for anyone wondering...
In the end I managed to convince the "powers-that-be" to let me convert the project to GLES 2.0. The process wasn't actually very painful (luckily) and it was very worth it.
The above operation was successfully offloaded to the GPU along with a few others and the performance was increased from 1fps to 60+...so well worth it :).
Its also worth noting that I a hybrid approach would have been well worth it if the re-write had not been an option