Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify instancing, instancedArrays and vertexArray polyfilling code #116

Closed
dmnsgn opened this issue May 19, 2022 · 3 comments · Fixed by #117
Closed

Simplify instancing, instancedArrays and vertexArray polyfilling code #116

dmnsgn opened this issue May 19, 2022 · 3 comments · Fixed by #117
Milestone

Comments

@dmnsgn
Copy link
Member

dmnsgn commented May 19, 2022

According to MDN WebGL_best_practices, ANGLE_instanced_arrays, OES_standard_derivatives, OES_element_index_uint and OES_vertex_array_object are universally supported in WebGL 1.

So we could remove the checks for their existence and just polyfill directly.

Related #114.

@dmnsgn
Copy link
Member Author

dmnsgn commented May 19, 2022

From this:

  if (!gl.drawElementsInstanced) {
    const ext = gl.getExtension("ANGLE_instanced_arrays");
    if (!ext) {
      // TODO: this._caps[CAPS_INSTANCED_ARRAYS] = false;
      gl.drawElementsInstanced = () => {
        throw new Error(
          "gl.drawElementsInstanced not available. ANGLE_instanced_arrays not supported"
        );
      };
      gl.drawArraysInstanced = () => {
        throw new Error(
          "gl.drawArraysInstanced not available. ANGLE_instanced_arrays not supported"
        );
      };
      gl.vertexAttribDivisor = () => {
        throw new Error(
          "gl.vertexAttribDivisor not available. ANGLE_instanced_arrays not supported"
        );
      };
    } else {
      // TODO: this._caps[CAPS_INSTANCED_ARRAYS] = true;
      gl.drawElementsInstanced = ext.drawElementsInstancedANGLE.bind(ext);
      gl.drawArraysInstanced = ext.drawArraysInstancedANGLE.bind(ext);
      gl.vertexAttribDivisor = ext.vertexAttribDivisorANGLE.bind(ext);
      capabilities.instancedArrays = true;
      capabilities.instancing = true; // TODO: deprecate
    }
  } else {
    capabilities.instancedArrays = true;
    capabilities.instancing = true; // TODO: deprecate
  }

to this:

if (!gl.drawElementsInstanced) {
    const ext = gl.getExtension("ANGLE_instanced_arrays");
    gl.drawElementsInstanced = ext.drawElementsInstancedANGLE.bind(ext);
    gl.drawArraysInstanced = ext.drawArraysInstancedANGLE.bind(ext);
    gl.vertexAttribDivisor = ext.vertexAttribDivisorANGLE.bind(ext);
  }

and removing capabilities.instancing/instancedArrays/vertexArrayObject.

@vorg
Copy link
Member

vorg commented May 19, 2022

Looks good

dmnsgn added a commit that referenced this issue May 19, 2022
…ement_index_uint and OES_vertex_array_object are universally supported

- remove extension check for ANGLE_instanced_arrays and OES_vertex_array_object
- remove capabilities.instancing/instancedArrays/vertexArrayObject
- remove OES_element_index_uint and OES_standard_derivatives from capabilities

Closes #116
@dmnsgn dmnsgn mentioned this issue May 26, 2022
Merged
10 tasks
@dmnsgn
Copy link
Member Author

dmnsgn commented Jun 8, 2022

OES_element_index_uint and OES_standard_derivatives still need a call to get activated.

@dmnsgn dmnsgn added this to the 3.0.0 milestone Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants