Skip to content
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

Enable support for gl.FLOAT #166

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
13 changes: 8 additions & 5 deletions seriously.js
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@
status,
useFloat = options === true ? options : (options && options.useFloat);

useFloat = false;//useFloat && !!gl.getExtension('OES_texture_float'); //useFloat is not ready!
useFloat = useFloat && !!gl.getExtension('OES_texture_float');
if (useFloat) {
this.type = gl.FLOAT;
} else {
Expand All @@ -797,8 +797,8 @@
this.texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, this.texture);
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
this.ownTexture = true;
Expand Down Expand Up @@ -878,8 +878,11 @@
gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer);
gl.bindRenderbuffer(gl.RENDERBUFFER, this.renderBuffer);

//todo: handle float
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
if(this.type === gl.FLOAT){
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.FLOAT, new Float32Array(width * height * 4));
}else{
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
}
gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0);

Expand Down