It is a native extension for Dart to use OpenGL in desktop applications. On www.dartlang.org they call it "command-line or server applications". However, you can definitely create GUI application and use OpenGL too.
dependencis:
dartgl:
pub get
import 'package:dartgl/dartgl.dart';
var vertexShader = glCreateShader(GL_VERTEX_SHADER);
var fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
...
var program = glCreateProgram();
glAttachShader(program, vertexShader);
glAttachShader(program, fragmentShader);
glBindAttribLocation(program, 0, "in_Position");
glBindAttribLocation(program, 1, "in_Color");
glBindAttribLocation(program, 2, "in_Texture");
glLinkProgram(program);
location = glGetUniformLocation(program, "in_Time");
var arrays = new Uint32List(1);
glGenVertexArrays(1, arrays);
...
while (...){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
...
/.
}
For testing purpose, I created native extension for a tiny part of SDL 2.0 to create a window, create OpenGL context and manage window events. You can use your own way.
In order to run basic examples from test directory, SDL should be installed.
sudo apt-get install libsdl2-2.0
Download and add to PATH
In order to simplify troubleshooting, you can use debug modification of DartGL. In this mode, glGetError() is called after each OpenGL. Error message is printed to console if glGetError returns not GL_NO_ERROR.
import 'package:dartgl/debug/dartgl.dart';
Add this to your package's pubspec.yaml file:
dependencies:
dartgl: "^0.1.3"
You can install packages from the command line:
with pub:
$ pub get
Alternatively, your editor might support pub get.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:dartgl/dartgl.dart';
| Version | Uploaded | Documentation | Archive |
|---|---|---|---|
| 0.1.3 | Aug 15, 2016 |
|
|
| 0.1.2 | Aug 12, 2016 |
|
|
| 0.1.1 | Aug 2, 2016 |
|
|
| 0.1.0 | Aug 2, 2016 |
|
|
| 0.0.23 | Aug 13, 2014 |
|
|
| 0.0.22 | Aug 13, 2014 |
|
|
| 0.0.21 | Aug 12, 2014 |
|
|
| 0.0.20 | Aug 12, 2014 |
|
|
| 0.0.19 | Aug 12, 2014 |
|
|
| 0.0.18 | Aug 12, 2014 |
|
|
We analyzed this package on Jul 13, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
|
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
22 | / 100 |
|
Health:
Code health derived from static analysis.
[more]
|
100 | / 100 |
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
7 | / 100 |
|
Overall score:
Weighted score of the above.
[more]
|
42 |
Detected platforms: other
Primary library:
package:dartgl/dartgl.dartwith components:nativewrappers.
Maintain CHANGELOG.md.
Changelog entries help clients to follow the progress in your code.
Package is getting outdated.
The package was released 99 weeks ago.
Fix analysis and formatting issues.
Analysis or formatting checks reported 14 hints.
Run
dartfmtto formatlib/dartgl.dart.Run
dartfmtto formatlib/dartgl_sdl.dart.Similar analysis of the following files failed:
lib/debug/dartgl.dart(hint)lib/debug/handlers.dart(hint)
Package is pre-v1 release.
While there is nothing inherently wrong with versions of
0.*.*, it usually means that the author is still experimenting with the general direction API.
Maintain an example.
Create a short demo in the
example/directory to show how to use this package. Common file name patterns include:main.dart,example.dartor you could also usedartgl.dart.