wasabia / flutter_gl

cross-platform call OpenGL API by Dart through dart:ffi. Provides OpenGL with Texture Widget on Flutter.
243 stars 60 forks source link

Class 'LibOpenGLES' has no instance method 'glUniform4fv' with matching arguments. #1

Closed ghost closed 2 years ago

ghost commented 2 years ago

I get this Exception when I try to set the colors

// setup the colors.

String vs = """
    attribute vec4 a_position;

    uniform mat4 u_matrix;

    void main() {
      // Multiply the position by the matrix.
      gl_Position = u_matrix * a_position;
    }
  """;

  String fs = """
    precision mediump float;

    uniform vec4 u_color;

    void main() {
      gl_FragColor = u_color;
    }
  """;

dynamic color = [
    Random().nextDouble(),
    Random().nextDouble(),
    Random().nextDouble(),
    1,
  ];

colorLocation = gl.getUniformLocation(program, "u_color");

gl.uniform4fv(colorLocation, color); <--- error
Exception has occurred.
NoSuchMethodError (NoSuchMethodError: Class 'LibOpenGLES' has no instance method 'glUniform4fv' with matching arguments.
Receiver: Instance of 'LibOpenGLES'
Tried calling: glUniform4fv(1, Instance(length:4) of '_GrowableList')
Found: glUniform4fv(int, int, Pointer<Float>) => void)

I get this error when I use the app on an android device.

The web app works without issues but my app will run on an android device.

What I should do to fix this issue?

wasabia commented 2 years ago

Hi @George35mk already update main branch and check the example project https://github.com/wasabia/flutter_gl/blob/main/flutter_gl/example/lib/ExampleDemoTest.dart#L194

Now is not full opengl api was wrappered https://github.com/wasabia/flutter_gl/blob/main/flutter_gl/lib/openGL/opengl/OpenGLContextES.dart#L1

wasabia commented 2 years ago

the example project now is only worked on App side beacuse it use ffi

ghost commented 2 years ago

Hi, @wasabia Thank you for the fix, can you update the package on the pub.dev https://pub.dev/packages/flutter_gl so I can update the package in my pubspec.yaml file and confirm the fix.

Thank you

wasabia commented 2 years ago

Hi @George35mk new version release. https://pub.dev/packages/flutter_gl

ghost commented 2 years ago

Thanks, @wasabia I can confirm your fix solves the issue. gl.uniform4fv now works as expected.