wasabia / flutter_gl

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

Add missing `glTransformFeedbackVaryings` #23

Closed intonarumori closed 2 years ago

intonarumori commented 2 years ago

Based on the documentation it seems this could be available for use in OpenGLES 3.0: https://www.khronos.org/registry/OpenGL-Refpages/es3.0/html/glTransformFeedbackVaryings.xhtml

This would be very useful to create particle fields, let me know if you could add this. Thank you.

wasabia commented 2 years ago

glTransformFeedbackVaryings done. but not test 😄

https://developer.mozilla.org/en-US/docs/Web/API/WebGLTransformFeedback

intonarumori commented 2 years ago

@wasabia I'm using pub to include the project. Do you think a version update is needed for these changes to take effect? Maybe bumping to 0.0.16? If there's another way to update let me know, I'm a bit new to Flutter.

Thanks.

wasabia commented 2 years ago

clone this repo to your local then you can use local pub

like flutter_gl example project

https://github.com/wasabia/flutter_gl/blob/main/flutter_gl/example/pubspec.yaml

intonarumori commented 2 years ago

@wasabia Thanks.

Tested, I think we need to use Int8 pointers and cast the native utf8 to int8 like this:

/// OpenGLContextES.dart
transformFeedbackVaryings(program, count, List<String> varyings, bufferMode) {
    final varyingsPtr = calloc<Pointer<Int8>>(varyings.length);

    int i = 0;
    for (final varying in varyings) {
      varyingsPtr[i] = varying.toNativeUtf8().cast<Int8>();
      i = i + 1;
    }
    final result = gl.glTransformFeedbackVaryings(program, count, varyingsPtr, bufferMode);
    calloc.free(varyingsPtr);

    return result;
  }

Instead of: https://github.com/wasabia/flutter_gl/blob/21de2e5a1205283df8df1520f71877b01f8b9b00/flutter_gl/lib/openGL/opengl/OpenGLContextES.dart#L813-L826

I will test more and maybe set up a fork and send a PR.