class framebuffer{ constructor( ){ this.width = 1024; this.height = 1024; this._className = "_framebuffer"; this.glFramebuffer; this.framebuffers = []; this.renderbuffers = []; this.face = false; this.renderType = '2d'; this.samplers = []; // render to samplers //GL_DEPTH_ATTACHMENT this.multiSample = false; this.msaaFramebuffer; this.msaaColorRenderBuffer; this.msaaDepthRenderBuffer; this.MSAA_level = 4; } setViewport( viewport ){ this.viewport = viewport; this.gl = viewport.gl; this.target = this.gl.TEXTURE_2D; this.type = this.gl.FLOAT; this.attachment = this.gl.COLOR_ATTACHMENT0; } addSampler( sampler, face ) { sampler.setViewport( this.viewport ); this.samplers.push( sampler ); if( face ){ this.face = face; } } addCubeSampler( sampler ) { sampler.addTexture(new texture(), this.gl.TEXTURE_CUBE_MAP_POSITIVE_X); sampler.addTexture(new texture(), this.gl.TEXTURE_CUBE_MAP_NEGATIVE_X); sampler.addTexture(new texture(), this.gl.TEXTURE_CUBE_MAP_POSITIVE_Y); sampler.addTexture(new texture(), this.gl.TEXTURE_CUBE_MAP_NEGATIVE_Y); sampler.addTexture(new texture(), this.gl.TEXTURE_CUBE_MAP_POSITIVE_Z); sampler.addTexture(new texture(), this.gl.TEXTURE_CUBE_MAP_NEGATIVE_Z); this.samplers.push( sampler ); } getSampler( ) { return this.samplers[0]; } /** * Create framebuffer * @param {(int)} width * @param {(int)} height * @param {(object)} properties **/ create() { //type, depth //var WEBGL_draw_buffers = kepler.extensions.WEBGL_draw_buffers; var attachments = []; this.glFramebuffer = this.gl.createFramebuffer(); this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, this.glFramebuffer); this.renderbuffer = this.gl.createRenderbuffer(); this.gl.bindRenderbuffer(this.gl.RENDERBUFFER, this.renderbuffer); this.gl.renderbufferStorage(this.gl.RENDERBUFFER, this.gl.DEPTH_COMPONENT32F, this.width, this.height); this.gl.framebufferRenderbuffer(this.gl.FRAMEBUFFER, this.gl.DEPTH_ATTACHMENT, this.gl.RENDERBUFFER, this.renderbuffer); //} for(var c = 0; c 1) { //kepler.extensions.WEBGL_draw_buffers.drawBuffersWEBGL(attachments); this.gl.drawBuffers(attachments); } if (this.gl.checkFramebufferStatus(this.gl.FRAMEBUFFER) != this.gl.FRAMEBUFFER_COMPLETE) { alert("this combination of attachments does not work"); } //this.gl.bindFramebuffer(this.gl.TEXTURE_2D, null); this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, null); //this.gl.bindFramebuffer(this.gl.RENDERBUFFER, null); } } export {framebuffer as default};