Add blob and fix some issues
This commit is contained in:
parent
5b4e67cbf0
commit
edca93fcfe
4 changed files with 237 additions and 67 deletions
|
|
@ -1,11 +1,22 @@
|
|||
import { FrameBuffer } from './frame-buffer';
|
||||
import { enableExtension } from '../helper/enable-extension';
|
||||
|
||||
export class IntermediateFrameBuffer extends FrameBuffer {
|
||||
private frameTexture: WebGLTexture;
|
||||
|
||||
private floatLinearEnabled = true;
|
||||
|
||||
constructor(gl: WebGL2RenderingContext) {
|
||||
super(gl);
|
||||
|
||||
enableExtension(gl, 'EXT_color_buffer_float');
|
||||
|
||||
try {
|
||||
enableExtension(gl, 'OES_texture_float_linear');
|
||||
} catch {
|
||||
this.floatLinearEnabled = false;
|
||||
}
|
||||
|
||||
this.frameTexture = this.gl.createTexture();
|
||||
this.configureTexture();
|
||||
|
||||
|
|
@ -27,12 +38,12 @@ export class IntermediateFrameBuffer extends FrameBuffer {
|
|||
this.gl.texImage2D(
|
||||
this.gl.TEXTURE_2D,
|
||||
0,
|
||||
this.gl.RGBA,
|
||||
this.gl.RG16F,
|
||||
this.size.x,
|
||||
this.size.y,
|
||||
0,
|
||||
this.gl.RGBA,
|
||||
this.gl.UNSIGNED_BYTE,
|
||||
this.gl.RG,
|
||||
this.gl.FLOAT,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
|
@ -42,12 +53,12 @@ export class IntermediateFrameBuffer extends FrameBuffer {
|
|||
this.gl.texParameteri(
|
||||
this.gl.TEXTURE_2D,
|
||||
this.gl.TEXTURE_MAG_FILTER,
|
||||
this.gl.LINEAR
|
||||
this.floatLinearEnabled ? this.gl.LINEAR : this.gl.NEAREST
|
||||
);
|
||||
this.gl.texParameteri(
|
||||
this.gl.TEXTURE_2D,
|
||||
this.gl.TEXTURE_MIN_FILTER,
|
||||
this.gl.LINEAR
|
||||
this.floatLinearEnabled ? this.gl.LINEAR : this.gl.NEAREST
|
||||
);
|
||||
this.gl.texParameteri(
|
||||
this.gl.TEXTURE_2D,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
export const enableExtension = (
|
||||
gl: WebGL2RenderingContext,
|
||||
name: string
|
||||
): any => {
|
||||
if (gl.getSupportedExtensions().indexOf(name) == -1) {
|
||||
throw new Error(`Unsupported extension ${name}`);
|
||||
}
|
||||
|
||||
return gl.getExtension(name);
|
||||
};
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import { InfoText } from '../../../objects/types/info-text';
|
||||
import { enableExtension } from './enable-extension';
|
||||
|
||||
// https://www.khronos.org/registry/webgl/extensions/EXT_disjoint_timer_query_webgl2/
|
||||
|
||||
|
|
@ -10,15 +11,8 @@ export class WebGlStopwatch {
|
|||
private resultsInNanoSeconds: number;
|
||||
|
||||
constructor(private gl: WebGL2RenderingContext) {
|
||||
if (
|
||||
this.gl
|
||||
.getSupportedExtensions()
|
||||
.indexOf('EXT_disjoint_timer_query_webgl2') == -1
|
||||
) {
|
||||
throw new Error('Unsupported extension');
|
||||
}
|
||||
|
||||
this.timerExtension = this.gl.getExtension(
|
||||
this.timerExtension = enableExtension(
|
||||
gl,
|
||||
'EXT_disjoint_timer_query_webgl2'
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ export class UniformArrayAutoScalingProgram implements IProgram {
|
|||
);
|
||||
|
||||
const closest = this.programs.find((p) =>
|
||||
p.values.every((v, i) => v > values[i])
|
||||
p.values.every((v, i) => v >= values[i])
|
||||
);
|
||||
|
||||
this.current = closest ? closest.program : last(this.programs).program;
|
||||
|
|
|
|||
Loading…
Reference in a new issue