sdlSetWindowData function

Pointer<NativeType> sdlSetWindowData(
  1. Pointer<SdlWindow> window,
  2. String? name,
  3. Pointer<NativeType> userdata
)

Associate an arbitrary named pointer with a window.

name is case-sensitive.

\param window the window to associate with the pointer \param name the name of the pointer \param userdata the associated pointer \returns the previous value associated with name.

\since This function is available since SDL 2.0.0.

\sa SDL_GetWindowData

extern DECLSPEC void* SDLCALL SDL_SetWindowData(SDL_Window * window, const char *name, void *userdata)

Implementation

Pointer<NativeType> sdlSetWindowData(
    Pointer<SdlWindow> window, String? name, Pointer<NativeType> userdata) {
  final sdlSetWindowDataLookupFunction = libSdl2.lookupFunction<
      Pointer<NativeType> Function(Pointer<SdlWindow> window,
          Pointer<Utf8> name, Pointer<NativeType> userdata),
      Pointer<NativeType> Function(
          Pointer<SdlWindow> window,
          Pointer<Utf8> name,
          Pointer<NativeType> userdata)>('SDL_SetWindowData');
  final namePointer = name != null ? name.toNativeUtf8() : nullptr;
  final result = sdlSetWindowDataLookupFunction(window, namePointer, userdata);
  calloc.free(namePointer);
  return result;
}