flutter_gl icon indicating copy to clipboard operation
flutter_gl copied to clipboard

Example doesn't work correctly on Windows

Open organic-nailer opened this issue 2 years ago • 6 comments

Hello. Thank you for creating such an amazing package!

I tried to run example app (flutter_gl/example), but when I run it on Windows, the triangle doesn't show up. When I run it on the Web under the same condition, it displays correctly. Could you see what's wrong?

  • Windows image

  • Web image

organic-nailer avatar Jun 22 '23 15:06 organic-nailer

The example should work on Intel integratied graphic rather AMD or Nvidia adapter. The vertex shader should be like: """#version 300 es precision mediump float; in vec4 a_position; in vec2 a_texCoord; out highp vec2 vTexCoord; void main() { gl_Position = a_position; vTexCoord = a_texCoord; } """;

beelabcloud avatar Aug 28 '23 16:08 beelabcloud

for AMD case, "vec4 a_position" is the key, vec2/vec3 just not working, I don't know why.

beelabcloud avatar Aug 28 '23 16:08 beelabcloud

I found a weak solution in my environment (Windows/AMD).

https://github.com/organic-nailer/flutter_gl_sample_windows/blob/master/lib/main.dart

for AMD case, "vec4 a_position" is the key, vec2/vec3 just not working, I don't know why.

The above solution was not effective in my environment. I found that calling glVertexAttribPointer twice results in the correct display instead. I don't know why this code works correctly.

gl.bindVertexArray(_vao);
{
  gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer);
  gl.enableVertexAttribArray(positionLocation);
  // call twice
  gl.vertexAttribPointer(positionLocation, 4, gl.FLOAT, false, 4 * Float32List.bytesPerElement, 0);
  gl.vertexAttribPointer(positionLocation, 4, gl.FLOAT, false, 4 * Float32List.bytesPerElement, 0);
}
gl.bindVertexArray(0);

organic-nailer avatar Sep 30 '23 11:09 organic-nailer