opengl: Revamp texturing.

This commit is contained in:
Rod Kay
2025-09-09 10:52:23 +10:00
parent 76add3f4a2
commit 5f0e2155be
24 changed files with 593 additions and 479 deletions

View File

@@ -7,6 +7,7 @@
uniform int texture_Count;
uniform sampler2D Textures [16];
uniform float Fade [16];
uniform bool texture_Applies [16];
vec4
apply_Texturing (vec2 Coords)
@@ -15,12 +16,15 @@ apply_Texturing (vec2 Coords)
for (int i = 0; i < texture_Count; ++i)
{
if (texture_Applies [i])
{
Color.rgb += texture (Textures [i], Coords).rgb
* texture (Textures [i], Coords).a
* (1.0 - Fade [i]);
Color.a = max (Color.a, texture (Textures [i],
Coords).a);
}
}
return Color;

View File

@@ -1,3 +1,4 @@
with openGL.Model.texturing;
with openGL.texture_Set;
with
openGL.Palette,
@@ -151,20 +152,26 @@ is
:= Model.sphere.lit_colored.new_Sphere (Radius => 1.0, Color => (Green, Opaque));
the_ball_3_Model : constant Model.sphere.lit_textured.view
:= Model.sphere.lit_textured.new_Sphere (Radius => 1.0, Image => the_Texture);
:= Model.sphere.lit_textured.new_Sphere (Radius => 1.0,
texture_Details => texture_Set.to_Details ([1 => the_Texture]),
Image => the_Texture);
the_ball_4_Model : constant Model.sphere.lit_colored_textured.view
:= Model.sphere.lit_colored_textured.new_Sphere (Radius => 1.0, Image => the_Texture);
:= Model.sphere.lit_colored_textured.new_Sphere (Radius => 1.0,
texture_Details => texture_Set.to_Details ([1 => the_Texture]),
Image => the_Texture);
the_billboard_Model : constant Model.billboard.textured.view
:= Model.billboard.textured.forge.new_Billboard (Size => (1.0, 1.0),
Plane => Billboard.xy,
texture_Details => texture_Set.to_Details ([1 => the_Texture]),
Texture => the_Texture);
the_colored_billboard_Model : constant Model.billboard.textured.view -- TODO: Add color.
:= Model.billboard.textured.forge.new_Billboard (Size => (1.0, 1.0),
Plane => Billboard.xy,
Texture => the_Texture);
Texture => the_Texture,
texture_Details => texture_Set.to_Details ([1 => the_Texture]));
use Model.box;
the_box_1_Model : constant Model.box.colored.view
@@ -180,16 +187,20 @@ is
the_box_2_Model : constant Model.box.lit_textured.view
:= Model.box.lit_textured.new_Box
(Size => [1.0, 2.0, 1.0],
Faces => [others => (texture_Name => the_Texture)]);
Faces => [others => (texture_Name => the_Texture)],
texture_Details => texture_Set.to_Details ([1 => the_Texture]));
the_box_3_Model : constant Model.box.textured.view
:= Model.box.textured.new_Box
(Size => [1.0, 2.0, 3.0],
Faces => [others => (texture_Name => the_Texture)]);
Faces => [others => (texture_Name => the_Texture)],
texture_Details => texture_Set.to_Details ([1 => the_Texture]));
the_capsule_Model : constant Model.capsule.lit_textured.view
:= Model.capsule.lit_textured.new_Capsule (Radius => 0.5,
Height => 2.0,
texture_Details => texture_Set.to_Details ([1 => the_Texture]),
Image => the_Texture);
the_lit_textured_circle_Model : constant Model.circle.lit_textured.view
@@ -248,6 +259,7 @@ is
:= Model.any.new_Model (--Scale => (1.0, 1.0, 1.0),
Model => to_Asset ("assets/opengl/model/human.obj"),
Texture => the_Texture,
texture_Details => openGL.texture_Set.to_Details ([1 => the_Texture]),
Texture_is_lucid => False);
the_lit_colored_polygon_Model : constant Model.polygon.lit_colored.view
@@ -256,12 +268,13 @@ is
the_lit_textured_polygon_Model : constant Model.polygon.lit_textured.view
:= Model.polygon.lit_textured.new_Polygon (vertex_Sites => [Origin_2D, [1.0, 0.0], [1.0, 1.0], [-1.0, 0.5]],
texture_Details => (openGL.texture_Set.to_Details ([1 => the_Texture])));
texture_Details => openGL.texture_Set.to_Details ([1 => the_Texture]));
the_text_Model : constant Model.Text.lit_colored.view
:= Model.Text.lit_colored.new_Text (Text => "Once upon a midnight dreary ...",
Font => the_font_Id,
Color => (Green, Opaque),
texture_Details => openGL.texture_Set.to_Details ([1 => the_Texture]),
Centered => True);
the_segment_line_Model : constant Model.segment_line.view
@@ -277,12 +290,13 @@ is
Tiling : constant texture_Transform_2d := (S => (0.0, 1.0),
T => (0.0, 1.0));
the_ground_Model : constant Model.terrain.view
:= Model.Terrain.new_Terrain (heights_Asset => heights_File,
Row => 1,
Col => 1,
Heights => the_Region.all'Access,
Color_Map => texture_File,
Tiling => Tiling);
:= Model.Terrain.new_Terrain (heights_Asset => heights_File,
Row => 1,
Col => 1,
Heights => the_Region.all'Access,
Color_Map => texture_File,
texture_Details => openGL.texture_Set.to_Details ([1 => texture_File]),
Tiling => Tiling);
begin
Demo.Renderer.add_Font (the_font_Id);
@@ -292,10 +306,10 @@ is
the_segment_line_Model.add_Segment (end_Site => [2.0, 2.0, 0.0]);
the_segment_line_Model.add_Segment (end_Site => [0.0, 2.0, 0.0]);
return [ the_ground_Model.all'Access,
return [ the_text_Model.all'Access,
the_ground_Model.all'Access,
the_lit_textured_polygon_Model.all'Access,
the_lit_colored_polygon_Model.all'Access,
the_text_Model.all'Access,
the_arrow_Model.all'Access,
the_ball_1_Model.all'Access,
the_ball_2_Model.all'Access,

View File

@@ -31,29 +31,34 @@ is
function to_Model (Model : in asset_Name;
Texture : in asset_Name;
texture_Details : in texture_Set.Details;
Texture_is_lucid : in Boolean) return openGL.Model.any.item
is
begin
return Self : openGL.Model.any.item := (openGL.Model.item with
-- return Self : openGL.Model.any. := (openGL.Model.item with
return Self : openGL.Model.any.item := (textured_Model.textured_item with
Model,
Texture,
Texture_is_lucid,
Geometry => null)
do
Self.Bounds.Ball := 1.0;
Self.texture_Details_is (texture_Details);
end return;
end to_Model;
function new_Model (Model : in asset_Name;
Texture : in asset_Name;
texture_Details : in texture_Set.Details;
Texture_is_lucid : in Boolean) return openGL.Model.any.view
is
begin
return new openGL.Model.any.item' (to_Model (Model, Texture, Texture_is_lucid));
return new openGL.Model.any.item' (to_Model (Model, Texture, texture_Details, Texture_is_lucid));
end new_Model;
--------------
--- Attributes
--
@@ -501,40 +506,40 @@ is
-- Texturing
--
overriding
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level)
is
begin
null;
end Fade_is;
overriding
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level
is
begin
return 0.0;
end Fade;
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in openGL.asset_Name)
is
begin
null;
end Texture_is;
overriding
function texture_Count (Self : in Item) return Natural
is
begin
return 1;
end texture_Count;
-- overriding
-- procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in texture_Set.fade_Level)
-- is
-- begin
-- null;
-- end Fade_is;
--
--
--
-- overriding
-- function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level
-- is
-- begin
-- return 0.0;
-- end Fade;
--
--
--
-- procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in openGL.asset_Name)
-- is
-- begin
-- null;
-- end Texture_is;
--
--
--
-- overriding
-- function texture_Count (Self : in Item) return Natural
-- is
-- begin
-- return 1;
-- end texture_Count;

View File

@@ -1,5 +1,6 @@
with
openGL.Geometry;
openGL.Geometry,
openGL.Model.texturing;
package openGL.Model.any
@@ -9,7 +10,11 @@ package openGL.Model.any
-- This model is largely used by the IO importers of various model formats (ie collada, wavefront, etc).
--
is
type Item is new Model.item with private;
package textured_Model is new texturing.Mixin (openGL.Model.item);
type Item is new textured_Model.textured_item with private;
-- type Item is new Model.item with private;
type View is access all Item'Class;
@@ -19,6 +24,7 @@ is
function new_Model (Model : in asset_Name;
Texture : in asset_Name;
texture_Details : in texture_Set.Details;
Texture_is_lucid : in Boolean) return openGL.Model.any.view;
--------------
@@ -43,24 +49,25 @@ is
-- Texturing
--
overriding
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
overriding
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level);
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in asset_Name);
overriding
function texture_Count (Self : in Item) return Natural;
-- overriding
-- function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
--
-- overriding
-- procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in texture_Set.fade_Level);
--
-- procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in asset_Name);
--
-- overriding
-- function texture_Count (Self : in Item) return Natural;
private
type Item is new Model.item with
-- type Item is new Model.item with
type Item is new textured_Model.textured_item with
record
Model : asset_Name := null_Asset; -- A wavefront '.obj' or collada '.dae' file. -- TODO: Rename to 'model_Name'.

View File

@@ -17,6 +17,7 @@ is
function new_Billboard (Size : in Size_t := default_Size;
Plane : in billboard.Plane;
Texture : in asset_Name;
texture_Details : in texture_Set.Details;
Lucid : in Boolean := False) return View
is
Self : constant View := new Item (Lucid);
@@ -25,6 +26,8 @@ is
Self.Texture_Name := Texture;
Self.define (Size);
Self.texture_Details_is (texture_Details);
return Self;
end new_Billboard;
end Forge;
@@ -202,41 +205,41 @@ is
-- Texturing
--
overriding
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level)
is
begin
null;
end Fade_is;
overriding
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level
is
begin
return 0.0;
end Fade;
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in openGL.asset_Name)
is
begin
null;
end Texture_is;
overriding
function texture_Count (Self : in Item) return Natural
is
begin
return 1;
end texture_Count;
-- overriding
-- procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in texture_Set.fade_Level)
-- is
-- begin
-- null;
-- end Fade_is;
--
--
--
-- overriding
-- function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level
-- is
-- begin
-- return 0.0;
-- end Fade;
--
--
--
-- procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in openGL.asset_Name)
-- is
-- begin
-- null;
-- end Texture_is;
--
--
--
--
-- overriding
-- function texture_Count (Self : in Item) return Natural
-- is
-- begin
-- return 1;
-- end texture_Count;

View File

@@ -1,6 +1,7 @@
with
openGL.Geometry,
openGL.Texture;
openGL.Texture,
openGL.Model.texturing;
package openGL.Model.billboard.textured
@@ -8,7 +9,10 @@ package openGL.Model.billboard.textured
-- Models a textured billboard.
--
is
type Item (Lucid : Boolean) is new Model.billboard.item with private;
package textured_Model is new texturing.Mixin (openGL.Model.billboard.item);
type Item (Lucid : Boolean) is new textured_Model.textured_item with private;
-- type Item (Lucid : Boolean) is new Model.billboard.item with private;
type View is access all Item'Class;
type Image_view is access Image;
@@ -24,6 +28,7 @@ is
function new_Billboard (Size : in Size_t := default_Size;
Plane : in billboard.Plane;
Texture : in asset_Name;
texture_Details : in texture_Set.Details;
Lucid : in Boolean := False) return View;
end Forge;
@@ -50,24 +55,25 @@ is
-- Texturing
--
overriding
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
overriding
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level);
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in asset_Name);
overriding
function texture_Count (Self : in Item) return Natural;
-- overriding
-- function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
--
-- overriding
-- procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in texture_Set.fade_Level);
--
-- procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in asset_Name);
--
-- overriding
-- function texture_Count (Self : in Item) return Natural;
private
type Item (Lucid : Boolean) is new Model.billboard.item with
-- type Item (Lucid : Boolean) is new Model.billboard.item with
type Item (Lucid : Boolean) is new textured_Model.textured_item with
record
texture_Name : asset_Name := null_Asset;
Texture : openGL.Texture.Object := openGL.Texture.null_Object; -- The texture to be applied to the billboard face.

View File

@@ -10,13 +10,16 @@ is
--
function new_Box (Size : in Vector_3;
Faces : in lit_textured.Faces) return View
Faces : in lit_textured.Faces;
texture_Details : in texture_Set.Details) return View
is
Self : constant View := new Item;
begin
Self.Faces := Faces;
Self.Size := Size;
Self.texture_Details_is (texture_Details);
return Self;
end new_Box;
@@ -196,41 +199,41 @@ is
-- Texturing
--
overriding
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level)
is
begin
null;
end Fade_is;
overriding
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level
is
begin
return 0.0;
end Fade;
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in openGL.asset_Name)
is
begin
null;
end Texture_is;
overriding
function texture_Count (Self : in Item) return Natural
is
begin
return 1;
end texture_Count;
-- overriding
-- procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in texture_Set.fade_Level)
-- is
-- begin
-- null;
-- end Fade_is;
--
--
--
-- overriding
-- function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level
-- is
-- begin
-- return 0.0;
-- end Fade;
--
--
--
-- procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in openGL.asset_Name)
-- is
-- begin
-- null;
-- end Texture_is;
--
--
--
--
-- overriding
-- function texture_Count (Self : in Item) return Natural
-- is
-- begin
-- return 1;
-- end texture_Count;

