Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
contextChange()
{
const gl = this.renderer.gl;
if (settings.PREFER_ENV === ENV.WEBGL_LEGACY)
{
this.MAX_TEXTURES = 1;
}
else
{
// step 1: first check max textures the GPU can handle.
this.MAX_TEXTURES = Math.min(
gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS),
settings.SPRITE_MAX_TEXTURES);
// step 2: check the maximum number of if statements the shader can have too..
this.MAX_TEXTURES = checkMaxIfStatementsInShader(
this.MAX_TEXTURES, gl);
}
this._shader = this.shaderGenerator.generateShader(this.MAX_TEXTURES);
this.CONTEXT_UID = this.renderer.CONTEXT_UID;
this.current = this.unknownFramebuffer;
this.viewport = new Rectangle();
this.hasMRT = true;
this.writeDepthTexture = true;
this.disposeAll(true);
// webgl2
if (this.renderer.context.webGLVersion === 1)
{
// webgl 1!
let nativeDrawBuffersExtension = this.renderer.context.extensions.drawBuffers;
let nativeDepthTextureExtension = this.renderer.context.extensions.depthTexture;
if (settings.PREFER_ENV === ENV.WEBGL_LEGACY)
{
nativeDrawBuffersExtension = null;
nativeDepthTextureExtension = null;
}
if (nativeDrawBuffersExtension)
{
gl.drawBuffers = (activeTextures) =>
nativeDrawBuffersExtension.drawBuffersWEBGL(activeTextures);
}
else
{
this.hasMRT = false;
gl.drawBuffers = () =>
{
// empty
contextChange()
{
const gl = this.renderer.gl;
if (settings.PREFER_ENV === ENV.WEBGL_LEGACY)
{
this.MAX_TEXTURES = 1;
}
else
{
// step 1: first check max textures the GPU can handle.
this.MAX_TEXTURES = Math.min(gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS), settings.SPRITE_MAX_TEXTURES);
// step 2: check the maximum number of if statements the shader can have too..
this.MAX_TEXTURES = checkMaxIfStatementsInShader(this.MAX_TEXTURES, gl);
}
// generate generateMultiTextureProgram, may be a better move?
this.shader = generateMultiTextureShader(gl, this.MAX_TEXTURES);
// we use the second shader as the first one depending on your browser may omit aTextureId
contextChange()
{
this.disposeAll(true);
const gl = this.gl = this.renderer.gl;
const context = this.renderer.context;
this.CONTEXT_UID = this.renderer.CONTEXT_UID;
// webgl2
if (!gl.createVertexArray)
{
// webgl 1!
let nativeVaoExtension = this.renderer.context.extensions.vertexArrayObject;
if (settings.PREFER_ENV === ENV.WEBGL_LEGACY)
{
nativeVaoExtension = null;
}
if (nativeVaoExtension)
{
gl.createVertexArray = () =>
nativeVaoExtension.createVertexArrayOES();
gl.bindVertexArray = (vao) =>
nativeVaoExtension.bindVertexArrayOES(vao);
gl.deleteVertexArray = (vao) =>
nativeVaoExtension.deleteVertexArrayOES(vao);
}
else
contextChange()
{
const gl = this.renderer.gl;
if (settings.PREFER_ENV === ENV.WEBGL_LEGACY)
{
this.MAX_TEXTURES = 1;
}
else
{
// step 1: first check max textures the GPU can handle.
this.MAX_TEXTURES = Math.min(
gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS),
settings.SPRITE_MAX_TEXTURES);
// step 2: check the maximum number of if statements the shader can have too..
this.MAX_TEXTURES = checkMaxIfStatementsInShader(
this.MAX_TEXTURES, gl);
}
this._shader = this.shaderGenerator.generateShader(this.MAX_TEXTURES);