azerion / phaser-nineslice

NineSlice plugin for Phaser!
MIT License
53 stars 20 forks source link

Trying to add two instances of PhaserNineSlice.NineSlice causes a webGL error and doesn't show the second instance. #5

Open Barrelrolla opened 7 years ago

Barrelrolla commented 7 years ago

Trying to add two instances with a texture from the same atlas causes a WebGL error: [.Offscreen-For-WebGL-07472F00]GL ERROR :GL_INVALID_OPERATION : glDrawElements: Source and destination textures of the draw are the same. The result is that the second instance doesn't show up.

The code that causes the error:

    this.nineSlice = new PhaserNineSlice.NineSlice(
        this.game as PhaserNineSlice.NineSliceGame,
        400,
        100,
        AssetsKeys.ATLAS_GAME_VIEW,
        AssetsKeys.ATLAS_GAME_VIEW_KEYS.MY_CARDS_VIEW.BOOKS_REVIEWER_BACK_BTN_UP,
        500,
        200,
        {
            top: 20,
            bottom: 20,
            left: 50,
            right: 50
        }
    );
    this.game.add.existing(this.nineSlice);

    this.nineSlice2 = new PhaserNineSlice.NineSlice(
        this.game as PhaserNineSlice.NineSliceGame,
        0,
        0,
        AssetsKeys.ATLAS_GAME_VIEW,
        AssetsKeys.ATLAS_GAME_VIEW_KEYS.MY_CARDS_VIEW.BOOKS_REVIEWER_BACK_BTN_UP,
        200,
        500,
        {
            top: 20,
            bottom: 20,
            left: 50,
            right: 50
        }
    );
    this.game.add.existing(this.nineSlice2);
fmflame commented 7 years ago

Hey, what's up with this bug? Any status update - is it hard to fix? I would really love to use it!

AleBles commented 7 years ago

I'm not seeing this happen when I duplicate the button in the example, which version of Phaser are you guys on?

edit; NVM, just found out it happens on Phaser-CE

AleBles commented 7 years ago

Also found out it's a bug in Phaser-ce: http://www.html5gamedevs.com/topic/27041-gldrawelements-source-and-destination-textures-of-the-draw-are-the-same/#comment-165755

So either you downgrade to Phaser 2.6.2, or we rewrite this lib to not user RenderTexture.

fmflame commented 7 years ago

Well If it's really a Phaser-ce bug, then this should get fixed at some point and your lib would work right? My point being that if that is the case I can go vote for this issue on Phaser-ce github and possibly try to fix it at some point when I find the time?

AleBles commented 7 years ago

No bug reported in the phaser-ce repo yet, I'll be sure to make one later today