Skip to content

Implement getVertexAttrib family for WebGL compatibility (getVertexAttrib, getVertexAttribOffset, etc.) #407

@EndlessJour9527

Description

@EndlessJour9527

Background

When running sdk/tests/conformance2/attribs/gl-vertex-attrib.html from the EndlessJour9527/WebGL test suite in JSAR Runtime, the following error is encountered:

Uncaught TypeError: gl.getVertexAttrib is not a function

This is a critical WebGL API required by the WebGL specification and by a number of Khronos conformance tests (see WebGL 2.0 spec: getVertexAttrib).

Task

Implement the family of getVertexAttrib APIs so that JSAR correctly passes conformance tests such as:

  • gl.getVertexAttrib
  • gl.getVertexAttribOffset
  • gl.getVertexAttribPointer

Minimal required functionality

  • All variants for querying attribute state must be provided and match WebGL 1/2 and Khronos test expectations
    • Accepts all standard parameters: index, pname
    • Handles edge cases required for test coverage

Reference:

Acceptance Criteria

  • Passing the following conformance test file: sdk/tests/conformance2/attribs/gl-vertex-attrib.html from EndlessJour9527/WebGL
  • Returns correct results for all valid function calls
  • Throws appropriate exceptions for invalid parameters as per the spec

Implementation Hints (C++)

Implement in C++:

// WebGLRenderingContext getVertexAttrib implementation
void WebGLRenderingContext::getVertexAttrib(GLuint index, GLenum pname, ...) {
  // Reference: https://registry.khronos.org/webgl/specs/latest/2.0/#5.14.9
  // Add switch/case for each valid pname
  switch (pname) {
    case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
      // Return enabled state
      break;
    case GL_VERTEX_ATTRIB_ARRAY_SIZE:
      // Return size
      break;
    // ... handle other cases
    default:
      // Throw exception for invalid pname
      break;
  }
}

Related files to update are in src/client/builtin_scene/webgl_rendering_context.cpp.


See also JSAR documentation for WebGL 2.0 support and internal architecture documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions