Skip to content

Commit

Permalink
release new version 0.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
wasabia committed Jan 14, 2022
1 parent 608f2a3 commit 9146b73
Show file tree
Hide file tree
Showing 24 changed files with 483 additions and 373 deletions.
22 changes: 20 additions & 2 deletions flutter_gl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

Flutter GL can call OpenGL ES API with Dart

Support iOS,Android,Web
Support iOS, Android, Web, macOS, Windows

Linux TODO

Used by [three_dart](https://github.com/wasabia/three_dart)


## OpenGL ES API
Now the api is similar to WebGL
Expand All @@ -23,9 +28,12 @@ int width = 200;
int height = 200;
num dpr = 1.0;
flutterGlPlugin = FlutterGlPlugin(width, height, dpr: dpr);
flutterGlPlugin = FlutterGlPlugin();
Map<String, dynamic> _options = {
"width": width,
"height": height,
"dpr": dpr,
"antialias": true,
"alpha": false
};
Expand Down Expand Up @@ -56,12 +64,22 @@ cd flutter_gl/flutter_gl/example
flutter run
```

## 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](https://user-images.githubusercontent.com/1768228/118112805-15a0b300-b418-11eb-81c0-c693cfca95aa.png)

![screen1](https://user-images.githubusercontent.com/1768228/118112813-176a7680-b418-11eb-8ff9-877b941048e1.png)


## Issues

File any issues, bugs, or feature requests.
Expand Down
34 changes: 28 additions & 6 deletions flutter_gl/example/lib/ExampleDemoTest.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:io';
import 'dart:math';
import 'dart:typed_data';

Expand Down Expand Up @@ -163,10 +164,9 @@ class _MyAppState extends State<ExampleDemoTest> {
animate() {
render();

// Future.delayed(Duration(milliseconds: 40), () {

// animate();
// });
Future.delayed(Duration(milliseconds: 40), () {
animate();
});
}

setupDefaultFBO() {
Expand Down Expand Up @@ -234,14 +234,36 @@ class _MyAppState extends State<ExampleDemoTest> {
prepare() {
final _gl = flutterGlPlugin.gl;

var vs = """
String _version = "300 es";

if(Platform.isMacOS || Platform.isWindows) {
_version = "150";
}

var vs = """#version ${_version}
${
(Platform.isMacOS || Platform.isWindows) ? """
#define attribute in
#define varying out
#define texture2D texture
""" : ""
}
attribute vec4 a_Position;
void main() {
gl_Position = a_Position;
}
""";

var fs = """
var fs = """#version ${_version}
${
(Platform.isMacOS || Platform.isWindows) ? """
#define varying in
out highp vec4 pc_fragColor;
#define gl_FragColor pc_fragColor
""" : ""
}
precision mediump float;
uniform vec4 u_color;
void main() {
Expand Down
30 changes: 26 additions & 4 deletions flutter_gl/example/lib/ExampleTriangle01.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import 'dart:async';
import 'dart:io';
import 'dart:math';
import 'dart:typed_data';

import 'dart:ui' as ui;
import 'dart:ffi';
import 'package:ffi/ffi.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

Expand Down Expand Up @@ -206,14 +205,37 @@ class _MyAppState extends State<ExampleTriangle01> {
prepare() {
final _gl = flutterGlPlugin.gl;

var vs = """
String _version = "300 es";

if(Platform.isMacOS || Platform.isWindows) {
_version = "150";
}

var vs = """#version ${_version}
${
(Platform.isMacOS || Platform.isWindows) ? """
#define attribute in
#define varying out
#define texture2D texture
""" : ""
}
attribute vec3 a_Position;
void main() {
gl_Position = vec4(a_Position, 1.0);
}
""";

var fs = """
var fs = """#version ${_version}
${
(Platform.isMacOS || Platform.isWindows) ? """
#define varying in
out highp vec4 pc_fragColor;
#define gl_FragColor pc_fragColor
""" : ""
}
void main() {
gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0);
}
Expand Down
4 changes: 2 additions & 2 deletions flutter_gl/example/lib/MyApp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class _MyAppState extends State<MyApp> {

@override
Widget build(BuildContext context) {
return ExampleTriangle01();
// return ExampleDemoTest();
// return ExampleTriangle01();
return ExampleDemoTest();
}
}
2 changes: 1 addition & 1 deletion flutter_gl/example/macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
flutter_gl_macos: fd42c918a2cfe97e202cc51f2347a15644b763e5
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
path_provider_macos: a0a3fd666cb7cd0448e936fb4abad4052961002b
path_provider_macos: 160cab0d5461f0c0e02995469a98f24bdb9a3f1f
three3d_egl_osx: 5f0b1c41e6d687ac778b3d9900afd569c7f36424

PODFILE CHECKSUM: 0d3963a09fc94f580682bd88480486da345dc3f0
Expand Down
Loading

0 comments on commit 9146b73

Please sign in to comment.