texture method

bool texture(
  1. Pointer<SdlTexture> texture, {
  2. Rectangle<double>? srcrect,
  3. Rectangle<double>? dstrect,
})

Copy a portion of the texture to the current rendering target at subpixel precision.

\param renderer the renderer which should copy parts of a texture. \param texture the source texture. \param srcrect a pointer to the source rectangle, or NULL for the entire texture. \param dstrect a pointer to the destination rectangle, or NULL for the entire rendering target. \returns true on success or false on failure; call SDL_GetError() for more information.

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

\since This function is available since SDL 3.2.0.

\sa SDL_RenderTextureRotated \sa SDL_RenderTextureTiled

extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, const SDL_FRect *dstrect)

{@category render}

Implementation

bool texture(
  Pointer<SdlTexture> texture, {
  math.Rectangle<double>? srcrect,
  math.Rectangle<double>? dstrect,
}) {
  Pointer<SdlFRect> srcrectPointer = nullptr;
  Pointer<SdlFRect> dstrectPointer = nullptr;
  if (srcrect != null) {
    srcrectPointer = srcrect.calloc();
  }
  if (dstrect != null) {
    dstrectPointer = dstrect.calloc();
  }
  final result = sdlRenderTexture(
    this,
    texture,
    srcrectPointer,
    dstrectPointer,
  );
  calloc
    ..free(srcrectPointer)
    ..free(dstrectPointer);
  return result;
}