sdlCreateGpuDevice function gpu

Pointer<SdlGpuDevice> sdlCreateGpuDevice(
  1. int formatFlags,
  2. bool debugMode,
  3. String? name
)

Creates a GPU context.

The GPU driver name can be one of the following:

  • "vulkan": Vulkan
  • "direct3d12": D3D12
  • "metal": Metal
  • NULL: let SDL pick the optimal driver

\param format_flags a bitflag indicating which shader formats the app is able to provide. \param debug_mode enable debug mode properties and validations. \param name the preferred GPU driver, or NULL to let SDL pick the optimal driver. \returns a GPU context on success or NULL on failure; call SDL_GetError() for more information.

\since This function is available since SDL 3.2.0.

\sa SDL_CreateGPUDeviceWithProperties \sa SDL_GetGPUShaderFormats \sa SDL_GetGPUDeviceDriver \sa SDL_DestroyGPUDevice \sa SDL_GPUSupportsShaderFormats

extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_CreateGPUDevice( SDL_GPUShaderFormat format_flags, bool debug_mode, const char *name)

Implementation

Pointer<SdlGpuDevice> sdlCreateGpuDevice(
  int formatFlags,
  bool debugMode,
  String? name,
) {
  final sdlCreateGpuDeviceLookupFunction = _libSdl
      .lookupFunction<
        Pointer<SdlGpuDevice> Function(
          Uint32 formatFlags,
          Uint8 debugMode,
          Pointer<Utf8> name,
        ),
        Pointer<SdlGpuDevice> Function(
          int formatFlags,
          int debugMode,
          Pointer<Utf8> name,
        )
      >('SDL_CreateGPUDevice');
  final namePointer = name != null ? name.toNativeUtf8() : nullptr;
  final result = sdlCreateGpuDeviceLookupFunction(
    formatFlags,
    debugMode ? 1 : 0,
    namePointer,
  );
  calloc.free(namePointer);
  return result;
}