You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In rust bindings we don't have a way to update the color 1, unless we resort to using unsafe rust and mimic the C code:
unsafe {
let color = SDL_Color {
r: 0xff,
g: 0xff,
b: 0xff,
a: 0xff,
};
let mut colors = vec![color];
let sdl_surface = *surface.raw();
let pal = (*sdl_surface.format).palette;
let colors_ptr = (&mut colors [0]) as *mut SDL_Color;
sys::SDL_SetPaletteColors(pal, colors_ptr, 1, 1);
};
To solve this issue, we may need two new functions: one to retrieve the palette in the Surface struct and other to update the palette based on SDL_SetPaletteColors. @Cobrand
The text was updated successfully, but these errors were encountered:
Say we have a palette with 4 colors. This palette is used by a surface. If I wanted to modify color 1, I would do something like this in C:
In rust bindings we don't have a way to update the color 1, unless we resort to using unsafe rust and mimic the C code:
To solve this issue, we may need two new functions: one to retrieve the palette in the Surface struct and other to update the palette based on SDL_SetPaletteColors.
@Cobrand
The text was updated successfully, but these errors were encountered: