sdlLoadTexture function render

Pointer<SdlTexture> sdlLoadTexture(
  1. Pointer<SdlRenderer> renderer,
  2. String? file
)

Load a BMP, PNG or JPEG image from a file.

The new texture should be freed with SDL_DestroyTexture(). Not doing so will result in a memory leak.

\param renderer the renderer to use. \param file the file to load. \returns a pointer to a new SDL_Texture structure or NULL on failure; call SDL_GetError() for more information.

\threadsafety It is safe to call this function from any thread.

\since This function is available since SDL 3.6.0.

\sa SDL_DestroyTexture \sa SDL_LoadTexture_IO

extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_LoadTexture(SDL_Renderer *renderer, const char *file)

See also:

Implementation

Pointer<SdlTexture> sdlLoadTexture(
  Pointer<SdlRenderer> renderer,
  String? file,
) {
  final sdlLoadTextureLookupFunction = _libSdl
      .lookupFunction<
        Pointer<SdlTexture> Function(
          Pointer<SdlRenderer> renderer,
          Pointer<ffi.Utf8> file,
        ),
        Pointer<SdlTexture> Function(
          Pointer<SdlRenderer> renderer,
          Pointer<ffi.Utf8> file,
        )
      >('SDL_LoadTexture');
  final filePointer = file != null ? file.toNativeUtf8() : nullptr;
  final result = sdlLoadTextureLookupFunction(renderer, filePointer);
  ffi.calloc.free(filePointer);
  return result;
}