Renderbuffer.js 1.4 KB

12345
  1. /*
  2. All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. See https://js.arcgis.com/4.24/esri/copyright.txt for details.
  4. */
  5. import{ContextType as e}from"./context-util.js";import{ResourceType as t}from"./enums.js";class r{constructor(r,s){this._context=r,this._desc=s,this.type="renderbuffer",this._context.instanceCounter.increment(t.Renderbuffer,this);const i=this._context.gl;this.glName=i.createRenderbuffer(),this._context.bindRenderbuffer(this);const{width:n,height:h,internalFormat:o,multisampled:a}=s;if(a){if(this._context.type!==e.WEBGL2)throw new Error("Multisampled renderbuffers are not supported in WebGL1!");i.renderbufferStorageMultisample(i.RENDERBUFFER,this.samples,o,n,h)}else i.renderbufferStorage(i.RENDERBUFFER,o,n,h)}get descriptor(){return this._desc}get samples(){const e=this._desc.samples,t=this._context.parameters.maxSamples;return e?Math.min(e,t):t}resize(e,t){const r=this._desc;if(r.width===e&&r.height===t)return;r.width=e,r.height=t;const s=this._context.gl;if(this._context.bindRenderbuffer(this),r.multisampled){s.renderbufferStorageMultisample(s.RENDERBUFFER,this.samples,r.internalFormat,r.width,r.height)}else s.renderbufferStorage(s.RENDERBUFFER,r.internalFormat,r.width,r.height)}dispose(){this._context&&(this._context.gl.deleteRenderbuffer(this.glName),this._context.instanceCounter.decrement(t.Renderbuffer,this),this._context=null)}}export{r as Renderbuffer};