flutter_opengl 0.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 56

OpenGL Flutter plugin #

OpenGL Android NDK plugin.

YT video


Getting Started #

This plugin is only for Android. Is greatly appreciated any help!
This is an early stage of a plugin for Flutter to let the developers to use an OpenGL widget. This is not a binding to let the devs to write OpenGL code within Flutter, but lets to write shader and drawing frame functions in C/C++ code. The plugin is only available for Android OS, looking forward for someone to make it cross-platform!

The example provides 4 drawing shaders classes. They are subclass of Shader.cpp. Each of them need an initShader(void *args) and a drawFrame(void *args) functions which are used by the renderer.cpp engine at creation time. RendererController::nativeSetSurface() has the task to crate the renderer engine.

The 3 example shaders are taken from https://www.shadertoy.com/ https://www.shadertoy.com/view/3l23Rh by nimitz https://www.shadertoy.com/user/nimitz https://www.shadertoy.com/view/llj3Dz by Darthmarshie https://www.shadertoy.com/user/Darthmarshie https://www.shadertoy.com/view/ttlGDf by alro https://www.shadertoy.com/user/alro

(more to come)


Currently NDK builds for x86_64, x86, arm64-v8a and armeabi-v7a and libnative-lib.so is available on all ABI lib subfolders but libflutter.so is missing in armeabi-v7a. In example or plugin build.gradle or both, forcing gradle to build only for armeabi-v7a with

ndk {
    abiFilters 'armeabi-v7a'

doesn't work and libflutter.so is missing in the lib folder, but works with command line:

flutter run --debug --target-platform android-arm

(more to come)


Renderer::getWindowWidth() and Renderer::getWindowHeight() doesn't work correctly:
they are used in Renderer::initializeGL() to set window buffer size with ANativeWindow_setBuffersGeometry(), without it the window surface is not working and nothing is displayed.

Add source comments.

Implement a way to pass an OpenGL texture from Flutter to NDK.

Implement iOS layer plugin.

(more to come)

0.0.3 #

  • code rearranged.
  • every shader can now be written separately subclassing the Shader class and passing it to the renderer.
  • added function to load texture image from assets folder with Android. Since this uses java, it should be rewritten for iOS.
  • added a texture shader example.


opengl_example #

Demonstrates how to use the opengl plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_opengl: ^0.0.3

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_opengl/flutter_opengl.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health issues and suggestions

Document public APIs. (-1 points)

8 out of 8 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/flutter_opengl.dart.

Run flutter format to format lib/flutter_opengl.dart.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies