diff --git a/raylib.ads b/raylib.ads index afe8390..6bb4a4d 100644 --- a/raylib.ads +++ b/raylib.ads @@ -668,21 +668,12 @@ package Raylib is No_Image : Image; - --~type Texture is record - --~Id : Natural := 0; - --~Width : Integer := 0; - --~Height : Integer := 0; - --~Mipmaps : Integer := 1; - --~Format : Pixel_Format := Pixel_Format_None; - --~end record with Convention => C_Pass_By_Copy; - type Texture is record - Id : Natural; - Width : Integer; - Height : Integer; - Mipmaps : Integer; - --~Format : Pixel_Format; - Format : Integer; + Id : Natural := 0; + Width : Integer := 0; + Height : Integer := 0; + Mipmaps : Integer := 1; + Format : Pixel_Format := Pixel_Format_None; end record with Convention => C_Pass_By_Copy; No_Texture : Texture; @@ -824,12 +815,12 @@ package Raylib is Distance : Float := 0.0; Point : Vector_3D := (0.0, 0.0, 0.0); Normal : Vector_3D := (0.0, 0.0, 0.0); - end record; + end record with Convention => C_Pass_By_Copy; type Bounding_Box is record Min : Vector_3D := (0.0, 0.0, 0.0); Max : Vector_3D := (0.0, 0.0, 0.0); - end record; + end record with Convention => C_Pass_By_Copy; type Wave is record Frame_Count : Natural := 0; @@ -837,7 +828,7 @@ package Raylib is Sample_Size : Natural := 0; Channels : Natural := 0; Data : Pointer := null; - end record; + end record with Convention => C_Pass_By_Copy; type Audio_Stream is record Buffer : Pointer := null; @@ -845,14 +836,14 @@ package Raylib is Sample_Rate : Natural := 0; Sample_Size : Natural := 0; Channels : Natural := 0; - end record; + end record with Convention => C_Pass_By_Copy; No_Audio_Stream : Audio_Stream; type Sound is record Stream : Audio_Stream := No_Audio_Stream; Frame_Count : Natural := 0; - end record; + end record with Convention => C_Pass_By_Copy; type Music is record Stream : Audio_Stream := No_Audio_Stream; @@ -860,7 +851,7 @@ package Raylib is Looping : Logical := False; Context_Type : Integer := 0; Context_Data : Pointer := null; - end record; + end record with Convention => C_Pass_By_Copy; type VR_Device_Info is record Horizontal_Resoultion : Integer := 0; @@ -873,7 +864,7 @@ package Raylib is Interpupillary_Distance : Float := 0.0; Lens_Distortion_Values : Float_Array_4 := (0.0, 0.0, 0.0, 0.0); Chroma_Abberation_Correction : Float_Array_4 := (0.0, 0.0, 0.0, 0.0); - end record; + end record with Convention => C_Pass_By_Copy; No_VR_Device_Info : VR_Device_Info; @@ -889,7 +880,7 @@ package Raylib is Right_Screen_Center : Float_Array_2 := (0.0, 0.0); Scale : Float_Array_2 := (0.0, 0.0); Scale_In : Float_Array_2 := (0.0, 0.0); - end record; + end record with Convention => C_Pass_By_Copy; No_VR_Stereo_Config : VR_Stereo_Config; @@ -897,7 +888,7 @@ package Raylib is Capacity : Natural := 0; Count : Natural := 0; Paths : Pointer := null; - end record; + end record with Convention => C_Pass_By_Copy; type Integer_Array_4 is array (0 .. 3) of Integer; @@ -905,13 +896,13 @@ package Raylib is Frame : Natural := 0; Kind : Natural := 0; Parameters : Integer_Array_4 := (0, 0, 0, 0); - end record; + end record with Convention => C_Pass_By_Copy; type Automation_Event_List is record Capacity : Natural := 0; Count : Natural := 0; Events : access Automation_Event := null; - end record; + end record with Convention => C_Pass_By_Copy; ------------------------------------------------------------------------ @@ -2871,6 +2862,8 @@ package Raylib is Convention => C, External_Name => "DrawTexturePro"; + --~RLAPI void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint); + --~procedure DrawTextureNPatch (Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest, Vector2 origin, float rotation, Color tint) with --~Import => True, --~Convention => C, diff --git a/window.adb b/window.adb index 925acd5..79a5b58 100644 --- a/window.adb +++ b/window.adb @@ -1,8 +1,110 @@ -with Raylib; -use Raylib; +--~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; @@ -10,11 +112,17 @@ procedure Window is 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_Exit_Key (Key_Q); -- Default is Key_Escape Set_Target_FPS (72); -- Default is 60 Dragdown := Load_Texture ("./texture.png" & Character'Val (0)); @@ -24,28 +132,30 @@ begin -- Begin_Drawing; -- - Clear_Background (Sky_Blue); + Clear_Background (16#FFFFCCFF#); -- - Draw_Texture (Dragdown, (Get_Screen_Width - Dragdown.Width) / 2, (Get_Screen_Height - Dragdown.Height) / 2); - Draw_Texture (Dragdown, 100, 100, White); - Draw_Texture_Pro (Dragdown, (0.0, 0.0, 420.0, 420.0), (200.0, 0.0, 420.0, 420.0)); + --~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, Light_Gray); - Draw_Text (Text, 30, 30, 32, Black); - Draw_Text_Pro (Get_Font_Default, Text, (90.0, 90.0), (9.0, 9.0), 0.0, 32.0, 4.0, Red); - Draw_FPS (60, 60); - Draw_Line (0, 0, 300, 300, Red); - Draw_Rectangle (120, 120, 30, 60, Green); - 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; + --~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;