sdlxRenderTexture function render

bool sdlxRenderTexture(
  1. Pointer<SdlRenderer> renderer,
  2. Pointer<SdlTexture> texture, {
  3. SdlxFRect? srcrect,
  4. SdlxFRect? 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)

Implementation

bool sdlxRenderTexture(
  Pointer<SdlRenderer> renderer,
  Pointer<SdlTexture> texture, {
  SdlxFRect? srcrect,
  SdlxFRect? dstrect,
}) {
  Pointer<SdlFRect> srcrectPointer = nullptr;
  Pointer<SdlFRect> dstrectPointer = nullptr;
  if (srcrect != null) {
    srcrectPointer = srcrect.calloc();
  }
  if (dstrect != null) {
    dstrectPointer = dstrect.calloc();
  }
  final result = sdlRenderTexture(
    renderer,
    texture,
    srcrectPointer,
    dstrectPointer,
  );
  if (srcrectPointer != nullptr) {
    srcrectPointer.callocFree();
  }
  if (dstrectPointer != nullptr) {
    dstrectPointer.callocFree();
  }
  return result;
}