+ SDL surface / raster conversion
This commit is contained in:
parent
e34a527032
commit
4f813935e3
|
@ -1,3 +1,5 @@
|
|||
with Ada.Text_IO, Ada.Integer_Text_IO;
|
||||
use Ada.Text_IO, Ada.Integer_Text_IO;
|
||||
with Interfaces.C;
|
||||
with Video.Backends.SDL.Windows;
|
||||
with Video.Backends.SDL.Surfaces;
|
||||
|
@ -15,5 +17,10 @@ begin
|
|||
Width => Screen_Width, Height => Screen_Height);
|
||||
Surf := Windows.Get_Window_Surface (Wnd);
|
||||
|
||||
Put (Integer (Surf.w)); Put (" × "); Put (Integer (Surf.h)); New_Line;
|
||||
Put ("Pitch: "); Put (Integer (Surf.pitch)); New_Line;
|
||||
Put ("Bits per pixel: "); Put (Integer (Surf.format.Bits_Per_Pixel)); New_Line;
|
||||
Put ("Bytes per pixel: "); Put (Integer (Surf.format.Bytes_Per_Pixel)); New_Line;
|
||||
|
||||
Err := Message_Boxes.Show_Message_Box (Title => "Hello World", Message => "Greetz!");
|
||||
end Hello_World_SDL;
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
with Interfaces.C.Pointers;
|
||||
with System.Storage_Elements;
|
||||
use System.Storage_Elements;
|
||||
|
||||
package body Video.Backends.SDL.Surfaces is
|
||||
|
||||
package body Raster_Conversions is
|
||||
|
||||
type Pixel_Array is array (Integer range <>) of Pixel;
|
||||
|
||||
procedure Copy (
|
||||
Source : in Raster;
|
||||
Target : in out Surface)
|
||||
is
|
||||
begin
|
||||
for Y in Source'Range (1) loop
|
||||
declare
|
||||
Line : Pixel_Array (Source'Range (2)) with
|
||||
Import, Address => Target.Pixels
|
||||
+ Storage_Offset (Y - Source'First (1));
|
||||
begin
|
||||
for X in Source'Range (2) loop
|
||||
Line (X) := Source (Y, X);
|
||||
end loop;
|
||||
end;
|
||||
end loop;
|
||||
end;
|
||||
end Raster_Conversions;
|
||||
|
||||
end Video.Backends.SDL.Surfaces;
|
|
@ -23,4 +23,19 @@ package Video.Backends.SDL.Surfaces is
|
|||
|
||||
type Surface_Access is access all Surface with Convention => C;
|
||||
|
||||
generic
|
||||
type Pixel is private;
|
||||
type Raster is array (Integer range <>, Integer range <>) of aliased Pixel;
|
||||
Default : Pixel;
|
||||
package Raster_Conversions is
|
||||
procedure Copy (
|
||||
Source : in Raster;
|
||||
Target : in out Surface)
|
||||
with
|
||||
Pre => Source'Length (1) = Target.h
|
||||
and Source'Length (2) = Target.w
|
||||
and Target.format.Bits_Per_Pixel = Pixel'Size;
|
||||
-- Copy video raster to sdl surface. Source and target should have same dimensions
|
||||
end Raster_Conversions;
|
||||
|
||||
end Video.Backends.SDL.Surfaces;
|
||||
|
|
Loading…
Reference in New Issue