View File

@@ -1,6 +1,7 @@
with
openGL.Geometry,
openGL.Font;
openGL.Font,
openGL.Model.texturing;
package openGL.Model.Box.lit_textured
@@ -10,7 +11,10 @@ package openGL.Model.Box.lit_textured
-- Each face may have a separate texture.
--
is
type Item is new Model.box.item with private;
package textured_Model is new texturing.Mixin (openGL.Model.box.item);
type Item is new textured_Model.textured_item with private;
-- type Item is new Model.box.item with private;
type View is access all Item'Class;
@@ -27,7 +31,8 @@ is
--
function new_Box (Size : in Vector_3;
Faces : in lit_textured.Faces) return View;
Faces : in lit_textured.Faces;
texture_Details : in texture_Set.Details) return View;
--------------
@@ -43,24 +48,25 @@ is
-- Texturing
--
overriding
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
overriding
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level);
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in asset_Name);
overriding
function texture_Count (Self : in Item) return Natural;
-- overriding
-- function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
--
-- overriding
-- procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in texture_Set.fade_Level);
--
-- procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in asset_Name);
--
-- overriding
-- function texture_Count (Self : in Item) return Natural;
private
type Item is new Model.box.item with
-- type Item is new Model.box.item with
type Item is new textured_Model.textured_item with
record
Faces : lit_textured.Faces;
end record;

View File

@@ -11,6 +11,7 @@ is
function new_Box (Size : in Vector_3;
Faces : in textured.Faces;
texture_Details : in texture_Set.Details;
is_Skybox : in Boolean := False) return View
is
Self : constant View := new Item;
@@ -19,6 +20,8 @@ is
Self.is_Skybox := is_Skybox;
Self.Size := Size;
Self.texture_Details_is (texture_Details);
return Self;
end new_Box;
@@ -203,40 +206,40 @@ is
-- Texturing
--
overriding
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level)
is
begin
null;
end Fade_is;
overriding
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level
is
begin
return 0.0;
end Fade;
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in openGL.asset_Name)
is
begin
null;
end Texture_is;
overriding
function texture_Count (Self : in Item) return Natural
is
begin
return 1;
end texture_Count;
-- overriding
-- procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in texture_Set.fade_Level)
-- is
-- begin
-- null;
-- end Fade_is;
--
--
--
-- overriding
-- function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level
-- is
-- begin
-- return 0.0;
-- end Fade;
--
--
--
-- procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in openGL.asset_Name)
-- is
-- begin
-- null;
-- end Texture_is;
--
--
--
-- overriding
-- function texture_Count (Self : in Item) return Natural
-- is
-- begin
-- return 1;
-- end texture_Count;
end openGL.Model.box.textured;

View File

@@ -1,7 +1,8 @@
with
openGL.Geometry,
openGL.Font,
openGL.Texture;
openGL.Texture,
openGL.Model.texturing;
package openGL.Model.Box.textured
@@ -11,7 +12,10 @@ package openGL.Model.Box.textured
-- Each face may have a separate texture.
--
is
type Item is new Model.box.item with private;
package textured_Model is new texturing.Mixin (openGL.Model.box.item);
type Item is new textured_Model.textured_item with private;
-- type Item is new Model.box.item with private;
type View is access all Item'Class;
@@ -29,6 +33,7 @@ is
function new_Box (Size : in Vector_3;
Faces : in textured.Faces;
texture_Details : in texture_Set.Details;
is_Skybox : in Boolean := False) return View;
@@ -44,24 +49,25 @@ is
-- Texturing
--
overriding
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
overriding
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level);
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in asset_Name);
overriding
function texture_Count (Self : in Item) return Natural;
-- overriding
-- function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
--
-- overriding
-- procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in texture_Set.fade_Level);
--
-- procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in asset_Name);
--
-- overriding
-- function texture_Count (Self : in Item) return Natural;
private
type Item is new Model.box.item with
-- type Item is new Model.box.item with
type Item is new textured_Model.textured_item with
record
Faces : textured.Faces;
is_Skybox : Boolean := False;

View File

