1. -- 
  2. -- Copyright (c) 2013 Kevin Wellwood 
  3. -- All rights reserved. 
  4. -- 
  5. -- This source code is distributed under the Modified BSD License. For terms and 
  6. -- conditions, see license.txt. 
  7. -- 
  8.  
  9. with Allegro.Bitmaps;                   use Allegro.Bitmaps; 
  10. with Interfaces;                        use Interfaces; 
  11. with System;                            use System; 
  12.  
  13. -- Allegro 5.0.9 - Primitives addon 
  14. package Allegro.Drawing.Primitives is 
  15.  
  16.     -- Initialization 
  17.  
  18.     function Al_Init_Primitives_Addon return Boolean; 
  19.  
  20.     procedure Al_Shutdown_Primitives_Addon; 
  21.     pragma Import( C, Al_Shutdown_Primitives_Addon, "al_shutdown_primitives_addon" ); 
  22.  
  23.     function Al_Get_Allegro_Primitives_Version return Unsigned_32; 
  24.     pragma Import( C, Al_Get_Allegro_Primitives_Version, "al_get_allegro_primitives_version" ); 
  25.  
  26.     -- High level drawing structures 
  27.  
  28.     type Point_2D is 
  29.         record 
  30.             x, y : Float; 
  31.         end record; 
  32.     pragma Convention( C, Point_2D ); 
  33.  
  34.     type Point_2D_Array is array (Integer range <>) of Point_2D; 
  35.     pragma Convention( C, Point_2D_Array ); 
  36.  
  37.     -- High level drawing routines 
  38.  
  39.     procedure Al_Draw_Line( x1, y1, 
  40.                             x2, y2    : Float; 
  41.                             color     : Allegro_Color; 
  42.                             thickness : Float ); 
  43.     pragma Import( C, Al_Draw_Line, "al_draw_line" ); 
  44.  
  45.     procedure Al_Draw_Triangle( x1, y1, 
  46.                                 x2, y2, 
  47.                                 x3, y3    : Float; 
  48.                                 color     : Allegro_Color; 
  49.                                 thickness : Float ); 
  50.     pragma Import( C, Al_Draw_Triangle, "al_draw_triangle" ); 
  51.  
  52.     procedure Al_Draw_Rectangle( x1, y1, 
  53.                                  x2, y2    : Float; 
  54.                                  color     : Allegro_Color; 
  55.                                  thickness : Float ); 
  56.     pragma Import( C, Al_Draw_Rectangle, "al_draw_rectangle" ); 
  57.  
  58.     procedure Al_Draw_Rounded_Rectangle( x1, y1, 
  59.                                          x2, y2    : Float; 
  60.                                          rx, ry    : Float; 
  61.                                          color     : Allegro_Color; 
  62.                                          thickness : Float ); 
  63.     pragma Import( C, Al_Draw_Rounded_Rectangle, "al_draw_rounded_rectangle" ); 
  64.  
  65.     procedure Al_Calculate_Arc( dest         : Address; 
  66.                                 stride       : Integer; 
  67.                                 cx, cy       : Float; 
  68.                                 rx, ry       : Float; 
  69.                                 start_theta  : Float; 
  70.                                 delta_theta  : Float; 
  71.                                 thickness    : Float; 
  72.                                 num_segments : Integer ); 
  73.     pragma Import( C, Al_Calculate_Arc, "al_calculate_arc" ); 
  74.  
  75.     procedure Al_Calculate_Arc( dest        : Point_2D_Array; 
  76.                                 cx, cy      : Float; 
  77.                                 rx, ry      : Float; 
  78.                                 start_theta : Float; 
  79.                                 delta_theta : Float; 
  80.                                 thickness   : Float ); 
  81.     pragma Precondition( dest'Length > 0 ); 
  82.     pragma Precondition( thickness <= 0.0 or else dest'Length mod 2 = 0 ); 
  83.  
  84.     procedure Al_Draw_Circle( cx, cy    : Float; 
  85.                               r         : Float; 
  86.                               color     : Allegro_Color; 
  87.                               thickness : Float ); 
  88.     pragma Import( C, Al_Draw_Circle, "al_draw_circle" ); 
  89.  
  90.     procedure Al_Draw_Ellipse( cx, cy    : Float; 
  91.                                rx, ry    : Float; 
  92.                                color     : Allegro_Color; 
  93.                                thickness : Float ); 
  94.     pragma Import( C, Al_Draw_Ellipse, "al_draw_ellipse" ); 
  95.  
  96.     procedure Al_Draw_Arc( cx, cy      : Float; 
  97.                            r           : Float; 
  98.                            start_theta : Float; 
  99.                            delta_theta : Float; 
  100.                            color       : Allegro_Color; 
  101.                            thickness   : Float ); 
  102.     pragma Import( C, Al_Draw_Arc, "al_draw_arc" ); 
  103.  
  104.     procedure Al_Draw_Elliptical_Arc( cx, cy      : Float; 
  105.                                       rx, ry      : Float; 
  106.                                       start_theta : Float; 
  107.                                       delta_theta : Float; 
  108.                                       color       : Allegro_Color; 
  109.                                       thickness   : Float ); 
  110.     pragma Import( C, Al_Draw_Elliptical_Arc, "al_draw_elliptical_arc" ); 
  111.  
  112.     procedure Al_Draw_Pieslice( cx, cy      : Float; 
  113.                                 r           : Float; 
  114.                                 start_theta : Float; 
  115.                                 delta_theta : Float; 
  116.                                 color       : Allegro_Color; 
  117.                                 thickness   : Float ); 
  118.     pragma Import( C, Al_Draw_Pieslice, "al_draw_pieslice" ); 
  119.  
  120.     procedure Al_Calculate_Spline( dest         : Address; 
  121.                                    stride       : Integer; 
  122.                                    points       : Address; 
  123.                                    thickness    : Float; 
  124.                                    num_segments : Integer ); 
  125.     pragma Import( C, Al_Calculate_Spline, "al_calculate_spline" ); 
  126.  
  127.     procedure Al_Calculate_Spline( dest      : Point_2D_Array; 
  128.                                    points    : Point_2D_Array; 
  129.                                    thickness : Float ); 
  130.     pragma Precondition( dest'Length > 0 ); 
  131.     pragma Precondition( thickness <= 0.0 or else dest'Length mod 2 = 0 ); 
  132.     pragma Precondition( points'Length = 4 ); 
  133.  
  134.     procedure Al_Draw_Spline( points    : Address; 
  135.                               color     : Allegro_Color; 
  136.                               thickness : Float ); 
  137.     pragma Import( C, Al_Draw_Spline, "al_draw_spline" ); 
  138.  
  139.     procedure Al_Draw_Spline( points    : Point_2D_Array; 
  140.                               color     : Allegro_Color; 
  141.                               thickness : Float ); 
  142.     pragma Precondition( points'Length = 4 ); 
  143.  
  144.     procedure Al_Calculate_Ribbon( dest          : Address; 
  145.                                    dest_stride   : Integer; 
  146.                                    points        : Address; 
  147.                                    points_stride : Integer; 
  148.                                    thickness     : Float; 
  149.                                    num_segments  : Integer ); 
  150.     pragma Import( C, Al_Calculate_Ribbon, "al_calculate_ribbon" ); 
  151.  
  152.     procedure Al_Calculate_Ribbon( dest      : Point_2D_Array; 
  153.                                    points    : Point_2D_Array; 
  154.                                    thickness : Float ); 
  155.     pragma Precondition( dest'Length > 0 ); 
  156.     pragma Precondition( points'Length > 0 ); 
  157.     pragma Precondition( (thickness <= 0.0 and then dest'Length = points'Length) or else 
  158.                          (thickness >  0.0 and then dest'Length = points'Length * 2) ); 
  159.  
  160.     procedure Al_Draw_Ribbon( points       : Address; 
  161.                               stride       : Integer; 
  162.                               color        : Allegro_Color; 
  163.                               thickness    : Float; 
  164.                               num_segments : Integer ); 
  165.     pragma Import( C, Al_Draw_Ribbon, "al_draw_ribbon" ); 
  166.  
  167.     procedure Al_Draw_Ribbon( points    : Point_2D_Array; 
  168.                               color     : Allegro_Color; 
  169.                               thickness : Float ); 
  170.     pragma Precondition( points'Length > 0 ); 
  171.  
  172.     procedure Al_Draw_Filled_Triangle( x1, y1, 
  173.                                        x2, y2, 
  174.                                        x3, y3 : Float; 
  175.                                        color  : Allegro_Color ); 
  176.     pragma Import( C, Al_Draw_Filled_Triangle, "al_draw_filled_triangle" ); 
  177.  
  178.     procedure Al_Draw_Filled_Rectangle( x1, y1, 
  179.                                         x2, y2 : Float; 
  180.                                         color  : Allegro_Color ); 
  181.     pragma Import( C, Al_Draw_Filled_Rectangle, "al_draw_filled_rectangle" ); 
  182.  
  183.     procedure Al_Draw_Filled_Ellipse( cx, cy : Float; 
  184.                                       rx, ry : Float; 
  185.                                       color  : Allegro_Color ); 
  186.     pragma Import( C, Al_Draw_Filled_Ellipse, "al_draw_filled_ellipse" ); 
  187.  
  188.     procedure Al_Draw_Filled_Circle( cx, cy : Float; 
  189.                                      r      : Float; 
  190.                                      color  : Allegro_Color ); 
  191.     pragma Import( C, Al_Draw_Filled_Circle, "al_draw_filled_circle" ); 
  192.  
  193.     procedure Al_Draw_Filled_Pieslice( cx, cy      : Float; 
  194.                                        r           : Float; 
  195.                                        start_theta : Float; 
  196.                                        delta_theta : Float; 
  197.                                        color       : Allegro_Color ); 
  198.     pragma Import( C, Al_Draw_Filled_Pieslice, "al_draw_filled_pieslice" ); 
  199.  
  200.     procedure Al_Draw_Filled_Rounded_Rectangle( x1, y1 : Float; 
  201.                                                 x2, y2 : Float; 
  202.                                                 rx, ry : Float; 
  203.                                                 color  : Allegro_Color ); 
  204.     pragma Import( C, Al_Draw_Filled_Rounded_Rectangle, "al_draw_filled_rounded_rectangle" ); 
  205.  
  206.     -- Low level drawing structures 
  207.  
  208.     type Allegro_Vertex is 
  209.         record 
  210.             x, y, z : Float; 
  211.             u, v    : Float; 
  212.             color   : Allegro_Color; 
  213.         end record; 
  214.     pragma Convention( C, Allegro_Vertex ); 
  215.  
  216.     type Allegro_Vertex_Array is array (Integer range <>) of Allegro_Vertex; 
  217.     pragma Convention( C, Allegro_Vertex_Array ); 
  218.  
  219.     type Allegro_Prim_Attr is ( 
  220.         ALLEGRO_PRIM_NONE, 
  221.         ALLEGRO_PRIM_POSITION, 
  222.         ALLEGRO_PRIM_COLOR_ATTR, 
  223.         ALLEGRO_PRIM_TEX_COORD, 
  224.         ALLEGRO_PRIM_TEX_COORD_PIXEL, 
  225.         ALLEGRO_PRIM_ATTR_NUM 
  226.     ); 
  227.     pragma Convention( C, Allegro_Prim_Attr ); 
  228.  
  229.     type Allegro_Prim_Storage is ( 
  230.         ALLEGRO_PRIM_FLOAT_2, 
  231.         ALLEGRO_PRIM_FLOAT_3, 
  232.         ALLEGRO_PRIM_SHORT_2, 
  233.         ALLEGRO_PRIM_COLOR    -- used with ALLEGRO_PRIM_COLOR_ATTR in Allegro_Vertex_Element 
  234.     ); 
  235.     pragma Convention( C, Allegro_Prim_Storage ); 
  236.  
  237.     type Allegro_Vertex_Element is 
  238.         record 
  239.             attribute : Allegro_Prim_Attr; 
  240.             storage   : Allegro_Prim_Storage; 
  241.             offset    : Integer; 
  242.         end record; 
  243.     pragma Convention( C, Allegro_Vertex_Element ); 
  244.  
  245.     type Allegro_Vertex_Element_Array is array (Integer range <>) of Allegro_Vertex_Element; 
  246.     pragma Convention( C, Allegro_Vertex_Element_Array ); 
  247.  
  248.     type Allegro_Vertex_Decl is limited private; 
  249.     type A_Allegro_Vertex_Decl is access all Allegro_Vertex_Decl; 
  250.  
  251.     type Allegro_Prim_Type is ( 
  252.         ALLEGRO_PRIM_LINE_LIST, 
  253.         ALLEGRO_PRIM_LINE_STRIP, 
  254.         ALLEGRO_PRIM_LINE_LOOP, 
  255.         ALLEGRO_PRIM_TRIANGLE_LIST, 
  256.         ALLEGRO_PRIM_TRIANGLE_STRIP, 
  257.         ALLEGRO_PRIM_TRIANGLE_FAN, 
  258.         ALLEGRO_PRIM_POINT_LIST, 
  259.         ALLEGRO_PRIM_NUM_TYPES 
  260.     ); 
  261.     pragma Convention( C, Allegro_Prim_Type ); 
  262.  
  263.     type Vertex_Index_Array is array (Natural range <>) of Integer; 
  264.  
  265.     -- Low level drawing routines 
  266.  
  267.     function Al_Create_Vertex_Decl( elements : Address; 
  268.                                     stride   : Integer ) return A_Allegro_Vertex_Decl; 
  269.     pragma Import( C, Al_Create_Vertex_Decl, "al_create_vertex_decl" ); 
  270.  
  271.     function Al_Create_Vertex_Decl( elements : Allegro_Vertex_Element_Array; 
  272.                                     stride   : Positive ) return A_Allegro_Vertex_Decl; 
  273.     pragma Precondition( elements'Length > 0 ); 
  274.  
  275.     procedure Al_Destroy_Vertex_Decl( decl : in out A_Allegro_Vertex_Decl ); 
  276.  
  277.     procedure Al_Draw_Prim( vertices : Address; 
  278.                             decl     : A_Allegro_Vertex_Decl; 
  279.                             texture  : A_Allegro_Bitmap; 
  280.                             start    : Integer; 
  281.                             stop     : Integer; 
  282.                             primType : Allegro_Prim_Type ); 
  283.     pragma Import( C, Al_Draw_Prim, "al_draw_prim" ); 
  284.  
  285.     -- Same as Al_Draw_Prim above, using the default Allegro_Vertex structure. 
  286.     procedure Al_Draw_Prim( vertices : Allegro_Vertex_Array; 
  287.                             texture  : A_Allegro_Bitmap; 
  288.                             start    : Integer; 
  289.                             stop     : Integer; 
  290.                             primType : Allegro_Prim_Type ); 
  291.  
  292.     function Al_Draw_Indexed_Prim( vertices : Address; 
  293.                                    decl     : A_Allegro_Vertex_Decl; 
  294.                                    texture  : A_Allegro_Bitmap; 
  295.                                    indices  : Vertex_Index_Array; 
  296.                                    primType : Allegro_Prim_Type ) return Integer; 
  297.  
  298.     -- Same as Al_Draw_Indexed_Prim above, but errors are ignored. 
  299.     procedure Al_Draw_Indexed_Prim( vertices : Address; 
  300.                                     decl     : A_Allegro_Vertex_Decl; 
  301.                                     texture  : A_Allegro_Bitmap; 
  302.                                     indices  : Vertex_Index_Array; 
  303.                                     primType : Allegro_Prim_Type ); 
  304.  
  305.     -- Same as Al_Draw_Index_Prim above, using the default Allegro_Vertex structure. 
  306.     procedure Al_Draw_Indexed_Prim( vertices : Allegro_Vertex_Array; 
  307.                                     texture  : A_Allegro_Bitmap; 
  308.                                     indices  : Vertex_Index_Array; 
  309.                                     primType : Allegro_Prim_Type ); 
  310.  
  311.  
  312. --  ALLEGRO_PRIM_FUNC(void, al_draw_soft_triangle, (ALLEGRO_VERTEX* v1, ALLEGRO_VERTEX* v2, ALLEGRO_VERTEX* v3, uintptr_t state, 
  313. --                                             void (*init)(uintptr_t, ALLEGRO_VERTEX*, ALLEGRO_VERTEX*, ALLEGRO_VERTEX*), 
  314. --                                             void (*first)(uintptr_t, int, int, int, int), 
  315. --                                             void (*step)(uintptr_t, int), 
  316. --                                             void (*draw)(uintptr_t, int, int, int))); 
  317. --  ALLEGRO_PRIM_FUNC(void, al_draw_soft_line, (ALLEGRO_VERTEX* v1, ALLEGRO_VERTEX* v2, uintptr_t state, 
  318. --                                         void (*first)(uintptr_t, int, int, ALLEGRO_VERTEX*, ALLEGRO_VERTEX*), 
  319. --                                         void (*step)(uintptr_t, int), 
  320. --                                         void (*draw)(uintptr_t, int, int))); 
  321.  
  322. private 
  323.  
  324.     type Allegro_Vertex_Decl is limited null record; 
  325.     pragma Convention( C, Allegro_Vertex_Decl ); 
  326.  
  327. end Allegro.Drawing.Primitives;