+ SDL: getting surface
This commit is contained in:
parent
37161b7a1b
commit
e34a527032
5 changed files with 101 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
with Interfaces.C;
|
||||
with Video.Backends.SDL.Windows;
|
||||
with Video.Backends.SDL.Surfaces;
|
||||
with Video.Backends.SDL.Message_Boxes;
|
||||
use Video.Backends.SDL;
|
||||
|
||||
|
@ -7,10 +8,12 @@ procedure Hello_World_SDL is
|
|||
Screen_Width : constant := 640;
|
||||
Screen_Height : constant := 480;
|
||||
Wnd : Windows.Window_Access;
|
||||
Surf : Surfaces.Surface_Access;
|
||||
Err : Error_Code;
|
||||
begin
|
||||
Wnd := Windows.Create_Window ("Hello World",
|
||||
Width => Screen_Width, Height => Screen_Height);
|
||||
Surf := Windows.Get_Window_Surface (Wnd);
|
||||
|
||||
Err := Message_Boxes.Show_Message_Box (Title => "Hello World", Message => "Greetz!");
|
||||
end Hello_World_SDL;
|
||||
|
|
58
source/backends/sdl/video-backends-sdl-pixels.ads
Normal file
58
source/backends/sdl/video-backends-sdl-pixels.ads
Normal file
|
@ -0,0 +1,58 @@
|
|||
with Interfaces.C.Pointers;
|
||||
|
||||
package Video.Backends.SDL.Pixels is
|
||||
|
||||
subtype Pixel_Format_Id is Unsigned_32;
|
||||
|
||||
type Color is record
|
||||
r : Unsigned_8;
|
||||
g : Unsigned_8;
|
||||
b : Unsigned_8;
|
||||
a : Unsigned_8;
|
||||
end record with Convention => C;
|
||||
|
||||
type Color_Array is array (Natural range <>) of aliased Color with Convention => C;
|
||||
|
||||
package Color_Pointers is new Interfaces.C.Pointers (
|
||||
Index => Natural,
|
||||
Element => Color,
|
||||
Element_Array => Color_Array,
|
||||
Default_Terminator => (0, 0, 0, 0));
|
||||
|
||||
type Palette is record
|
||||
ncolors : C.int;
|
||||
colors : Color_Pointers.Pointer;
|
||||
version : Unsigned_32;
|
||||
refcount : C.int;
|
||||
end record with Convention => C;
|
||||
|
||||
type Palette_Access is access all Palette with Convention => C;
|
||||
|
||||
type Pixel_Format;
|
||||
|
||||
type Pixel_Format_Access is access all Pixel_Format with Convention => C;
|
||||
|
||||
type Pixel_Format is record
|
||||
format : Pixel_Format_Id;
|
||||
palette : Palette_Access;
|
||||
Bits_Per_Pixel : Unsigned_8;
|
||||
Bytes_Per_Pixel : Unsigned_8;
|
||||
padding1,
|
||||
padding2 : Unsigned_8;
|
||||
Rmask : Unsigned_32;
|
||||
Gmask : Unsigned_32;
|
||||
Bmask : Unsigned_32;
|
||||
Amask : Unsigned_32;
|
||||
Rloss : Unsigned_8;
|
||||
Gloss : Unsigned_8;
|
||||
Bloss : Unsigned_8;
|
||||
Aloss : Unsigned_8;
|
||||
Rshift : Unsigned_8;
|
||||
Gshift : Unsigned_8;
|
||||
Bshift : Unsigned_8;
|
||||
Ashift : Unsigned_8;
|
||||
refcount : C.int;
|
||||
next : Pixel_Format_Access;
|
||||
end record with Convention => C;
|
||||
|
||||
end Video.Backends.SDL.Pixels;
|
8
source/backends/sdl/video-backends-sdl-rects.ads
Normal file
8
source/backends/sdl/video-backends-sdl-rects.ads
Normal file
|
@ -0,0 +1,8 @@
|
|||
package Video.Backends.SDL.Rects is
|
||||
|
||||
type Rect is record
|
||||
x, y : C.int;
|
||||
w, h : C.int;
|
||||
end record with Convention => C;
|
||||
|
||||
end Video.Backends.SDL.Rects;
|
26
source/backends/sdl/video-backends-sdl-surfaces.ads
Normal file
26
source/backends/sdl/video-backends-sdl-surfaces.ads
Normal file
|
@ -0,0 +1,26 @@
|
|||
with System;
|
||||
use System;
|
||||
with Video.Backends.SDL.Pixels, Video.Backends.SDL.Rects;
|
||||
use Video.Backends.SDL.Pixels, Video.Backends.SDL.Rects;
|
||||
|
||||
package Video.Backends.SDL.Surfaces is
|
||||
|
||||
subtype Surface_Flags is Unsigned_32;
|
||||
|
||||
type Surface is record
|
||||
flags : Surface_Flags;
|
||||
format : Pixel_Format_Access;
|
||||
w, h : C.int;
|
||||
pitch : C.int;
|
||||
pixels : Address;
|
||||
userdata : Address;
|
||||
locked : C.int;
|
||||
list_blitmap : Address;
|
||||
clip_rect : Rect;
|
||||
map : Address;
|
||||
refcount : C.int;
|
||||
end record with Convention => C;
|
||||
|
||||
type Surface_Access is access all Surface with Convention => C;
|
||||
|
||||
end Video.Backends.SDL.Surfaces;
|
|
@ -1,3 +1,6 @@
|
|||
with Video.Backends.SDL.Surfaces;
|
||||
use Video.Backends.SDL.Surfaces;
|
||||
|
||||
package Video.Backends.SDL.Windows is
|
||||
type Window is private;
|
||||
|
||||
|
@ -24,6 +27,9 @@ package Video.Backends.SDL.Windows is
|
|||
is (SDL_CreateWindow (C.To_C (Title), C.int (X_Left), C.int (Y_Top),
|
||||
C.int (Width), C.int (Height), Flags));
|
||||
|
||||
function Get_Window_Surface (wnd : Window_Access) return Surface_Access
|
||||
with Import, Convention => C, External_Name => "SDL_GetWindowSurface";
|
||||
|
||||
private
|
||||
type Window is null record;
|
||||
|
||||
|
|
Loading…
Reference in a new issue