Repository navigation
Conversation
getExtension('WEBGL_provoking_vertex') returned null, so flat varyings always came from the last vertex. headless-gl now offers it on WebGL2 contexts using ANGLE's GL_ANGLE_provoking_vertex, as Chrome does, and provokingVertexWEBGL(FIRST_VERTEX_CONVENTION_WEBGL) switches to the first vertex. getParameter(PROVOKING_VERTEX_WEBGL) returns the convention once the extension is enabled.
The first vertex convention matters beyond correctness: under the last vertex convention, ANGLE's Metal backend rewrites the index buffer of each indexed draw whose program has flat varyings, and keeps the copies.
index.d.ts declares the extension, since TypeScript's DOM types don't.
test/webgl-provoking-vertex.js checks that WebGL1 doesn't offer it, that getParameter is rejected before it is enabled, and that a flat-shaded triangle takes its last vertex's color, then its first's once set, then its last's again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
getExtension('WEBGL_provoking_vertex')returnsnull, so flat varyings always come from the last vertex. This offers the extension on WebGL2 contexts using ANGLE'sGL_ANGLE_provoking_vertex, as Chrome does.provokingVertexWEBGL(FIRST_VERTEX_CONVENTION_WEBGL)switches flat varyings to the first vertex; ANGLE setsINVALID_ENUMfor any other mode, as the extension spec says.getParameter(PROVOKING_VERTEX_WEBGL)returns the convention once the extension is enabled, andnullwithINVALID_ENUMbefore.index.d.tsdeclares it inSupplementalExtensions, since TypeScript's DOM types don't; the README's table lists it.Why it matters beyond correctness: under the last vertex convention, ANGLE's Metal backend rewrites the index buffer of every indexed draw whose program has flat varyings, and keeps the copies. A WebGL2 renderer that picks the first vertex convention in browsers for that reason can now do the same here.
Tests
test/webgl-provoking-vertex.jsdraws a flat-shaded triangle whose vertices are red, green, and blue: the pixel is blue under the default (last) convention, red onceFIRST_VERTEX_CONVENTION_WEBGLis set, and blue again when set back. It also checks the constants,getParameterbefore and after enabling, andINVALID_ENUMfor another mode.On macOS (M4 Max), with ANGLE's default OpenGL backend and with
ANGLE_DEFAULT_PLATFORM=metal:test/webgl-provoking-vertex.js: 15/15test/*.jsthat doesn't need@stackgl/gl-conformance(48 files): passtest/types.js(node.mts,require.cts,dom.mts,custom-context-types.mts): passstandardon the changed files: cleanNot run: the conformance suite (
@stackgl/gl-conformanceneeds a GitHub Packages token), Linux, and Windows.Context: we render a WebGL2 CAD engine (Emscripten) in Node with headless-gl master. Master runs it with no workarounds; this extension was the one thing missing. Thanks for the WebGL2 work this month.
🤖 Generated with Claude Code