PDA

View Full Version : ReadPixels from Framebuffer Object (fbo) => wrong Colors?



11&2
09-30-2010, 03:53 AM
Hi,

for selection Im using the color picking method, the rendering etc. is working fine but I get the wrong colors.



var back_colors = [
// Front face
224/255, 0.0, 0.0, 255/255,
224/255, 0.0, 0.0, 255/255,
224/255, 0.0, 0.0, 255/255,

222/255, 0.0, 0.0, 255/255,
222/255, 0.0, 0.0, 255/255,
222/255, 0.0, 0.0, 255/255,

222/255, 0.0, 0.0, 255/255,
222/255, 0.0, 0.0, 255/255,
222/255, 0.0, 0.0, 255/255,

222/255, 0.0, 0.0, 255/255,
222/255, 0.0, 0.0, 255/255,
222/255, 0.0, 0.0, 255/255
];
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(back_colors), gl.STATIC_DRAW);


So the reference page states regarding "glReadPixels" : "When type is GL_UNSIGNED_BYTE, each component is multiplied by 2^8 -1" (http://www.khronos.org/opengles/sdk/docs/man/).

So for the reading I coded:


var element_color = new Uint8Array(gl.viewportWidth * gl.viewportHeight * 4);
gl.readPixels(window_x, window_y, gl.viewportWidth, gl.viewportHeight, gl.RGBA, gl.UNSIGNED_BYTE, element_color);


So for Red I would expect a value of 224 or 222 but what I get is 221.

Whats going on?

Greetings S.

11&2
10-02-2010, 08:47 AM
The Problem lies within "Minefield", when I build with Webkit the error is gone and I get the expected colors.