1. -- Change log: 
  2.  
  3. -- GdM : 26-Jul-2011 : using System.Address_To_Access_Conversions 
  4.  
  5. -- GdM : 28-Nov-2005 : replaced Unrestricted_Access with Address 
  6. --                   since Unrestricted_Access is GNAT-Specific 
  7.  
  8. -- GdM : 27-Jan-2004 : Added Material_Float_vector and Material ( .. .) for it 
  9.  
  10. -- GdM : 11-Apr-2002  : * "gl .. ." and other useless C prefixes removed 
  11. --                    * removing of pointers and 
  12. --                      " .. .4f" -style suffixes in progress 
  13.  
  14. with Interfaces.C.Strings; 
  15. with GL.Extended; 
  16.  
  17. package body GL is 
  18.  
  19.    procedure Light 
  20.      (Light_id  : LightIDEnm; 
  21.       pname     : LightParameterVEnm; 
  22.       params    : Light_Float_vector) 
  23.    is 
  24.       params_copy : aliased Light_Float_vector := params; 
  25.    begin 
  26.       Lightfv (Light_id, pname, params_copy (0)'Unchecked_Access); 
  27.    end Light; 
  28.  
  29.    procedure Material (face   : FaceEnm; 
  30.                        pname  : MaterialParameterVEnm; 
  31.                        params : Material_Float_vector) is 
  32.  
  33.       params_copy : aliased Material_Float_vector := params; 
  34.  
  35.    begin 
  36.       Materialfv (face, pname, params_copy (0)'Unchecked_Access); 
  37.    end Material; 
  38.  
  39.    procedure Vertex (v : Double_Vector_3D) is 
  40.  
  41.    begin 
  42.       Vertex3dv (A2A_double.To_Pointer (v (0)'Address)); 
  43.       -- This method is functionally identical 
  44.       -- to using GNAT's 'Unrestricted_Access 
  45.    end Vertex; 
  46.  
  47.    procedure Normal (v : Double_Vector_3D) is 
  48.  
  49.    begin 
  50.       Normal3dv (A2A_double.To_Pointer (v (0)'Address)); 
  51.    end Normal; 
  52.  
  53.    procedure Translate (v : Double_Vector_3D) is 
  54.  
  55.    begin 
  56.       Translate (v (0), v (1), v (2)); 
  57.    end Translate; 
  58.  
  59.    procedure Color (v : RGB_Color) is 
  60.    begin 
  61.       Color3dv (A2A_double.To_Pointer (v.Red'Address)); 
  62.    end Color; 
  63.  
  64.    procedure Color (v : RGBA_Color) is 
  65.    begin 
  66.       Color4dv (A2A_double.To_Pointer (v.red'Address)); 
  67.    end Color; 
  68.  
  69.    function GetString (name : StringEnm) return String is 
  70.       function Cvt is new Ada.Unchecked_Conversion (ubytePtr, Interfaces.C.Strings.chars_ptr); 
  71.       ps : constant Interfaces.C.Strings.chars_ptr := Cvt (GL.GetString (name)); 
  72.       use Interfaces.C.Strings; 
  73.    begin 
  74.       -- OpenGL doc : If an error is generated, glGetString returns 0. 
  75.       if ps = Null_Ptr then 
  76.          -- We still return a string, but an empty one (this is abnormal) 
  77.          return ""; 
  78.       else 
  79.          return Interfaces.C.Strings.Value (ps); 
  80.       end if; 
  81.    end GetString; 
  82.  
  83.    ----------------------------- 
  84.    -- Wrappers of GL.Extended -- 
  85.    ----------------------------- 
  86.  
  87.    procedure Gen_Buffers (n        : GL.Sizei; 
  88.                          buffers  : GL.uintPtr) 
  89.                         renames GL.Extended.GenBuffers; 
  90.  
  91.    procedure Delete_Buffers (n        : GL.Sizei; 
  92.                             buffers  : GL.uintPtr) 
  93.                            renames GL.Extended.DeleteBuffers; 
  94.  
  95.    procedure BindBuffer (target  : VBO_Target; 
  96.                          buffer  : GL.Uint) 
  97.                         renames GL.Extended.BindBuffer; 
  98.  
  99.    procedure Buffer_Data (target  : GL.VBO_Target; 
  100.                          size    : GL.sizeiPtr; 
  101.                          data    : GL.pointer; 
  102.                          usage   : GL.VBO_Usage) 
  103.                         renames GL.Extended.BufferData; 
  104.  
  105.    procedure BufferSubData (target  : GL.VBO_Target; 
  106.                             offset  : GL.intPtr; 
  107.                             size    : GL.sizeiPtr; 
  108.                             data    : GL.pointer) 
  109.                            renames GL.Extended.BufferSubData; 
  110.  
  111.    function MapBuffer   (target  : GL.VBO_Target; 
  112.                          Policy  : GL.Access_Policy) return GL.pointer 
  113.                         renames GL.Extended.MapBuffer; 
  114.  
  115.    function UnmapBuffer (target  : GL.VBO_Target) return GL_Boolean 
  116.                         renames GL.Extended.UnmapBuffer; 
  117.  
  118.    procedure GetBufferParameter (target  : GL.VBO_Target; 
  119.                                  value   : Buffer_Parameter; 
  120.                                  data    : intPointer) 
  121.                                 renames GL.Extended.GetBufferParameter; 
  122.  
  123. end GL;