onContextChange()
    {
        const gl = this.renderer.gl;

        if (this.renderer.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 = checkMaxIfStatmentsInShader(this.MAX_TEXTURES, gl);
        }

        const shader = this.shader = generateMultiTextureShader(gl, this.MAX_TEXTURES);

        // create a couple of buffers
        this.indexBuffer = glCore.GLBuffer.createIndexBuffer(gl, this.indices, gl.STATIC_DRAW);

        // we use the second shader as the first one depending on your browser may omit aTextureId
        // as it is not used by the shader so is optimized out.

        this.renderer.bindVao(null);

        for (let i = 0; i < this.vaoMax; i++)
        {
            this.vertexBuffers[i] = glCore.GLBuffer.createVertexBuffer(gl, null, gl.STREAM_DRAW);

            /* eslint-disable max-len */

            // build the vao object that will render..
            this.vaos[i] = this.renderer.createVao()
                .addIndex(this.indexBuffer)
                .addAttribute(this.vertexBuffers[i], shader.attributes.aVertexPosition, gl.FLOAT, false, this.vertByteSize, 0)
                .addAttribute(this.vertexBuffers[i], shader.attributes.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4)
                .addAttribute(this.vertexBuffers[i], shader.attributes.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4);

            if (shader.attributes.aTextureId)
            {
                this.vaos[i].addAttribute(this.vertexBuffers[i], shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4);
            }

            /* eslint-enable max-len */
        }

        this.vao = this.vaos[0];
        this.currentBlendMode = 99999;

        this.boundTextures = new Array(this.MAX_TEXTURES);
    }
/**
     * Sets up the renderer context and necessary buffers.
     *
     * @private
     */
Sets up the renderer context and necessary buffers.
@private
Sets up the renderer context and necessary buffers . @private
onContextChange()
    {
        const gl = this.renderer.gl;
        if (this.renderer.legacy)
        {
            this.MAX_TEXTURES = 1;
        }
        else
        {
            this.MAX_TEXTURES = Math.min(gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS), settings.SPRITE_MAX_TEXTURES);
            this.MAX_TEXTURES = checkMaxIfStatmentsInShader(this.MAX_TEXTURES, gl);
        }
        const shader = this.shader = generateMultiTextureShader(gl, this.MAX_TEXTURES);
        this.indexBuffer = glCore.GLBuffer.createIndexBuffer(gl, this.indices, gl.STATIC_DRAW);
        this.renderer.bindVao(null);
        for (let i = 0; i < this.vaoMax; i++)
        {
            this.vertexBuffers[i] = glCore.GLBuffer.createVertexBuffer(gl, null, gl.STREAM_DRAW);
            this.vaos[i] = this.renderer.createVao()
                .addIndex(this.indexBuffer)
                .addAttribute(this.vertexBuffers[i], shader.attributes.aVertexPosition, gl.FLOAT, false, this.vertByteSize, 0)
                .addAttribute(this.vertexBuffers[i], shader.attributes.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4)
                .addAttribute(this.vertexBuffers[i], shader.attributes.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4);
            if (shader.attributes.aTextureId)
            {
                this.vaos[i].addAttribute(this.vertexBuffers[i], shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4);
            }
        }
        this.vao = this.vaos[0];
        this.currentBlendMode = 99999;
        this.boundTextures = new Array(this.MAX_TEXTURES);
    }
onContextChange ( ) { const gl = this . renderer . gl ; if ( this . renderer . legacy ) { this . MAX_TEXTURES = 1 ; } else { this . MAX_TEXTURES = Math . min ( gl . getParameter ( gl . MAX_TEXTURE_IMAGE_UNITS ) , settings . SPRITE_MAX_TEXTURES ) ; this . MAX_TEXTURES = checkMaxIfStatmentsInShader ( this . MAX_TEXTURES , gl ) ; } const shader = this . shader = generateMultiTextureShader ( gl , this . MAX_TEXTURES ) ; this . indexBuffer = glCore . GLBuffer . createIndexBuffer ( gl , this . indices , gl . STATIC_DRAW ) ; this . renderer . bindVao ( null ) ; for ( let i = 0 ; i < this . vaoMax ; i ++ ) { this . vertexBuffers [ i ] = glCore . GLBuffer . createVertexBuffer ( gl , null , gl . STREAM_DRAW ) ; this . vaos [ i ] = this . renderer . createVao ( ) . addIndex ( this . indexBuffer ) . addAttribute ( this . vertexBuffers [ i ] , shader . attributes . aVertexPosition , gl . FLOAT , false , this . vertByteSize , 0 ) . addAttribute ( this . vertexBuffers [ i ] , shader . attributes . aTextureCoord , gl . UNSIGNED_SHORT , true , this . vertByteSize , 2 * 4 ) . addAttribute ( this . vertexBuffers [ i ] , shader . attributes . aColor , gl . UNSIGNED_BYTE , true , this . vertByteSize , 3 * 4 ) ; if ( shader . attributes . aTextureId ) { this . vaos [ i ] . addAttribute ( this . vertexBuffers [ i ] , shader . attributes . aTextureId , gl . FLOAT , false , this . vertByteSize , 4 * 4 ) ; } } this . vao = this . vaos [ 0 ] ; this . currentBlendMode = 99999 ; this . boundTextures = new Array ( this . MAX_TEXTURES ) ; }
Sets up the renderer context and necessary buffers.
Sets up the renderer context and necessary buffers .
// step 1: first check max textures the GPU can handle. // step 2: check the maximum number of if statements the shader can have too.. // create a couple of buffers // we use the second shader as the first one depending on your browser may omit aTextureId // as it is not used by the shader so is optimized out. /* eslint-disable max-len */ // build the vao object that will render.. /* eslint-enable max-len */