sdlSetWindowShape function

bool sdlSetWindowShape(
  1. Pointer<SdlWindow> window,
  2. Pointer<SdlSurface> shape
)

Set the shape of a transparent window.

This sets the alpha channel of a transparent window and any fully transparent areas are also transparent to mouse clicks. If you are using something besides the SDL render API, then you are responsible for drawing the alpha channel of the window to match the shape alpha channel to get consistent cross-platform results.

The shape is copied inside this function, so you can free it afterwards. If your shape surface changes, you should call SDL_SetWindowShape() again to update the window. This is an expensive operation, so should be done sparingly.

The window must have been created with the SDL_WINDOW_TRANSPARENT flag.

\param window the window. \param shape the surface representing the shape of the window, or NULL to remove any current shape. \returns true on success or false on failure; 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.1.3.

extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape)

Implementation

bool sdlSetWindowShape(Pointer<SdlWindow> window, Pointer<SdlSurface> shape) {
  final sdlSetWindowShapeLookupFunction = libSdl3.lookupFunction<
      Uint8 Function(Pointer<SdlWindow> window, Pointer<SdlSurface> shape),
      int Function(Pointer<SdlWindow> window,
          Pointer<SdlSurface> shape)>('SDL_SetWindowShape');
  return sdlSetWindowShapeLookupFunction(window, shape) == 1;
}