I am trying to retrieve a color in OpenGL ES with glReadPixels. I set my objects' colors with float[], e.g. {0.0f,0.5f,0.2f,1.0f} How can I convert the glReadPixels value to the same float[], since it's unsigned byte?
Setting the color:
gl.glColor4f(color[0], color[1], color[2], color[3]);
Getting the color:
ByteBuffer buf = ByteBuffer.allocate(4);
buf.order(ByteOrder.nativeOrder());
gl.glReadPixels((int) mx, height - (int) my, 1, 1, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, buf);
byte result[] = buff.array();
I don't know if this has been asked/answered already, but I just haven't found a solution and I've been trying it for a good while.