attachOpenGlSurface method

RenderSessionHandle attachOpenGlSurface(
  1. OpenGlSurfaceDescriptor descriptor,
  2. RenderSessionAttachOptions options
)

Creates a session that renders the map to an OpenGL surface.

See mln_map_attach_open_gl_surface in the C API reference.

Errors:

  • Status.unsupported when openGlSupportedContextProviderMask() lacks the context's platform.

Implementation

RenderSessionHandle attachOpenGlSurface(
  OpenGlSurfaceDescriptor descriptor,
  RenderSessionAttachOptions options,
) {
  final registrations = _NativeRegistrations(_CallbackRoots());
  return _attach(
    (arena, completion, outSession) => registrations.run(
      () => raw.mln_map_attach_open_gl_surface(
        _handle.raw,
        _writeOpenGlSurfaceDescriptor(descriptor, arena),
        _writeRenderSessionAttachOptions(options, arena, registrations),
        outSession,
        completion,
        nativeDiagnostic,
      ),
    ),
    (handle, ready) => _adoptOwned(
      handle,
      () =>
          (RenderSessionHandle._(this, _NativeRenderSession(handle), ready)
            .._state.retain(registrations)),
      (handle) {
        _check(raw.mln_render_session_dispose(handle, nativeDiagnostic));
      },
    ),
  );
}