-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
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
Update & optimize #3
Conversation
else { | ||
var pixels = new Uint8Array(w * h * 4) | ||
gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, pixels) | ||
pixels = new Float32Array(pixels).map(function(p) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Float32Array#map
doesn't work in Safari and probably some other older browsers. 😄
Nice work! I made a couple comments. The only weird thing for me is the API, which could be used in any of these ways:
I think it's better to keep a smaller API surface area even if it introduces an extra few keystrokes. This way any code using this library is forced to be consistent:
😄 |
module.exports = function (shader, opt) { | ||
if (!opt) { | ||
//just options | ||
if (typeof shader === 'object' && !shader.fragShader) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small thing here – I think it's best to reduce the peer dependency on fragShader
and gl-shader
and just assume a more generic interface that is basically { gl, bind() }
which is what we had before. 😄 But I think this part will go away if we keep the options simple as they were before.
@mattdesl ok, fixed all comments. |
Yeah I agree |
I can merge and fix the API to the new style though, and make a breaking change. Thanks for all this! |
Ok, great! I’ll then align nogl-shader-output then to comply with the new API. |
Merged & cleaned up code / docs in |
Hello @mattdesl!
This is the lightweight version of #2.
Changes:
var draw = create(glslify('./shader.frag'), opts?)
. It is compatible with old API.It is a major change, because float processing does not clamp values to 0..1 range now. In every other aspect it is minor change.
Looking forward for review.