tsherif/picogl.js

Texture.data and flipY

Closed this issue · 2 comments

Hello again,
It seems that in Texture.data(), the texSubImage2D call uses the last value set for pixelStorei(GL.UNPACK_FLIP_Y_WEBGL) and doesn't use the texture's flipY.
If I understand this correctly, it can be fixed by adding in Texture.data() this again after binding.

    data(data) {
        if (!Array.isArray(data)) {
            DUMMY_UNIT_ARRAY[0] = data;
            data = DUMMY_UNIT_ARRAY;
        }

        let numLevels = this.mipmaps ? data.length : 1;
        let width = this.width;
        let height = this.height;
        let depth = this.depth;
        let generateMipmaps = this.mipmaps && data.length === 1;
        let i;

        this.bind(Math.max(this.currentUnit, 0));
        this.gl.pixelStorei(GL.UNPACK_FLIP_Y_WEBGL, this.flipY); // <- here

Hmmm... that's odd. I thought pixel store parameters were part of texture state. Thanks for reporting.

Turns out I was totally wrong. Pixel unpack parameters are part of the global GL state. This will be fixed in the next patch (+ a regression test!)