First commit
This commit is contained in:
71
engine/defaultRenderPass.js
Executable file
71
engine/defaultRenderPass.js
Executable file
@@ -0,0 +1,71 @@
|
||||
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 defaultRenderPass {
|
||||
isDefault = true;
|
||||
realtime = true;
|
||||
updated = false;
|
||||
|
||||
constructor( ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* set viewport
|
||||
* @param {(viewport)} viewport
|
||||
**/
|
||||
setViewport( viewport ){
|
||||
|
||||
this.viewport = viewport;
|
||||
this.gl = viewport.gl;
|
||||
|
||||
}
|
||||
|
||||
prepareDefault() {
|
||||
|
||||
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() {
|
||||
|
||||
if(this.renderToViewport) {
|
||||
this.gl.bindFramebuffer( this.gl.FRAMEBUFFER, null );
|
||||
} else {
|
||||
this.gl.bindFramebuffer( this.gl.FRAMEBUFFER, this.framebuffer.glFramebuffer );
|
||||
}
|
||||
|
||||
|
||||
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 );
|
||||
|
||||
this.updated = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export {defaultRenderPass as default};
|
||||
Reference in New Issue
Block a user