Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix position/color vertex attribute location
  • Loading branch information
ferhatb committed Oct 15, 2020
commit e904cfef9de22d1a782b260ff7f9eff4d52384fa
15 changes: 13 additions & 2 deletions lib/web_ui/lib/src/engine/html/render_vertices.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class _WebGlRenderer implements _GlRenderer {
assert(positionsBuffer != null); // ignore: unnecessary_null_comparison
gl.bindArrayBuffer(positionsBuffer);
gl.bufferData(positions, gl.kStaticDraw);
Object? positionLoc = gl.getUniformLocation(glProgram.program, 'position');
Object? positionLoc = gl.getAttributeLocation(glProgram.program, 'position');
js_util.callMethod(
gl.glContext, 'vertexAttribPointer', <dynamic>[
positionLoc, 2, gl.kFloat, false, 0, 0,
Expand All @@ -159,7 +159,7 @@ class _WebGlRenderer implements _GlRenderer {
gl.bindArrayBuffer(colorsBuffer);
// Buffer kBGRA_8888.
gl.bufferData(vertices._colors, gl.kStaticDraw);
Object colorLoc = gl.getUniformLocation(glProgram.program, 'color');
Object colorLoc = gl.getAttributeLocation(glProgram.program, 'color');
js_util.callMethod(gl.glContext, 'vertexAttribPointer',
<dynamic>[colorLoc, 4, gl.kUnsignedByte, true, 0, 0]);
gl.enableVertexAttribArray(1);
Expand Down Expand Up @@ -666,6 +666,17 @@ class _GlContext {
}
}

/// Returns reference to uniform in program.
Object getAttributeLocation(Object program, String attribName) {
Object? res = js_util
.callMethod(glContext, 'getAttribLocation', <dynamic>[program, attribName]);
if (res == null) {
throw Exception('$attribName not found');
} else {
return res;
}
}

/// Sets float uniform value.
void setUniform1f(Object uniform, double value) {
return js_util
Expand Down