@@ -13,6 +13,7 @@ is
function new_Capsule (Radius : in Real;
Height : in Real;
texture_Details : in texture_Set.Details;
Image : in asset_Name := null_Asset) return View
is
Self : constant View := new Item;
@@ -21,6 +22,8 @@ is
Self.Height := Height;
Self.Image := Image;
Self.texture_Details_is (texture_Details);
return Self;
end new_Capsule;
@@ -409,40 +412,40 @@ is
-- Texturing
--
overriding
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level)
is
begin
null;
end Fade_is;
overriding
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level
is
begin
return 0.0;
end Fade;
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in openGL.asset_Name)
is
begin
null;
end Texture_is;
overriding
function texture_Count (Self : in Item) return Natural
is
begin
return 1;
end texture_Count;
-- overriding
-- procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in texture_Set.fade_Level)
-- is
-- begin
-- null;
-- end Fade_is;
--
--
--
-- overriding
-- function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level
-- is
-- begin
-- return 0.0;
-- end Fade;
--
--
--
-- procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in openGL.asset_Name)
-- is
-- begin
-- null;
-- end Texture_is;
--
--
--
-- overriding
-- function texture_Count (Self : in Item) return Natural
-- is
-- begin
-- return 1;
-- end texture_Count;
end openGL.Model.capsule.lit_textured;

View File

@@ -1,5 +1,6 @@
with
openGL.Geometry;
openGL.Geometry,
openGL.Model.texturing;
package openGL.Model.capsule.lit_textured
@@ -7,7 +8,10 @@ package openGL.Model.capsule.lit_textured
-- Models a lit and textured capsule.
--
is
type Item is new Model.capsule.item with private;
package textured_Model is new texturing.Mixin (openGL.Model.capsule.item);
type Item is new textured_Model.textured_item with private;
-- type Item is new Model.capsule.item with private;
type View is access all Item'Class;
@@ -17,6 +21,7 @@ is
function new_Capsule (Radius : in Real;
Height : in Real;
texture_Details : in texture_Set.Details;
Image : in asset_Name := null_Asset) return View;
--------------
@@ -32,24 +37,25 @@ is
-- Texturing
--
overriding
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
overriding
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level);
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in asset_Name);
overriding
function texture_Count (Self : in Item) return Natural;
-- overriding
-- function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
--
-- overriding
-- procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in texture_Set.fade_Level);
--
-- procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in asset_Name);
--
-- overriding
-- function texture_Count (Self : in Item) return Natural;
private
type Item is new Model.capsule.item with
-- type Item is new Model.capsule.item with
type Item is new textured_Model.textured_item with
record
Radius : Real;
Height : Real;

View File

@@ -15,6 +15,7 @@ is
long_Count : in Positive := default_longitude_Count;
Color : in openGL.lucid_Color := (openGL.Palette.Grey,
Opacity => 1.0);
texture_Details : in texture_Set.Details;
Image : in asset_Name := null_Asset) return View
is
Self : constant View := new Item;
@@ -26,6 +27,8 @@ is
Self.Color := Color;
Self.Image := Image;
Self.texture_Details_is (texture_Details);
return Self;
end new_Sphere;
@@ -210,40 +213,40 @@ is
-- Texturing
--
overriding
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level)
is
begin
null;
end Fade_is;
overriding
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level
is
begin
return 0.0;
end Fade;
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in openGL.asset_Name)
is
begin
Self.Image := Now;
end Texture_is;
overriding
function texture_Count (Self : in Item) return Natural
is
begin
return 1;
end texture_Count;
-- overriding
-- procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in texture_Set.fade_Level)
-- is
-- begin
-- null;
-- end Fade_is;
--
--
--
-- overriding
-- function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level
-- is
-- begin
-- return 0.0;
-- end Fade;
--
--
--
-- procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in openGL.asset_Name)
-- is
-- begin
-- Self.Image := Now;
-- end Texture_is;
--
--
--
-- overriding
-- function texture_Count (Self : in Item) return Natural
-- is
-- begin
-- return 1;
-- end texture_Count;
end openGL.Model.sphere.lit_colored_textured;

View File

@@ -1,7 +1,8 @@
with
openGL.Font,
openGL.Palette,
openGL.Geometry;
openGL.Geometry,
openGL.Model.texturing;
package openGL.Model.sphere.lit_colored_textured
@@ -9,7 +10,10 @@ package openGL.Model.sphere.lit_colored_textured
-- Models a lit, colored, textured sphere.
--
is
type Item is new Model.sphere.item with private;
package textured_Model is new texturing.Mixin (openGL.Model.sphere.item);
type Item is new textured_Model.textured_item with private;
-- type Item is new Model.sphere.item with private;
type View is access all Item'Class;
@@ -18,6 +22,7 @@ is
long_Count : in Positive := default_longitude_Count;
Color : in openGL.lucid_Color := (openGL.Palette.Grey,
Opacity => 1.0);
texture_Details : in texture_Set.Details;
Image : in asset_Name := null_Asset) return View;
@@ -30,24 +35,25 @@ is
-- Texturing
--
overriding
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
overriding
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level);
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in asset_Name);
overriding
function texture_Count (Self : in Item) return Natural;
-- overriding
-- function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
--
-- overriding
-- procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in texture_Set.fade_Level);
--
-- procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in asset_Name);
--
-- overriding
-- function texture_Count (Self : in Item) return Natural;
private
type Item is new Model.sphere.item with -- TODO: Add 'Color' component.
-- type Item is new Model.sphere.item with -- TODO: Add 'Color' component.
type Item is new textured_Model.textured_item with
record
Color : openGL.lucid_Color;
Image : asset_Name := null_Asset; -- Usually a mercator projection to be mapped onto the sphere.

