text.cacheAsBitmap = true throws error.

Abierto
#551 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
javascript
Área
backend

Línea de trabajo

The report points to _CreateFramebuffer and PIXI.FilterTexture in the WebGL code but gives no file path or test. Start by locating those functions and tracing how framebuffer creation is called when Text.cacheAsBitmap is enabled. Confirm the reported renderBuffer error and verify the fix by exercising bitmap caching in the affected Phaser version.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug

This Issue is about (pick one, ✏️ delete others)

  • A bug in the API: Text.cacheAsBitmap
    • Phaser version(s): 2.10.6
    • What should happen: The text should be cached as bitmap
    • What happens instead: Uncaught TypeError: Cannot read property 'renderBuffer' of undefined

Error is in this piece of code -

The below function is not associated with a class so "this.renderBuffer" is not accessible. Possible fix is calling this function using call method and passing "this" as context.

function _CreateFramebuffer (gl, width, height, scaleMode, textureUnit)
{
    var framebuffer = gl.createFramebuffer();
    var depthStencilBuffer = gl.createRenderbuffer();
    var colorBuffer = null;
    var fbStatus = 0;
    gl.activeTexture(gl.TEXTURE0 + textureUnit);
    gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
    gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
    gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, this.renderBuffer);
    colorBuffer = _CreateEmptyTexture(gl, width, height, scaleMode);
    gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, colorBuffer, 0);
    fbStatus = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
    if(fbStatus !== gl.FRAMEBUFFER_COMPLETE)
    {
        console.error('Incomplete GL framebuffer. ', _fbErrors[fbStatus]);
    }
    framebuffer.width = width;
    framebuffer.height = height;
    framebuffer.targetTexture = colorBuffer;
    framebuffer.renderBuffer = depthStencilBuffer;
    return framebuffer;
}

PIXI.FilterTexture = function (gl, width, height, scaleMode, textureUnit)
{
    textureUnit = typeof textureUnit === 'number' ? textureUnit : 0;

    /**
     * @property gl
     * @type WebGLContext
     */
    this.gl = gl;

    // next time to create a frame buffer and texture

    /**
     * @property frameBuffer
     * @type Any
     */
//    this.frameBuffer = _CreateFramebuffer(gl, width, height, scaleMode || PIXI.scaleModes.DEFAULT, textureUnit);
// The below line fixes the error.
this.frameBuffer = _CreateFramebuffer.call (this, gl, width, height, scaleMode || PIXI.scaleModes.DEFAULT, textureUnit);
    /**
     * @property texture
     * @type Any
     */
    this.texture = this.frameBuffer.targetTexture;
    this.width = width;
    this.height = height;
    this.renderBuffer = this.frameBuffer.renderBuffer;
};
Lenguaje dominante
JavaScript
Estrellas
1.4k
Forks
485
Merge medio
1 d 2 h
PR fusionados (30 d)
9

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de phaserjs/phaser-ce

Todos los issues de phaserjs/phaser-ce

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.