1. ------------------------------------------------------------------------- 
  2.  --  GL.Skins - appearance of the surfaces of geometry primitives 
  3.  -- 
  4.  --  Copyright (c) Rod Kay 2007 
  5.  --  AUSTRALIA 
  6.  --  Permission granted to use this software, without any warranty, 
  7.  --  for any purpose, provided this copyright note remains attached 
  8.  --  and unmodified if sources are distributed further. 
  9.  ------------------------------------------------------------------------- 
  10.  
  11. with GL.Geometry, GL.Textures, GL.Materials; 
  12. with GL.Buffer.texture_coords; 
  13. --  with GL.Buffer.normals; 
  14.  
  15. package GL.Skins is 
  16.  
  17.    type Veneer is abstract tagged null record;   -- contains skin data specific to a particular geometric primitive. 
  18.  
  19.    type p_Veneer is access all Veneer'Class; 
  20.  
  21.    procedure Destroy (Self  : in out Veneer); 
  22.    procedure Free    (Self  : in out p_Veneer); 
  23.  
  24.    procedure Enable (Self  : in out Veneer)   is abstract; 
  25.  
  26.    -- 'Skin' : base of skin class 
  27.  
  28.    type Skin is abstract tagged 
  29.       record 
  30.          null; 
  31.       end record; 
  32.  
  33.    type p_Skin is access all Skin'Class; 
  34.    type Skin_Array is array (Positive range <>) of p_Skin; 
  35.  
  36.    procedure Destroy (Self  : in out Skin); 
  37.    procedure Free    (Self  : in out p_Skin); 
  38.  
  39.    function  New_Veneer (Self         : Skin; 
  40.                          for_Geometry : GL.Geometry.Geometry_t'Class) return p_Veneer is abstract; 
  41.  
  42.    procedure Enable         (Self  : in out Skin)                  is abstract; 
  43.    function  is_Transparent (Self  :        Skin) return Boolean   is abstract; 
  44.  
  45.    null_Skins : constant Skin_Array (1 .. 0) := (others => null); 
  46.  
  47.    -- Skin : opaque unlit mono_color 
  48.    -- 
  49.  
  50.    type Skin_opaque_unlit_mono_color is new Skin with 
  51.       record 
  52.          Color  : RGB_Color; 
  53.       end record; 
  54.  
  55.    overriding function  New_Veneer     (Self :        Skin_opaque_unlit_mono_color; for_Geometry : GL.Geometry.Geometry_t'Class) return p_Veneer; 
  56.    overriding procedure Enable         (Self : in out Skin_opaque_unlit_mono_color); 
  57.    overriding function  is_Transparent (Self :        Skin_opaque_unlit_mono_color) return Boolean; 
  58.  
  59.    -- Skin : opaque lit mono_color 
  60.    -- 
  61.  
  62.    type Veneer_opaque_lit_mono_color (Max_Normals  : GL.Geometry.vertex_Id) is new Veneer with 
  63.       record 
  64.          Normals  : GL.Geometry.GL_Normals_Vertex_Id (1 .. Max_Normals); 
  65.       end record; 
  66.  
  67.    overriding procedure Enable (Self  : in out Veneer_opaque_lit_mono_color); 
  68.  
  69.    type Skin_opaque_lit_mono_color is new Skin with 
  70.       record 
  71.          Material  : GL.Materials.Material_type := Materials.neutral_material; 
  72.       end record; 
  73.  
  74.    overriding function  new_Veneer (Self :        Skin_opaque_lit_mono_color; for_Geometry : GL.Geometry.Geometry_t'Class) return p_Veneer; 
  75.    overriding procedure Enable     (Self : in out Skin_opaque_lit_mono_color); 
  76.  
  77.    overriding function  is_Transparent (Self : Skin_opaque_lit_mono_color) return Boolean; 
  78.  
  79.    -- Skin : transparent unlit textured (used by 'impostor's)  -- tbd : get rid of 'transparent' since might not be ! 
  80.    -- 
  81.  
  82.    type Veneer_transparent_unlit_textured (Num_Coordinates  : GL.Geometry.vertex_Id) is new Veneer with 
  83.       record 
  84.          Texture_Coordinates  : GL.Textures.Coordinate_2D_array (1 .. Num_Coordinates); 
  85.       end record; 
  86.  
  87.    type p_Veneer_transparent_unlit_textured is access all Veneer_transparent_unlit_textured'Class; 
  88.  
  89.    overriding procedure Enable (Self  : in out Veneer_transparent_unlit_textured); 
  90.  
  91.    type Skin_transparent_unlit_textured is new Skin with 
  92.       record 
  93.          Texture               : GL.Textures.Object; 
  94.          Coordinate_Generator  : GL.Textures.p_coordinate_Generator; 
  95.       end record; 
  96.  
  97.    type p_Skin_transparent_unlit_textured is access all Skin_transparent_unlit_textured; 
  98.  
  99.    overriding procedure Destroy (Self  : in out Skin_transparent_unlit_textured); 
  100.  
  101.    overriding function  New_Veneer     (Self :        Skin_transparent_unlit_textured; for_Geometry :  GL.Geometry.Geometry_t'Class) return p_Veneer; 
  102.    overriding procedure Enable         (Self : in out Skin_transparent_unlit_textured); 
  103.    overriding function  is_Transparent (Self :        Skin_transparent_unlit_textured) return Boolean; 
  104.  
  105.    -- Skin : unlit textured vbo 
  106.    -- 
  107.  
  108.    type Veneer_unlit_textured_vbo is new Veneer with 
  109.       record 
  110.          -- texture_Coordinates  : GL.Buffer.vertex_buffer_Object; 
  111.          texture_Coordinates  : GL.Buffer.texture_coords.General_Object; 
  112.       end record; 
  113.  
  114.    type p_Veneer_unlit_textured_vbo is access all Veneer_unlit_textured_vbo'Class; 
  115.  
  116.    overriding procedure Enable (Self : in out Veneer_unlit_textured_vbo); 
  117.  
  118.    -- tbd : 'destroy' for veneers ! 
  119.  
  120.    type Skin_unlit_textured_vbo is new Skin with 
  121.       record 
  122.          Texture  : GL.Textures.Object; 
  123.       end record; 
  124.  
  125.    type p_Skin_unlit_textured_vbo is access all Skin_unlit_textured_vbo; 
  126.  
  127.    overriding procedure Destroy (Self  : in out Skin_unlit_textured_vbo); 
  128.  
  129.    overriding function  new_Veneer (Self :        Skin_unlit_textured_vbo; for_Geometry : GL.Geometry.Geometry_t'Class) return p_Veneer; 
  130.    overriding procedure Enable     (Self : in out Skin_unlit_textured_vbo); 
  131.  
  132.    overriding function  is_Transparent (Self : Skin_unlit_textured_vbo) return Boolean; 
  133.  
  134.    -- . .. other common skin specialisations . .. 
  135.    -- . .. 
  136.  
  137.    -- standard skins 
  138.    -- 
  139.  
  140.    green_Skin     : p_Skin := new GL.Skins.Skin_opaque_unlit_mono_color'(Color => (Red   => 1.0, 
  141.                                                                                    Green => 1.0, 
  142.                                                                                    Blue  => 1.0)); 
  143.  
  144.    lit_green_Skin : p_Skin := new GL.Skins.Skin_opaque_lit_mono_color;  -- tbd : set to a green colour (defaults to neutral grey atm :) 
  145.  
  146.    -- . .. other standard skins 
  147.  
  148. end GL.Skins; 
  149.  
  150.  -- tbd : use consistent naming for Max_* vs Num_*