GithubHelp home page GithubHelp logo

dispersia / flutter_gl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wasabia/flutter_gl

0.0 0.0 0.0 2.32 MB

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

JavaScript 0.90% Ruby 0.08% C++ 0.62% C 64.64% Objective-C 2.84% Kotlin 0.43% Dart 26.45% CSS 0.64% Swift 0.78% HTML 1.61% CMake 0.84% SCSS 0.17%

flutter_gl's Introduction

Flutter GL

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

Support iOS, Android, Web, macOS, Windows

Linux TODO

Used by three_dart

OpenGL API

the api is similar to WebGL

only support draw to FBO. then share the FBO texture to Native side.

import

import 'package:flutter_gl/flutter_gl.dart';

Usage

int width = 200;
int height = 200;
num dpr = 1.0;

flutterGlPlugin = FlutterGlPlugin();

Map<String, dynamic> _options = {
    "width": width, 
    "height": height, 
    "dpr": dpr,
    "antialias": true,
    "alpha": false
};    
await flutterGlPlugin.initialize(options: _options);

// on web this need called after web canvas dom was added to document
await flutterGlPlugin.prepareContext();

// you can get gl by
gl = flutterGlPlugin.gl;

// then you can call OpenGL ES API by gl like
gl.clearColor(0.0, 0.0, 0.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT);

// use this method to notify Flutter update Texture Widget
// sourceTextue is a texture which bind to FBO framebuffer
flutterGlPlugin.updateTexture(sourceTexture);

why use NativeArray replace Dart List

Dart List convert to ffi pointer need memeory copy.

Run Examples

Clone or download this repo

cd flutter_gl/flutter_gl/example

flutter run

share opengl context with flutter_gl

Android

when init the plugin, save share opengl context with ThreeEgl,

ThreeEgl.setContext("shareContext", shareEglEnv.eglContext);

so you can get it use ThreeEgl lib, then create yourself opengl context share with "shareContext"

shareContext = ThreeEgl.getContext("shareContext");

iOS

for iOS the key is 3 ...

eAGLShareContext = ThreeEgl.getContext(key: 3);

Web

no need ? just webgl

Windows

not support get share context now

Android

check the example project copy the example/android/app/libs/aars/threeegl.aar to your app android project same path

change minSdkVersion 24

Screenshot

screen0

screen1

Issues

File any issues, bugs, or feature requests.

Contributing

Pull request please!

flutter_gl's People

Contributors

daniellangh avatar dispersia avatar kdet avatar kevingogii avatar linies avatar mark-nicepants avatar wasabia avatar yodesoft avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.