you can drop the while cycle altogether, and rewrite the above for ES as:
#ifdef OPENGLES
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, cw, ch, 0, GL_RGBA, // apparently format is always GL_RGBA so no need to keep it in a...