Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement SDL_ConvertSurface #106

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/video/sdl-video-surfaces-makers.adb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ package body SDL.Video.Surfaces.Makers is

procedure Create (Self : in out Surface;
File_Name : in UTF_Strings.UTF_String) is
function SDL_Load_BMP_RW (Src : in SDL.RWops.RWops; freesrc : C.int) return Internal_Surface_Pointer with
function SDL_Load_BMP_RW (Src : in SDL.RWops.RWops; freesrc : C.int) return Internal_Surface_Pointer with
Import => True,
Convention => C,
External_Name => "SDL_LoadBMP_RW";
Expand All @@ -140,6 +140,26 @@ package body SDL.Video.Surfaces.Makers is
Self.Owns := True;
end Create;

procedure Convert (Self : in out Surface;
Src : SDL.Video.Surfaces.Surface;
Pixel_Format : SDL.Video.Pixel_Formats.Pixel_Format_Access) is
function SDL_ConvertSurface
(Src : in SDL.Video.Surfaces.Internal_Surface_Pointer;
Fmt : in SDL.Video.Pixel_Formats.Pixel_Format_Access;
Flags : in C.unsigned) return Internal_Surface_Pointer with
Import => True,
Convention => C,
External_Name => "SDL_ConvertSurface";
Surface : Internal_Surface_Pointer := null;
begin
Surface := SDL_ConvertSurface (Src.Internal, Pixel_Format, 0);
if Surface = null then
raise Surface_Error with SDL.Error.Get;
end if;

Self.Internal := Surface;
Self.Owns := True;
end Convert;

function Get_Internal_Surface (Self : in Surface) return Internal_Surface_Pointer is
begin
Expand Down
5 changes: 4 additions & 1 deletion src/video/sdl-video-surfaces-makers.ads
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ package SDL.Video.Surfaces.Makers is

procedure Create (Self : in out Surface;
File_Name : in UTF_Strings.UTF_String);

procedure Convert (Self : in out Surface;
Src : SDL.Video.Surfaces.Surface;
Pixel_Format : SDL.Video.Pixel_Formats.Pixel_Format_Access);
private
function Get_Internal_Surface (Self : in Surface) return Internal_Surface_Pointer with
Export => True,
Expand All @@ -64,7 +68,6 @@ private
Export => True,
Convention => Ada;

-- TODO: SDL_ConvertSurface
-- TODO: SDL_ConvertSurfaceFormat
-- TODO: SDL_CreateRGBSurfaceFrom
end SDL.Video.Surfaces.Makers;
Loading