sdlSetAppMetadata function

bool sdlSetAppMetadata(
  1. String? appname,
  2. String? appversion,
  3. String? appidentifier
)

Specify basic metadata about your app.

You can optionally provide metadata about your app to SDL. This is not required, but strongly encouraged.

There are several locations where SDL can make use of metadata (an "About" box in the macOS menu bar, the name of the app can be shown on some audio mixers, etc). Any piece of metadata can be left as NULL, if a specific detail doesn't make sense for the app.

This function should be called as early as possible, before SDL_Init. Multiple calls to this function are allowed, but various state might not change once it has been set up with a previous call to this function.

Passing a NULL removes any previous metadata.

This is a simplified interface for the most important information. You can supply significantly more detailed metadata with SDL_SetAppMetadataProperty().

\param appname The name of the application ("My Game 2: Bad Guy's Revenge!"). \param appversion The version of the application ("1.0.0beta5" or a git hash, or whatever makes sense). \param appidentifier A unique string in reverse-domain format that identifies this app ("com.example.mygame2"). \returns true on success or false on failure; call SDL_GetError() for more information.

\threadsafety It is safe to call this function from any thread.

\since This function is available since SDL 3.1.3.

\sa SDL_SetAppMetadataProperty

extern SDL_DECLSPEC bool SDLCALL SDL_SetAppMetadata(const char *appname, const char *appversion, const char *appidentifier)

Implementation

bool sdlSetAppMetadata(
    String? appname, String? appversion, String? appidentifier) {
  final sdlSetAppMetadataLookupFunction = libSdl3.lookupFunction<
      Uint8 Function(Pointer<Utf8> appname, Pointer<Utf8> appversion,
          Pointer<Utf8> appidentifier),
      int Function(Pointer<Utf8> appname, Pointer<Utf8> appversion,
          Pointer<Utf8> appidentifier)>('SDL_SetAppMetadata');
  final appnamePointer = appname != null ? appname.toNativeUtf8() : nullptr;
  final appversionPointer =
      appversion != null ? appversion.toNativeUtf8() : nullptr;
  final appidentifierPointer =
      appidentifier != null ? appidentifier.toNativeUtf8() : nullptr;
  final result = sdlSetAppMetadataLookupFunction(
          appnamePointer, appversionPointer, appidentifierPointer) ==
      1;
  calloc.free(appnamePointer);
  calloc.free(appversionPointer);
  calloc.free(appidentifierPointer);
  return result;
}