Created
April 6, 2018 11:31
-
-
Save Lucretia/eb48629943b409842e047f09b0a8a319 to your computer and use it in GitHub Desktop.
Test Blit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Blit_Scaled | |
-- | |
-- Self : The destination surface to blit onto. | |
-- Self_Area : The coordinates and size of the area to blit into. | |
-- Source : The surface to blit onto Self. | |
-- Source_Area : The coordinates and size of the area to blit from. | |
procedure Blit_Scaled (Self : in out Surface; | |
Self_Area : in out Rectangles.Rectangle; | |
Source : in Surface; | |
Source_Area : in Rectangles.Rectangle := Rectangles.Null_Rectangle) is | |
function SDL_Blit_Scaled (S : in Internal_Surface_Pointer; | |
SR : access Rectangles.Rectangle; | |
D : in Internal_Surface_Pointer; | |
DR : access Rectangles.Rectangle) return C.int with | |
Import => True, | |
Convention => C, | |
External_Name => "SDL_UpperBlitScaled"; -- SDL_BlitScaled is a macro in SDL_surface.h | |
use type Rectangles.Rectangle; | |
Result : C.int := 0; | |
Area : aliased Rectangles.Rectangle := Self_Area; | |
begin | |
if Self_Area = Rectangles.Null_Rectangle then | |
if Source_Area = Rectangles.Null_Rectangle then | |
Result := SDL_Blit_Scaled (Source.Internal, null, Self.Internal, null); | |
else | |
Result := SDL_Blit_Scaled (Source.Internal, Source_Area'Access, Self.Internal, null); | |
end if; | |
else | |
if Source_Area = Rectangles.Null_Rectangle then | |
Result := SDL_Blit_Scaled (Source.Internal, null, Self.Internal, Area'Access); | |
else | |
Result := SDL_Blit_Scaled (Source.Internal, Source_Area'Access, Self.Internal, Area'Access); | |
end if; | |
Self_Area := Area; | |
end if; | |
if Result /= SDL.Success then | |
raise Surface_Error with SDL.Error.Get; | |
end if; | |
end Blit_Scaled; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment