168 lines
6.7 KiB
Ada
168 lines
6.7 KiB
Ada
--~with Raylib;
|
|
--~use Raylib;
|
|
|
|
procedure Window is
|
|
|
|
type colour_range is range 0 .. 2 ** 32 - 1;
|
|
--
|
|
--~type Rectangle is record x, y, width, height : float; end record with convention => c_pass_by_copy;
|
|
--~type Vector_2D is record x, y : float; end record with convention => c_pass_by_copy;
|
|
--~type Texture is record id : natural; width, height, mipmaps, format : integer; end record with convention => c_pass_by_copy;
|
|
--~type Font is record baseSize, glyphCount, glyphPadding : integer; id : Texture; recs, glyphs : access integer; end record with convention => c_pass_by_copy;
|
|
--
|
|
|
|
type Vector_2D is record
|
|
X : Float := 0.0;
|
|
Y : Float := 0.0;
|
|
end record with Convention => C_Pass_By_Copy;
|
|
|
|
type Rectangle is record
|
|
X : Float := 0.0;
|
|
Y : Float := 0.0;
|
|
Width : Float := 0.0;
|
|
Height : Float := 0.0;
|
|
end record with Convention => C_Pass_By_Copy;
|
|
|
|
No_Rectangle : Rectangle;
|
|
|
|
type Texture is record
|
|
Id : Natural := 0;
|
|
Width : Integer := 0;
|
|
Height : Integer := 0;
|
|
Mipmaps : Integer := 1;
|
|
Format : Integer := 3;
|
|
end record with Convention => C_Pass_By_Copy;
|
|
|
|
No_Texture : Texture;
|
|
|
|
type Glyph_Info is record
|
|
Value : Integer := 0;
|
|
Offset_X : Integer := 0;
|
|
Offset_Y : Integer := 0;
|
|
Advance_X : Integer := 0;
|
|
Data : access Integer := null;
|
|
end record with Convention => C_Pass_By_Copy;
|
|
|
|
type Font is record
|
|
Base_Size : Integer := 0;
|
|
Glyph_Count : Integer := 0;
|
|
Glyph_Padding : Integer := 0;
|
|
Data : Texture := No_Texture;
|
|
Rectangles : access Rectangle := null;
|
|
Glyphs : access Glyph_Info := null;
|
|
end record with Convention => C_Pass_By_Copy;
|
|
|
|
--
|
|
procedure Open_Window (width, height : in integer; title : in string) with import => true, convention => c, external_name => "InitWindow";
|
|
procedure Close_Window with import => true, convention => c, external_name => "CloseWindow";
|
|
procedure Begin_Drawing with import => true, convention => c, external_name => "BeginDrawing";
|
|
procedure End_Drawing with import => true, convention => c, external_name => "EndDrawing";
|
|
--
|
|
procedure Clear_Background (pallete : in colour_range) with import => true, convention => c, external_name => "ClearBackground";
|
|
procedure Set_Target_FPS (framerate : in integer) with import => true, convention => c, external_name => "SetTargetFPS";
|
|
function Window_Should_Close return Boolean with import => true, convention => c, external_name => "WindowShouldClose";
|
|
--
|
|
function Get_Screen_Width return integer with import => true, convention => c, external_name => "GetScreenWidth";
|
|
function Get_Screen_Height return integer with import => true, convention => c, external_name => "GetScreenHeight";
|
|
--
|
|
function Load_Texture (file_path : in string) return Texture with import => true, convention => c, external_name => "LoadTexture";
|
|
--
|
|
procedure Unload_Texture (data : in Texture) with import => true, convention => c, external_name => "UnloadTexture";
|
|
--
|
|
--~procedure Draw_Texture_Pro (data : in Texture; s, d : in rectangle; o : in Vector_2D; rotation : in float; tint : in colour_range) with import => true, convention => c, external_name => "DrawTexturePro";
|
|
procedure Draw_Text_Pro (data : in Font; text : in string; p, o : in Vector_2D; r, t, s : in float; tint : in colour_range) with import => true, convention => c, external_name => "DrawTextPro";
|
|
procedure Draw_Line (x1, y1, x2, y2 : in integer; tint : in colour_range) with import => true, convention => c, external_name => "DrawLine";
|
|
--
|
|
|
|
type Color_Range is range 0 .. 2**8 - 1;
|
|
type Index_Range is range 0 .. 2**16 - 1;
|
|
|
|
type Color is record
|
|
R : Color_Range := 255;
|
|
G : Color_Range := 255;
|
|
B : Color_Range := 255;
|
|
A : Color_Range := 255;
|
|
end record with Convention => C_Pass_By_Copy;
|
|
|
|
White : constant Color := (255, 255, 255, 255);
|
|
|
|
procedure Draw_Texture_Pro (
|
|
Data : Texture := No_Texture;
|
|
Source : Rectangle := No_Rectangle;
|
|
Destination : Rectangle := No_Rectangle;
|
|
Origin : Vector_2D := (0.0, 0.0);
|
|
Rotation : Float := 0.0;
|
|
--~Tint : Colour_range := 16#FFFFFFFF#
|
|
Tint : Color := White
|
|
) with
|
|
Import => True,
|
|
Convention => C,
|
|
External_Name => "DrawTexturePro";
|
|
|
|
--
|
|
function Get_Font_Default return Font with
|
|
Import => True,
|
|
Convention => C,
|
|
External_Name => "GetFontDefault";
|
|
|
|
Text : String := "Heyo world!" & Character'Val (0);
|
|
|
|
Dragdown : Texture;
|
|
|
|
X : Integer := 120;
|
|
Y : Integer := 120;
|
|
|
|
procedure Draw (Data : Texture) is
|
|
begin
|
|
Draw_Texture_Pro (Data, (0.0, 0.0, 420.0, 420.0), (200.0, 0.0, 420.0, 420.0), (0.0, 0.0), 0.0, (240, 240, 240, 255));
|
|
--~Draw_Texture_Pro (Data, (0.0, 0.0, 420.0, 420.0), (200.0, 0.0, 420.0, 420.0), (0.0, 0.0), 0.0, 16#CCCCCCCC#);
|
|
end Draw;
|
|
|
|
begin
|
|
|
|
Open_Window (720, 360, "Heyo Raylib!" & Character'Val (0));
|
|
|
|
--~Set_Exit_Key (Key_Q); -- Default is Key_Escape
|
|
Set_Target_FPS (72); -- Default is 60
|
|
|
|
Dragdown := Load_Texture ("./texture.png" & Character'Val (0));
|
|
|
|
Main_Loop: loop
|
|
exit when Window_Should_Close;
|
|
--
|
|
Begin_Drawing;
|
|
--
|
|
Clear_Background (16#FFFFCCFF#);
|
|
--
|
|
--~Draw_Texture (Dragdown, (Get_Screen_Width - Dragdown.Width) / 2, (Get_Screen_Height - Dragdown.Height) / 2);
|
|
--~Draw_Texture (Dragdown, 100, 100, 16#FFFFFFFF#);
|
|
Draw_Texture_Pro (Dragdown, (0.0, 0.0, 420.0, 420.0), (200.0, 0.0, 420.0, 420.0), (0.0, 0.0), 0.0, White);
|
|
--~Draw_Texture_Pro (Dragdown, (0.0, 0.0, 420.0, 420.0), (100.0, 0.0, 42.0, 42.0), (0.0, 0.0), 0.0, 16#FFFFFFFF#);
|
|
Draw (Dragdown);
|
|
--~Data : Texture := No_Texture;
|
|
--~Source : Rectangle := No_Rectangle;
|
|
--~Destination : Rectangle := No_Rectangle;
|
|
--~Origin : Vector_2D := (0.0, 0.0);
|
|
--~Rotation : Float := 0.0;
|
|
--~Tint : Color := White
|
|
--~Draw_Text ("Heyo world!" & Character'Val (0), 30, 30, 32, 16#FFCCCCFF#);
|
|
--~Draw_Text (Text, 30, 30, 32, 16#FFCCCCFF#);
|
|
Draw_Text_Pro (Get_Font_Default, Text, (90.0, 90.0), (9.0, 9.0), 0.0, 32.0, 4.0, 16#FF2222FF#);
|
|
--~Draw_FPS (60, 60);
|
|
Draw_Line (0, 0, 300, 300, 16#FFCCCCFF#);
|
|
--~Draw_Rectangle (120, 120, 30, 60, 16#FFCCCCFF#);
|
|
--~Draw_FPS (X, Y);
|
|
--~if Is_Key_Pressed (Key_W) then Y := Y - 10; end if;
|
|
--~if Is_Key_Pressed (Key_S) then Y := Y + 10; end if;
|
|
--~if Is_Key_Pressed (Key_A) then X := X - 10; end if;
|
|
--~if Is_Key_Pressed (Key_D) then X := X + 10; end if;
|
|
--
|
|
End_Drawing;
|
|
end loop Main_Loop;
|
|
|
|
Unload_Texture (Dragdown);
|
|
|
|
Close_Window;
|
|
|
|
end Window;
|