First commit
This commit is contained in:
63
engine/renderPasses/template.js
Executable file
63
engine/renderPasses/template.js
Executable file
@@ -0,0 +1,63 @@
|
||||
import framebuffer from '../framebuffer.js';
|
||||
import sampler2D from '../sampler2D.js';
|
||||
import {math, vector3, matrix4} from '../math.js';
|
||||
import samplerCube from '../samplerCube.js';
|
||||
import shader from '../shader.js';
|
||||
|
||||
class template {
|
||||
|
||||
constructor( ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* set viewport
|
||||
* @param {(viewport)} viewport
|
||||
**/
|
||||
setViewport( viewport ){
|
||||
|
||||
this.viewport = viewport;
|
||||
this.gl = viewport.gl;
|
||||
|
||||
}
|
||||
|
||||
prepare() {
|
||||
|
||||
this.width = this.viewport.width;
|
||||
this.height = this.viewport.height;
|
||||
|
||||
this.targetSampler = new sampler2D( );
|
||||
this.targetSampler.type = this.gl.FLOAT;
|
||||
|
||||
this.framebuffer = new framebuffer( );
|
||||
this.framebuffer.setViewport( this.viewport );
|
||||
|
||||
this.framebuffer.width = this.width;
|
||||
this.framebuffer.height = this.height;
|
||||
|
||||
this.framebuffer.addSampler( this.targetSampler );
|
||||
this.framebuffer.create();
|
||||
|
||||
|
||||
this.shader = new shader();
|
||||
this.shader.createFromFile("shaders/template.shader");
|
||||
|
||||
this.shader.setUniform("viewProjection", this.viewport.quad.viewProjection );
|
||||
|
||||
}
|
||||
|
||||
|
||||
render() {
|
||||
|
||||
//this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, this.framebuffer.glFramebuffer);
|
||||
this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, null);
|
||||
|
||||
this.gl.clearColor( 0, 0, 0, 1 );
|
||||
this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);
|
||||
|
||||
this.viewport.quad.draw( this.shader );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export {template as default};
|
||||
Reference in New Issue
Block a user