sdlxGetWindows function video

List<Pointer<SdlWindow>>? sdlxGetWindows()

Get a list of valid windows.

\param count a pointer filled in with the number of windows returned, may be NULL. \returns a NULL terminated array of SDL_Window pointers or NULL on failure; call SDL_GetError() for more information. This is a single allocation that should be freed with SDL_free() when it is no longer needed.

\threadsafety This function should only be called on the main thread.

\since This function is available since SDL 3.2.0.

extern SDL_DECLSPEC SDL_Window ** SDLCALL SDL_GetWindows(int *count)

Implementation

List<Pointer<SdlWindow>>? sdlxGetWindows() {
  final countPointer = calloc<Int32>();
  final resultPointer = sdlGetWindows(countPointer);
  if (resultPointer == nullptr) {
    countPointer.callocFree();
    return null;
  }
  final count = countPointer.value;
  final result = <Pointer<SdlWindow>>[];
  for (var i = 0; i < count; i++) {
    result.add((resultPointer + i).value);
  }
  countPointer.callocFree();
  return result;
}