text.cacheAsBitmap = true throws error.

Aperta
#551 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
javascript
Ambito
backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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;
};
Lingua principale
JavaScript
Stelle
1.4k
Fork
485
Merge medio
1g 2h
PR unite (30g)
9

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di phaserjs/phaser-ce

Tutte le issue di phaserjs/phaser-ce

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.