wasabia / flutter_gl

cross-platform call OpenGL API by Dart through dart:ffi. Provides OpenGL with Texture Widget on Flutter.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add missing `glTransformFeedbackVaryings`

intonarumori opened this issue · comments

commented

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.

glTransformFeedbackVaryings done. but not test 😄

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

commented

@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.

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

commented

@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:

transformFeedbackVaryings(program, count, List<String> varyings, bufferMode) {
final varyingsPtr = calloc<Pointer<Utf8>>(varyings.length);
int i = 0;
for(final varying in varyings) {
varyingsPtr[i] = varying.toNativeUtf8();
i = i + 1;
}
final result = gl.glTransformFeedbackVaryings(program, count, varyingsPtr, bufferMode);
calloc.free(varyingsPtr);
return result;
}

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