We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
readPixels()
RGB
const width = 4; const height = 4; const gl = require('gl')(width, height, {preserveDrawingBuffer: true}); gl.clearColor(1, 0, 0, 1); gl.clear(gl.COLOR_BUFFER_BIT); const pixelsRgba = new Uint8Array(width * height * 4); gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, pixelsRgba); console.log(pixelsRgba); const pixelsRgb = new Uint8Array(width * height * 3); gl.readPixels(0, 0, width, height, gl.RGB, gl.UNSIGNED_BYTE, pixelsRgb); console.log(pixelsRgb);
Output:
Uint8Array(64) [ 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255 ] Uint8Array(48) [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
The RGBA output is correct, but the RGB output is incorrect.
The text was updated successfully, but these errors were encountered:
RGBA
No branches or pull requests
Output:
The RGBA output is correct, but the RGB output is incorrect.
The text was updated successfully, but these errors were encountered: