1. with Ada.Unchecked_Conversion, System; 
  2.  
  3. package body GLU is 
  4.  
  5.   type loc_DoublePtr is new GL.doublePtr; 
  6.  
  7.   pragma No_Strict_Aliasing (Matrix_Double_Ptr); 
  8.   pragma No_Strict_Aliasing (Viewport_Ptr); 
  9.   pragma No_Strict_Aliasing (loc_DoublePtr); 
  10.   -- recommended by GNAT 2005 
  11.  
  12.   procedure Get (pname  : GL.ParameterNameEnm; 
  13.                  params : out Matrix_Double) is 
  14.     function Cvt is new Ada.Unchecked_Conversion (System.Address, Matrix_Double_Ptr); 
  15.     -- This method is functionally identical as GNAT's Unrestricted_Access 
  16.     -- but has no type safety (cf GNAT Docs) 
  17.   begin 
  18.     Get (pname, Cvt (params (0, 0)'Address)); 
  19.   end Get; 
  20.  
  21.   procedure Get (params : out Viewport_Rec) is 
  22.     function Cvt is new Ada.Unchecked_Conversion (System.Address, Viewport_Ptr); 
  23.   begin 
  24.     Get (GL.VIEWPORT, Cvt (params.X'Address)); 
  25.   end Get; 
  26.  
  27.   procedure Project (objx        : GL.Double; 
  28.                      objy        : GL.Double; 
  29.                      objz        : GL.Double; 
  30.                      modelMatrix : Matrix_Double; 
  31.                      projMatrix  : Matrix_Double; 
  32.                      viewport    : Viewport_Rec; 
  33.                      winx        : out GL.Double; 
  34.                      winy        : out GL.Double; 
  35.                      winz        : out GL.Double; 
  36.                      result      : out Boolean) 
  37.   is 
  38.     function CvV is new Ada.Unchecked_Conversion (System.Address, Viewport_Ptr); 
  39.     function CvM is new Ada.Unchecked_Conversion (System.Address, Matrix_Double_Ptr); 
  40.     function Cvt is new Ada.Unchecked_Conversion (System.Address, loc_DoublePtr); 
  41.     wx, wy, wz : GL.Double; 
  42.     use GL; 
  43.   begin 
  44.     -- Call the same function with C style 
  45.     result := Project ( 
  46.       objx, objy, objz, 
  47.       CvM (modelMatrix'Address), 
  48.       CvM (projMatrix'Address), 
  49.       CvV (viewport'Address), 
  50.       GL.doublePtr (Cvt (wx'Address)), 
  51.       GL.doublePtr (Cvt (wy'Address)), 
  52.       GL.doublePtr (Cvt (wz'Address)) 
  53. ) 
  54.     = 
  55.       GL.GL_Boolean'Pos (GL.GL_True); 
  56.     winx := wx; 
  57.     winy := wy; 
  58.     winz := wz; 
  59.   end Project; 
  60.  
  61. end GLU;