Sdl2 custom shaped windows

I have found the function SDL_SetWindowShape but can't figure out how to call that function when creating a window.
I've tried building a window and a surface with the shape I want and doing:

sdl2::sys::SDL_SetWindowShape(window,surface, sdl2::sys::SDL_WindowShapeMode { 
    mode: sdl2::sys::WindowShapeMode::ShapeModeDefault,
    parameters: sdl2::sys::SDL_WindowShapeParams {
        binarizationCutoff: 1, 
        colorKey: sdl2::sys::SDL_Color { 
            r: 255, 
            g: 0, 
            b: 0, 
            a: 255
        }, 
    }, 
});

but this gives the following errors for each param:

window,
   |         ^^^^^^ expected *-ptr, found struct `sdl2::video::Window`
   |
   = note: expected type `*mut sdl2::sdl2_sys::SDL_Window`
              found type `sdl2::video::Window`
surface,
   |         ^^^^^^^^ expected *-ptr, found struct `sdl2::surface::Surface`
   |
   = note: expected type `*mut sdl2::sdl2_sys::SDL_Surface`
              found type `sdl2::surface::Surface<'_>`
  --> src/main.rs:68:9
   |
68 | /         sdl2::sys::SDL_WindowShapeMode {
69 | |             mode: sdl2::sys::WindowShapeMode::ShapeModeDefault,
70 | |             parameters: sdl2::sys::SDL_WindowShapeParams {
71 | |                 binarizationCutoff: 1,
...  |
78 | |             },
79 | |         },
   | |_________^ expected *-ptr, found struct `sdl2::sdl2_sys::SDL_WindowShapeMode`
   |
   = note: expected type `*mut sdl2::sdl2_sys::SDL_WindowShapeMode`
              found type `sdl2::sdl2_sys::SDL_WindowShapeMode`

As well as an error for the parameters field: union expressions should have exactly one field, that I don't understand.

My window and surface variables are declared mutable at initiation.

How are you supposed to invoke this function?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.