eglGetConfigs function

List<Pointer<Void>> eglGetConfigs(
  1. Pointer<Void> display, {
  2. int maxConfigs = 10,
})

Implementation

List<Pointer<Void>> eglGetConfigs(Pointer<Void> display,
    {int maxConfigs = 10}) {
  final configs = calloc<IntPtr>(maxConfigs);
  final numConfigs = calloc<Int32>();
  final nativeCallSucceeded = _libEGL!.eglGetConfigs(
        display,
        configs.cast<Pointer<Void>>(),
        maxConfigs,
        numConfigs,
      ) ==
      1;
  List<Pointer<Void>> result = <Pointer<Void>>[];

  if (nativeCallSucceeded) {
    for (var i = 0; i < numConfigs.value; ++i) {
      result.add(Pointer.fromAddress(configs[i]));
    }
  }

  calloc.free(configs);
  calloc.free(numConfigs);

  if (!nativeCallSucceeded) {
    throw EglException(
        'Failed to get configs for display [$display], max configs $maxConfigs.');
  }

  return result;
}