ChronosGL constructor

ChronosGL(
  1. dynamic _canvas, {
  2. bool preserveDrawingBuffer = false,
  3. bool faceCulling = false,
  4. bool antialiasing = true,
})

Implementation

ChronosGL(this._canvas,
    {bool preserveDrawingBuffer = false,
    bool faceCulling = false,
    bool antialiasing = true}) {
  Map<String, Object> attributes = {
    "alpha": false,
    "depth": true,
    "stencil": true,
    "antialias": antialiasing,
    "premultipliedAlpha": true,
    "preserveDrawingBuffer": preserveDrawingBuffer,
    "failIfMajorPerformanceCaveat": false,
  };

  _gl = _canvas.getContext("webgl2", attributes);
  if (_gl == null) {
    throw Exception(NO_WEBGL_MESSAGE);
  }

  dynamic actual = _gl.getContextAttributes();
  LogInfo("ChronosGL Config: ${actual}");

  _gl.clearColor(0.0, 0.0, 0.0, 1.0);
  _gl.enable(GL_DEPTH_TEST);
  if (faceCulling) {
    _gl.enable(GL_CULL_FACE);
  }
}