oframe / ogl

Minimal WebGL Library
https://oframe.github.io/ogl/examples
3.77k stars 213 forks source link

Texture state #116

Closed hansagames closed 2 years ago

hansagames commented 3 years ago

Hi, just curious if this is correct:

src/core/Texture.js

How it is now:

      this.state = {};
        this.state.minFilter = this.gl.NEAREST_MIPMAP_LINEAR;
        this.state.magFilter = this.gl.LINEAR;
        this.state.wrapS = this.gl.REPEAT;
        this.state.wrapT = this.gl.REPEAT;
        this.state.anisotropy = 0;

Should not be values that are passed as parameters ?

        this.state = {};
       this.state.minFilter = this.minFilter;
        this.state.magFilter = this.magFilter;
        this.state.wrapS = this.wrapS;
        this.state.wrapT = this.wrapT;
        this.state.anisotropy = this.anisotropy;

as state is used as cache here, but maybe I am missing something

hansagames commented 3 years ago

Ok my assumption was wrong as it applies texture params only if they are not same as state, so would say at init state should be undefined or null, so on first render it would be applied

gordonnl commented 2 years ago

Yeah so I set the initial state to match the GL defaults, so that when it's first updated, it will only update those which differ from the defaults