Skip to content

GLES: fix ofPolyline / ofBeginShape outlines not drawing (iOS, WebGL) and ignoring line width (Android) - #8585

Merged
danoli3 merged 2 commits into
openframeworks:masterfrom
danoli3:gles-polyline-lines-shader
Oct 13, 2026
Merged

danoli3 merged 2 commits into
openframeworks:masterfrom
danoli3:gles-polyline-lines-shader

Conversation

@danoli3

@danoli3 danoli3 commented Oct 13, 2026

Copy link
Copy Markdown
Member

Problem

On OpenGL ES, open outlines don't draw: ofPolyline::draw(), and ofNoFill() + ofBeginShape() / ofEndShape(). The waveforms in audioOutputExample on WebGL are one visible case.

draw(ofPolyline) had an ES-only path that binds the positions as a client array and draws a raw GL_LINE_STRIP / GL_LINE_LOOP. With the lines shaders enabled (the default since #8019), setAttributes() selects the lines shader. That shader expects the triangle mesh draw(ofMesh) builds from the line, with prev/next vertex attributes, so the raw strip:

  • iOS (ES 3.0 and 2.0) and WebGL (1 and 2): draws nothing.
  • Android: draws garbled, wavy lines and ignores ofSetLineWidth.

#8533 removed the !TARGET_EMSCRIPTEN exclusion from that path, which is when WebGL broke.

Change

draw(ofPolyline) on ES uses the client-array path only when the lines shaders are disabled. Otherwise it uses the same VBO mesh path as desktop GL, which goes through draw(ofMesh) and its lines-shader bundle.

Tested

The same test on each platform draws eight outline cases over black and counts the drawn pixels in each band:

  1. open ofBeginShape, width 1
  2. open ofBeginShape, width 3
  3. ofDrawLine, width 1
  4. ofDrawLine, width 3
  5. ofPolyline::draw, width 1
  6. ofPolyline::draw, width 3
  7. unfilled rectangle
  8. closed ofBeginShape
Platform master this PR
WebGL2 / WebGL1 (Chrome) open ofBeginShape and ofPolyline blank, closed shape skewed ✅ all 8
iOS simulator, ES 3.0 and ES 2.0 open ofBeginShape, ofPolyline and closed shape blank ✅ all 8
Android 14 emulator, ES 3.0 lines garbled, width 3 drawn at 1 px ✅ all 8, correct widths

ofDrawLine and the unfilled rectangle already worked on master and are unchanged.

WebGL2: master / this PR

iOS simulator, ES 3.0: master / this PR

Android emulator, ES 3.0: master / this PR

Not tested on real devices.

On OpenGL ES, draw(ofPolyline) bound the positions as a client array and
drew a raw GL_LINE_STRIP / GL_LINE_LOOP. With the lines shaders enabled
(the default since openframeworks#8019) setAttributes() selects the lines shader, which
expects the triangle mesh that draw(ofMesh) builds from the line, so the
raw strip drew nothing on iOS and WebGL (open ofPolyline::draw and
ofNoFill ofBeginShape / ofEndShape outlines were blank) and ignored
ofSetLineWidth on Android. openframeworks#8533 also sent emscripten down this path,
which is how WebGL broke.

Use the client array path only when the lines shaders are disabled;
otherwise use the same VBO mesh path as desktop GL.
@danoli3
danoli3 merged commit 6fe7474 into openframeworks:master Oct 13, 2026
20 checks passed
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 this pull request may close these issues.

1 participant