bagl 0.6.1

  • Installing
  • Versions
  • 56

BaGL.dart: Basic Graphics Library for Dart.

WIP: expect changes to public interfaces, missing features and bugs. Please feel free to open issues on missing functionality and changes to public interfaces.

BaGL is a low-level abstraction on top of WebGL. It aims to provide a simpler, safer and more declarative drawing alternative to plain WebGL. BaGL was inspired by Glium and Elm WebGL.



Some basic examples are available in the example folder:

  • Triangle (dart, html): the "hello world" of the graphics world, drawing a single triangle.
  • Animated triangle (dart, html): demonstrates an animation loop with a triangle whose size oscillates.
  • Textured triangle (dart, html): demonstrates texturing with a 2D texture from a separate png file.
  • Cube (dart, html): demonstrates drawing a 3D mesh.
  • Animated Cube (dart, html): demonstrates an animation loop with a 3D mesh.
  • Textured Cube (dart, html): demonstrates texturing a 3D mesh with a 2D texture from a separate png file.


API documentation is available here.

BaGL Change Log


This version includes a refactor of the geometry APIs and several related breaking changes:

  • BREAKING: IndexGeometry has been renamed to PrimitiveSequence.
  • BREAKING: the default constructor signature of all PrimitiveSequence implementations (Points, Lines, LineStrip, LineLoop, Triangles, TriangleStrip, TriangleFan) has changed; the indexList, offset and count are now optional named parameters.
  • BREAKING: TrianglesTriangleView, LinesLineView and PointsPointView no longer allow updates of their vertex indices directly. Instead the index list of the PrimitiveSequence on which they are defined needs to be updated.
  • BREAKING: the index_geometry library has been renamed to geometry.
  • BREAKING: the geometric_primitives library has been removed; its contents were merged into the new geometry library.
  • All PrimitiveSequence implementations (Points, Lines, LineStrip, LineLoop, Triangles, TriangleStrip, TriangleFan) now allow modification of the count after instantiation. This should help implement dynamic geometry, in which the index list size is overprovisioned initially such that later additional data can be added and the primitive sequence expanded (by increasing the count) without having to recreate and rebind a new buffer for each change.
  • Adds magnitude, unitVector and isUnit fields to Vector2, Vector3 and Vector4.


LineLoopIterator, LineStripIterator, LinesIterator, PointsIterator, TriangleFanIterator, TriangleStripIterator, TrianglesIterator, AttributeDataTableIterator, AttributeDataRowViewIterator and VertexArrayIterator were made private. These iterators provide nothing beyond the expected Iterator API and were cluttering the API documentation.


  • BREAKING: deprovisionGeometry, deprovisionProgram and deprovisionSampler have been removed from RenderingContext. Use context.geometryResource.deprovision, context.programResources.deprovision and 'context.samplerResources.deprovision` instead.
  • RenderingContext now exposes geometryResources, programResources and samplerResources fields to allow manual management of resource provisioning/ deprovisioning.
  • Frame.draw now takes autoProvisioning as an optional named parameter. When set to false, BaGL will not automagically provision GPU resources for you. Instead resources should have been provisioned manually prior to the draw call (see change above).

This version refactors the rendering internals to make heavy use of Expandos so as to only hold on to weak references to geometry, programs and samplers. This means that once geometry, program and sampler objects become inaccessible in your code, these objects may be garbage collected by the Dart/Javascript runtime. Importantly, any GPU resources that BaGL previously provisioned for these objects will then also be freed by the runtime. This means that in most cases, you do not have to worry about deprovisioning these resources manually.


  • BREAKING: the translation constructors on Matrix3 and Matrix4 now take separate double values for each translation direction rather than a single vector. This aligns the signature with the scale constructor signature.
  • BREAKING: removes withValues and withValuesTranspose from Vector2, Vector3, Vector4, Matrix2, Matrix3 and Matrix4. These methods are no longer necessary with rl_matrix 0.6.0 and had no real function in BaGL. Use the fromList constructors instead.
  • Adds a Struct type. Frame.draw now accepts uniform values of type Struct and List<Struct>. These map to user defined struct types in GLSL shaders.


  • BREAKING: IndexGeometry now takes a type parameter Primitive (should be of type Point, Line or Triangle) and extends Iterable<Primitive>.
  • BREAKING: VertexArrayBuilder and VertexArray.toBuilder() have been removed. For the moment I'm not sure they belong in this library and they introduce a lot of complexity. May be added back in at a later point in time.
  • BREAKING: the keys and values for the draw parameter attributeNameMap have been reversed: keys should now be names as they appear in the shader program, values should be the name of the attribute on the geometry.
  • BREAKING: Frame.draw no longer allows missing attributes. If an attribute is active on the shader program, then the geometry must define a matching attribute (either by defining an attribute with the same name, or through a mapping provided by the attributeNameMap draw parameter).
  • The geometry provided to a Frame.draw call may now define attributes that are not used by the shader program without raising an error.

1. Depend on it

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

  bagl: "^0.6.1"

2. Install it

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.

3. Import it

Now in your Dart code, you can use:

import 'package:bagl/bagl.dart';
Version Uploaded Documentation Archive
0.6.1 Dec 7, 2016 Go to the documentation of bagl 0.6.1 Download bagl 0.6.1 archive
0.6.0 Dec 5, 2016 Go to the documentation of bagl 0.6.0 Download bagl 0.6.0 archive
0.5.0 Aug 30, 2016 Go to the documentation of bagl 0.5.0 Download bagl 0.5.0 archive
0.4.0 Aug 24, 2016 Go to the documentation of bagl 0.4.0 Download bagl 0.4.0 archive
0.3.1 Aug 16, 2016 Go to the documentation of bagl 0.3.1 Download bagl 0.3.1 archive
0.3.0 Aug 11, 2016 Go to the documentation of bagl 0.3.0 Download bagl 0.3.0 archive
0.2.0 Aug 2, 2016 Go to the documentation of bagl 0.2.0 Download bagl 0.2.0 archive
0.1.1 Jul 12, 2016 Go to the documentation of bagl 0.1.1 Download bagl 0.1.1 archive
0.1.0 Jul 12, 2016 Go to the documentation of bagl 0.1.0 Download bagl 0.1.0 archive


This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1


Describes how popular the package is relative to other packages. [more]
18 / 100
Code health derived from static analysis. [more]
100 / 100
Reflects how tidy and up-to-date the package is. [more]
84 / 100
Overall score:
Weighted score of the above. [more]


Detected platforms: web

Primary library: package:bagl/bagl.dart with components: html.


  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

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

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use bagl.dart.

  • Use analysis_options.yaml.

    Rename old .analysis_options file to analysis_options.yaml.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <2.0.0
collection ^1.9.0 1.14.5
quiver ^0.24.0 0.24.0 0.28.0
rl_matrix ^0.6.4 0.6.4 0.6.5
Transitive dependencies
matcher 0.12.1+4
path 1.5.1
stack_trace 1.9.1
Dev dependencies
browser ^0.10.0
dart_to_js_script_rewriter ^0.1.0
test ^0.12.17