sdlSetSurfaceColorKey function surface

bool sdlSetSurfaceColorKey(
  1. Pointer<SdlSurface> surface,
  2. bool enabled,
  3. int key
)

Set the color key (transparent pixel) in a surface.

The color key defines a pixel value that will be treated as transparent in a blit. For example, one can use this to specify that cyan pixels should be considered transparent, and therefore not rendered.

It is a pixel of the format used by the surface, as generated by SDL_MapRGB().

\param surface the SDL_Surface structure to update. \param enabled true to enable color key, false to disable color key. \param key the transparent pixel. \returns true on success or false on failure; call SDL_GetError() for more information.

\threadsafety This function is not thread safe.

\since This function is available since SDL 3.2.0.

\sa SDL_GetSurfaceColorKey \sa SDL_SetSurfaceRLE \sa SDL_SurfaceHasColorKey

extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceColorKey(SDL_Surface *surface, bool enabled, Uint32 key)

Implementation

bool sdlSetSurfaceColorKey(Pointer<SdlSurface> surface, bool enabled, int key) {
  final sdlSetSurfaceColorKeyLookupFunction = _libSdl
      .lookupFunction<
        Uint8 Function(Pointer<SdlSurface> surface, Uint8 enabled, Uint32 key),
        int Function(Pointer<SdlSurface> surface, int enabled, int key)
      >('SDL_SetSurfaceColorKey');
  return sdlSetSurfaceColorKeyLookupFunction(surface, enabled ? 1 : 0, key) ==
      1;
}