View File

@@ -12,6 +12,7 @@ is
function new_Sphere (Radius : in Real;
lat_Count : in Positive := default_latitude_Count;
long_Count : in Positive := default_longitude_Count;
texture_Details : in texture_Set.Details;
Image : in asset_Name := null_Asset) return View
is
Self : constant View := new Item;
@@ -21,6 +22,7 @@ is
Self.lat_Count := lat_Count;
Self.long_Count := long_Count;
Self.Image := Image;
Self.texture_Details_is (texture_Details);
return Self;
end new_Sphere;
@@ -198,40 +200,40 @@ is
-- Texturing
--
overriding
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level)
is
begin
null;
end Fade_is;
overriding
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level
is
begin
return 0.0;
end Fade;
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in openGL.asset_Name)
is
begin
Self.Image := Now;
end Texture_is;
overriding
function texture_Count (Self : in Item) return Natural
is
begin
return 1;
end texture_Count;
-- overriding
-- procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in texture_Set.fade_Level)
-- is
-- begin
-- null;
-- end Fade_is;
--
--
--
-- overriding
-- function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level
-- is
-- begin
-- return 0.0;
-- end Fade;
--
--
--
-- procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in openGL.asset_Name)
-- is
-- begin
-- Self.Image := Now;
-- end Texture_is;
--
--
--
-- overriding
-- function texture_Count (Self : in Item) return Natural
-- is
-- begin
-- return 1;
-- end texture_Count;

View File

@@ -1,6 +1,7 @@
with
openGL.Font,
openGL.Geometry;
openGL.Geometry,
openGL.Model.texturing;
package openGL.Model.sphere.lit_textured
@@ -10,13 +11,18 @@ package openGL.Model.sphere.lit_textured
-- The texture is often a mercator projection to be mapped onto the sphere.
--
is
type Item is new Model.sphere.item with private;
package textured_Model is new texturing.Mixin (openGL.Model.sphere.item);
type Item is new textured_Model.textured_item with private;
-- type Item is new Model.sphere.item with private;
type View is access all Item'Class;
function new_Sphere (Radius : in Real;
lat_Count : in Positive := default_latitude_Count;
long_Count : in Positive := default_longitude_Count;
texture_Details : in texture_Set.Details;
Image : in asset_Name := null_Asset) return View;
@@ -29,24 +35,25 @@ is
-- Texturing
--
overriding
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
overriding
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level);
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in asset_Name);
overriding
function texture_Count (Self : in Item) return Natural;
-- overriding
-- function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
--
-- overriding
-- procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in texture_Set.fade_Level);
--
-- procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in asset_Name);
--
-- overriding
-- function texture_Count (Self : in Item) return Natural;
private
type Item is new Model.sphere.item with
-- type Item is new Model.sphere.item with
type Item is new textured_Model.textured_item with
record
Image : asset_Name := null_Asset; -- Usually a mercator projection to be mapped onto the sphere.
end record;

View File

@@ -15,14 +15,15 @@ is
-- Forge
--
function new_Terrain (heights_Asset : in asset_Name;
Row, Col : in Integer;
Heights : in height_Map_view;
color_Map : in asset_Name;
Tiling : in texture_Transform_2d := (S => (0.0, 1.0),
T => (0.0, 1.0))) return View
function new_Terrain (heights_Asset : in asset_Name;
Row, Col : in Integer;
Heights : in height_Map_view;
color_Map : in asset_Name;
texture_Details : in texture_Set.Details;
Tiling : in texture_Transform_2d := (S => (0.0, 1.0),
T => (0.0, 1.0))) return View
is
the_Model : constant View := new Item' (Model.item with
the_Model : constant View := new Item' (textured_Model.textured_item with
heights_Asset => heights_Asset,
Heights => Heights,
Row => Row,
@@ -31,6 +32,7 @@ is
tiling => Tiling);
begin
the_Model.set_Bounds;
the_Model.texture_Details_is (texture_Details);
return the_Model;
end new_Terrain;
@@ -289,40 +291,40 @@ is
-- Texturing
--
overriding
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level)
is
begin
null;
end Fade_is;
overriding
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level
is
begin
return 0.0;
end Fade;
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in openGL.asset_Name)
is
begin
Self.color_Map := Now;
end Texture_is;
overriding
function texture_Count (Self : in Item) return Natural
is
begin
return 1;
end texture_Count;
-- overriding
-- procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in texture_Set.fade_Level)
-- is
-- begin
-- null;
-- end Fade_is;
--
--
--
-- overriding
-- function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level
-- is
-- begin
-- return 0.0;
-- end Fade;
--
--
--
-- procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in openGL.asset_Name)
-- is
-- begin
-- Self.color_Map := Now;
-- end Texture_is;
--
--
--
-- overriding
-- function texture_Count (Self : in Item) return Natural
-- is
-- begin
-- return 1;
-- end texture_Count;
end openGL.Model.terrain;

View File

@@ -1,5 +1,6 @@
with
openGL.Geometry;
openGL.Geometry,
openGL.Model.texturing;
package openGL.Model.terrain
@@ -7,7 +8,9 @@ package openGL.Model.terrain
-- Models lit, textured terrain.
--
is
type Item is new Model.item with private;
package textured_Model is new texturing.Mixin (openGL.Model.item);
type Item is new textured_Model.textured_item with private;
type View is access all Item'Class;
@@ -18,11 +21,12 @@ is
--- Forge
--
function new_Terrain (heights_Asset : in asset_Name;
Row, Col : in Integer;
Heights : in height_Map_view;
color_Map : in asset_Name;
Tiling : in texture_Transform_2d := (S => (0.0, 1.0),
function new_Terrain (heights_Asset : in asset_Name;
Row, Col : in Integer;
Heights : in height_Map_view;
color_Map : in asset_Name;
texture_Details : in texture_Set.Details;
Tiling : in texture_Transform_2d := (S => (0.0, 1.0),
T => (0.0, 1.0))) return View;
overriding
procedure destroy (Self : in out Item);
@@ -41,24 +45,24 @@ is
-- Texturing
--
overriding
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
overriding
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level);
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in asset_Name);
overriding
function texture_Count (Self : in Item) return Natural;
-- overriding
-- function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
--
-- overriding
-- procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in texture_Set.fade_Level);
--
-- procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in asset_Name);
--
-- overriding
-- function texture_Count (Self : in Item) return Natural;
private
type Item is new Model.item with
type Item is new textured_Model.textured_item with
record
heights_Asset : asset_Name := null_Asset;

View File

@@ -16,6 +16,7 @@ is
function new_Text (Text : in String;
Font : in openGL.Font.font_Id;
Color : in lucid_Color;
texture_Details : in texture_Set.Details;
Centered : in Boolean := True) return View
is
Font_Name : constant String := to_String (Font.Name);
@@ -35,6 +36,8 @@ is
Self.Centered := Centered;
Self.Bounds := null_Bounds;
Self.texture_Details_is (texture_Details);
return Self;
end;
end new_Text;
@@ -292,41 +295,41 @@ is
-- Texturing
--
overriding
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level)
is
begin
null;
end Fade_is;
overriding
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level
is
begin
return 0.0;
end Fade;
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in openGL.asset_Name)
is
begin
null;
end Texture_is;
overriding
function texture_Count (Self : in Item) return Natural
is
begin
return 1;
end texture_Count;
-- overriding
-- procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in texture_Set.fade_Level)
-- is
-- begin
-- null;
-- end Fade_is;
--
--
--
-- overriding
-- function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level
-- is
-- begin
-- return 0.0;
-- end Fade;
--
--
--
-- procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in openGL.asset_Name)
-- is
-- begin
-- null;
-- end Texture_is;
--
--
--
--
-- overriding
-- function texture_Count (Self : in Item) return Natural
-- is
-- begin
-- return 1;
-- end texture_Count;
end openGL.Model.Text.lit_colored;

View File

@@ -1,6 +1,7 @@
with
openGL.Font.texture,
openGL.Geometry;
openGL.Geometry,
openGL.Model.texturing;
package openGL.Model.Text.lit_colored
@@ -8,7 +9,10 @@ package openGL.Model.Text.lit_colored
-- Models lit and colored text.
--
is
type Item is new Model.text.item with private;
package textured_Model is new texturing.Mixin (openGL.Model.text.item);
type Item is new textured_Model.textured_item with private;
-- type Item is new Model.text.item with private;
type View is access all Item'Class;
@@ -19,6 +23,7 @@ is
function new_Text (Text : in String;
Font : in openGL.Font.font_Id;
Color : in lucid_Color;
texture_Details : in texture_Set.Details;
Centered : in Boolean := True) return View;
@@ -42,24 +47,25 @@ is
-- Texturing
--
overriding
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
overriding
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level);
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in asset_Name);
overriding
function texture_Count (Self : in Item) return Natural;
-- overriding
-- function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
--
-- overriding
-- procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in texture_Set.fade_Level);
--
-- procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
-- Now : in asset_Name);
--
-- overriding
-- function texture_Count (Self : in Item) return Natural;
private
type Item is new Model.text.item with
-- type Item is new Model.text.item with
type Item is new textured_Model.textured_item with
record
Text : String_view;

View File

@@ -18,6 +18,9 @@ is
no_such_Font : exception;
overriding
function texture_Applied (Self : in Item; Which : in texture_Set.texture_Id) return Boolean
is (True);
private

View File

@@ -1,6 +1,7 @@
with
openGL.Camera,
openGL.Model.billboard.textured,
openGL.texture_Set,
ada.unchecked_Deallocation;
@@ -82,7 +83,8 @@ is
Self.Visual.Model_is (Model.billboard.textured.Forge.new_Billboard (Size => (Width => Width,
Height => Height),
Plane => Model.billboard.xy,
Texture => null_Asset).all'Access);
Texture => null_Asset,
texture_Details => texture_Set.to_Details ([1 => null_Asset])).all'Access);
Self.Visual.Transform_is (Target.Transform);
-- Self.Visual.model_Transform_is (Target.model_Transform);
end set_Target;

View File

@@ -11,7 +11,7 @@ with
interfaces.C.Strings;
-- use ada.Text_IO;
use ada.Text_IO;
package body openGL.Shader
@@ -113,7 +113,7 @@ is
Status'unchecked_Access);
if Status = 0
and Debugging
and False
-- and False
then
declare
use ada.Text_IO;
@@ -137,6 +137,9 @@ is
is
the_Source : aliased constant C.char_array := to_C_char_array (shader_Filename);
begin
put_Line ("SHADER NAME: " & shader_Filename);
put_Line (interfaces.C.to_Ada (the_Source));
create_Shader (Self, Kind, the_Source);
end define;

View File

@@ -23,6 +23,8 @@ with
openGL.Model.line .colored,
openGL.Model.segment_line,
openGL.texture_Set,
physics.Model,
gel.Window;
-- float_Math.Random;
@@ -155,6 +157,7 @@ is
then
the_graphics_Model := openGL.Model.sphere.lit_colored_textured.new_Sphere (Radius,
Color => Color,
texture_Details => openGL.texture_Set.to_Details ([1 => Texture]),
Image => Texture).all'Access;
else
the_graphics_Model := openGL.Model.circle.colored.new_circle (Radius,
@@ -307,6 +310,7 @@ is
the_graphics_Model := openGL.Model.sphere.lit_colored_textured.new_Sphere (Radius,
lat_Count => lat_Count,
long_Count => long_Count,
texture_Details => openGL.texture_Set.to_Details ([1 => Texture]),
Image => Texture).all'Access;
else
if Color /= openGL.no_lucid_Color
@@ -422,7 +426,8 @@ is
Upper => (texture_Name => Texture),
Lower => (texture_Name => Texture),
Left => (texture_Name => Texture),
Right => (texture_Name => Texture)]);
Right => (texture_Name => Texture)],
texture_Details => openGL.texture_Set.to_Details ([1 => Texture]));
the_box_physics_Model : constant physics.Model.view
:= physics.Model.Forge.new_physics_Model (shape_Info => (Kind => physics.Model.Cube,
half_Extents => Size / 2.0),
@@ -456,7 +461,8 @@ is
:= openGL.Model.billboard.textured.forge.new_Billboard (Size => (Width => Size (1),
Height => Size (2)),
Plane => openGL.Model.Billboard.xy,
Texture => Texture);
Texture => Texture,
texture_Details => openGL.texture_Set.to_Details ([1 => Texture]));
the_billboard_physics_Model : constant physics.Model.view
:= physics.Model.Forge.new_physics_Model (shape_Info => (Kind => physics.Model.Cube,
@@ -640,6 +646,7 @@ is
:= openGL.Model.text.lit_colored.new_Text (Text => Text,
Font => Font,
Color => (Color, openGL.Opaque),
texture_Details => openGL.texture_Set.to_Details ([1 => openGL.null_Asset]),
Centered => Centered);
the_physics_Model : physics.Model.view;
begin