]> git.xolatile.top Git - xolatile-raylib-ada.git/commitdiff
Finished limiting Color to 4 bytes like Gott intended...
authorxolatile <xolatile@proton.me>
Mon, 18 Mar 2024 18:40:43 +0000 (14:40 -0400)
committerxolatile <xolatile@proton.me>
Mon, 18 Mar 2024 18:40:43 +0000 (14:40 -0400)
raylib.ads
window.adb

index 6bb4a4d130b2ee4e353b6b7398aa45b8d49a070a..e1a2e20625e64cc4f2fbfef49c86c69a8fee55b5 100644 (file)
@@ -601,6 +601,9 @@ package Raylib is
        type Color_Range is range 0 .. 2**8  - 1;
        type Index_Range is range 0 .. 2**16 - 1;
 
+       for Color_Range'Size use 8;
+       for Index_Range'Size use 16;
+
        type Pointer is access all System.Address;
 
        type Vector_2D is record
index 79a5b5803f49da8bf8c474e609b3aaa3c781615d..55035f41c7eac6f9772bef238bc7194a59b7f051 100644 (file)
@@ -1,110 +1,8 @@
---~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;
@@ -112,17 +10,11 @@ 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));
@@ -132,30 +24,18 @@ begin
                --
                Begin_Drawing;
                --
-               Clear_Background (16#FFFFCCFF#);
+               Clear_Background (Sky_Blue);
+               --
+               Draw_Texture     (Dragdown, 100, 100, White);
+               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, Black);
+               Draw_Rectangle   (120, 120, 30, 60, Blue);
                --
-               --~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;
+               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;