sdlCreateGpuRenderer function

Pointer<SdlRenderer> sdlCreateGpuRenderer(
  1. Pointer<SdlWindow> window,
  2. int formatFlags,
  3. Pointer<Pointer<SdlGpuDevice>> device
)

Create a 2D GPU rendering context for a window, with support for the specified shader format.

This is a convenience function to create a SDL GPU backed renderer, intended to be used with SDL_GPURenderState. The resulting renderer will support shaders in one of the specified shader formats.

If no available GPU driver supports any of the specified shader formats, this function will fail.

\param window the window where rendering is displayed. \param format_flags a bitflag indicating which shader formats the app is able to provide. \param device a pointer filled with the associated GPU device, or NULL on error. \returns a valid rendering context or NULL if there was an error; 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.4.0.

\sa SDL_CreateRendererWithProperties \sa SDL_GetGPUShaderFormats \sa SDL_CreateGPUShader \sa SDL_CreateGPURenderState \sa SDL_SetRenderGPUState

extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateGPURenderer(SDL_Window *window, SDL_GPUShaderFormat format_flags, SDL_GPUDevice **device)

Implementation

Pointer<SdlRenderer> sdlCreateGpuRenderer(
  Pointer<SdlWindow> window,
  int formatFlags,
  Pointer<Pointer<SdlGpuDevice>> device,
) {
  final sdlCreateGpuRendererLookupFunction = libSdl3
      .lookupFunction<
        Pointer<SdlRenderer> Function(
          Pointer<SdlWindow> window,
          Uint32 formatFlags,
          Pointer<Pointer<SdlGpuDevice>> device,
        ),
        Pointer<SdlRenderer> Function(
          Pointer<SdlWindow> window,
          int formatFlags,
          Pointer<Pointer<SdlGpuDevice>> device,
        )
      >('SDL_CreateGPURenderer');
  return sdlCreateGpuRendererLookupFunction(window, formatFlags, device);
}