joyrider
22-12-2003, 03:25 AM
Hi,
I've been fiddling around with SDL and tried to find a way to rotate the palette of a surface, the code below is what i've come up with.
it works for 8 bit surfaces when not running fullscreen, but as soon as i use it on fullscreen, it crashes !
Oh and is this copymemory call i use the good way ? thanks
procedure SDL_MovePalette(Surface : PSDL_Surface; Movedown : boolean);
var
Pal : TSDL_ColorArray;
Temp : TSDL_Color;
Tel : UInt32;
begin
// Get the current palette from the surface
CopyMemory(@Pal,Surface.Format.Palette.Colors,Leng th(pal));
if Movedown then
begin
Temp := Pal[Surface.Format.Palette.NColors-1];
for Tel := Surface.Format.Palette.NColors -2 downto 0 do Pal[Tel+1] := Pal[Tel];
Pal[0] := Temp;
end
else
begin
Temp := Pal[0];
for Tel := 0 to Surface.Format.Palette.NColors -2 do Pal[tel] := Pal[tel+1];
Pal[Surface.Format.Palette.NColors-1] := Temp;
end;
SDL_SetPalette(Surface,SDL_LOGPAL or SDL_PHYSPAL,@Pal,0,Surface.Format.Palette.NColors) ;
end;
I've been fiddling around with SDL and tried to find a way to rotate the palette of a surface, the code below is what i've come up with.
it works for 8 bit surfaces when not running fullscreen, but as soon as i use it on fullscreen, it crashes !
Oh and is this copymemory call i use the good way ? thanks
procedure SDL_MovePalette(Surface : PSDL_Surface; Movedown : boolean);
var
Pal : TSDL_ColorArray;
Temp : TSDL_Color;
Tel : UInt32;
begin
// Get the current palette from the surface
CopyMemory(@Pal,Surface.Format.Palette.Colors,Leng th(pal));
if Movedown then
begin
Temp := Pal[Surface.Format.Palette.NColors-1];
for Tel := Surface.Format.Palette.NColors -2 downto 0 do Pal[Tel+1] := Pal[Tel];
Pal[0] := Temp;
end
else
begin
Temp := Pal[0];
for Tel := 0 to Surface.Format.Palette.NColors -2 do Pal[tel] := Pal[tel+1];
Pal[Surface.Format.Palette.NColors-1] := Temp;
end;
SDL_SetPalette(Surface,SDL_LOGPAL or SDL_PHYSPAL,@Pal,0,Surface.Format.Palette.NColors) ;
end;