Add palette system
This commit is contained in:
parent
f60ae06f59
commit
98d1fc9ca2
19 changed files with 196 additions and 113 deletions
|
|
@ -4,16 +4,16 @@ import { FrameBuffer } from './frame-buffer';
|
|||
|
||||
export class IntermediateFrameBuffer extends FrameBuffer {
|
||||
private frameTexture: WebGLTexture;
|
||||
private floatEnabled = false;
|
||||
private floatLinearEnabled = false;
|
||||
|
||||
constructor(gl: UniversalRenderingContext) {
|
||||
super(gl);
|
||||
|
||||
if (gl.isWebGL2) {
|
||||
enableExtension(gl, 'EXT_color_buffer_float');
|
||||
}
|
||||
|
||||
try {
|
||||
enableExtension(gl, 'EXT_color_buffer_float');
|
||||
this.floatEnabled = true;
|
||||
|
||||
enableExtension(gl, 'OES_texture_float_linear');
|
||||
this.floatLinearEnabled = true;
|
||||
} catch {
|
||||
|
|
@ -21,6 +21,8 @@ export class IntermediateFrameBuffer extends FrameBuffer {
|
|||
}
|
||||
|
||||
// can only return null on lost context
|
||||
gl.activeTexture(gl.TEXTURE0);
|
||||
|
||||
this.frameTexture = this.gl.createTexture()!;
|
||||
this.configureTexture();
|
||||
|
||||
|
|
@ -43,17 +45,17 @@ export class IntermediateFrameBuffer extends FrameBuffer {
|
|||
const hasChanged = super.setSize();
|
||||
|
||||
if (hasChanged) {
|
||||
this.gl.bindTexture(this.gl.TEXTURE_2D, this.frameTexture);
|
||||
this.bind();
|
||||
|
||||
this.gl.texImage2D(
|
||||
this.gl.TEXTURE_2D,
|
||||
0,
|
||||
this.gl.isWebGL2 ? this.gl.RG16F : this.gl.RGBA,
|
||||
this.floatEnabled ? this.gl.RG16F : this.gl.RGB,
|
||||
this.size.x,
|
||||
this.size.y,
|
||||
0,
|
||||
this.gl.isWebGL2 ? this.gl.RG : this.gl.RGBA,
|
||||
this.gl.isWebGL2 ? this.gl.FLOAT : this.gl.UNSIGNED_BYTE,
|
||||
this.floatEnabled ? this.gl.RG : this.gl.RGB,
|
||||
this.floatEnabled ? this.gl.FLOAT : this.gl.UNSIGNED_BYTE,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
|
@ -61,8 +63,14 @@ export class IntermediateFrameBuffer extends FrameBuffer {
|
|||
return hasChanged;
|
||||
}
|
||||
|
||||
private configureTexture() {
|
||||
private bind() {
|
||||
this.gl.activeTexture(this.gl.TEXTURE0);
|
||||
this.gl.bindTexture(this.gl.TEXTURE_2D, this.frameTexture);
|
||||
}
|
||||
|
||||
private configureTexture() {
|
||||
this.bind();
|
||||
|
||||
this.gl.texParameteri(
|
||||
this.gl.TEXTURE_2D,
|
||||
this.gl.TEXTURE_MAG_FILTER,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue