sdlCreateGpuDevice function

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

Creates a GPU context.

\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.1.3.

\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 = libSdl3.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;
}