opengl: Cosmetics.

This commit is contained in:
Rod Kay
2025-09-20 12:02:50 +10:00
parent e950ad5383
commit b679ac4bf5
7 changed files with 3 additions and 295 deletions

View File

@@ -191,8 +191,6 @@ is
procedure enable_Textures (Self : in out Item)
is
begin
-- ada.Text_IO.put_Line (Self.Model'Image);
texturing.enable (for_Model => Self.Model.all'Access,
Uniforms => texture_Uniforms,
texture_Set => Self.texture_Set);

View File

@@ -8,7 +8,6 @@ with
openGL.Model;
-- private
package openGL.Geometry.texturing
--
-- Provides texturing support for geometries.

View File

@@ -9,95 +9,6 @@ is
use GL;
type texture_Units is array (texture_Set.texture_Id) of GLenum;
all_texture_Units : constant texture_Units := [GL_TEXTURE0,
GL_TEXTURE1,
GL_TEXTURE2,
GL_TEXTURE3,
GL_TEXTURE4,
GL_TEXTURE5,
GL_TEXTURE6,
GL_TEXTURE7,
GL_TEXTURE8,
GL_TEXTURE9,
GL_TEXTURE10,
GL_TEXTURE11,
GL_TEXTURE12,
GL_TEXTURE13,
GL_TEXTURE14,
GL_TEXTURE15];
-- GL_TEXTURE16,
-- GL_TEXTURE17,
-- GL_TEXTURE18,
-- GL_TEXTURE19,
-- GL_TEXTURE20,
-- GL_TEXTURE21,
-- GL_TEXTURE22,
-- GL_TEXTURE23,
-- GL_TEXTURE24,
-- GL_TEXTURE25,
-- GL_TEXTURE26,
-- GL_TEXTURE27,
-- GL_TEXTURE28,
-- GL_TEXTURE29,
-- GL_TEXTURE30,
-- GL_TEXTURE31];
procedure enable (for_Model : in openGL.Model.view;
Uniforms : in texturing.Uniforms;
texture_Set : in openGL.texture_Set.Item)
is
use GL.Binding,
GL.lean;
use type GLint;
begin
for i in 1 .. openGL.texture_Set.texture_Id (for_Model.texture_Count)
loop
Uniforms.Textures (i).fade_Uniform.Value_is (Real (for_Model.Fade (i)));
glUniform1i (Uniforms.Textures (i).texture_Uniform.gl_Variable,
GLint (i) - 1);
glActiveTexture (all_texture_Units (i));
glBindTexture (GL_TEXTURE_2D,
texture_Set.Textures (i).Object.Name);
end loop;
Uniforms.Count.Value_is (for_Model.texture_Count);
end enable;
procedure create (Uniforms : out texturing.Uniforms;
for_Program : in openGL.Program.view)
is
begin
for Id in texture_Set.texture_Id'Range
loop
declare
use ada.Strings,
ada.Strings.fixed;
i : constant Positive := Positive (Id);
texture_uniform_Name : constant String := "Textures[" & trim (Natural'Image (i - 1), Left) & "]";
fade_uniform_Name : constant String := "Fade[" & trim (Natural'Image (i - 1), Left) & "]";
begin
Uniforms.Textures (Id).texture_Uniform := for_Program.uniform_Variable (named => texture_uniform_Name);
Uniforms.Textures (Id). fade_Uniform := for_Program.uniform_Variable (named => fade_uniform_Name);
end;
end loop;
Uniforms.Count := for_Program.uniform_Variable ("texture_Count");
end create;
-------------
--- Mixin ---
-------------

View File

@@ -1,7 +1,5 @@
with
openGL.Variable.uniform,
openGL.texture_Set,
openGL.Program;
openGL.texture_Set;
package openGL.Model.texturing
@@ -9,40 +7,6 @@ package openGL.Model.texturing
-- Provides texturing support for models.
--
is
--- Uniforms
--
type texture_fade_Uniform_pair is
record
texture_Uniform : openGL.Variable.uniform.sampler2D;
fade_Uniform : openGL.Variable.uniform.float;
end record;
type texture_fade_Uniform_pairs is array (openGL.texture_Set.texture_Id
range 1 .. openGL.texture_Set.max_Textures) of texture_fade_Uniform_pair;
type Uniforms is
record
Textures : texture_fade_Uniform_pairs;
Count : openGL.Variable.uniform.int;
end record;
--- Operations
--
procedure enable (for_Model : in openGL.Model.view;
Uniforms : in texturing.Uniforms;
texture_Set : in openGL.texture_Set.Item);
procedure create (Uniforms : out texturing.Uniforms;
for_Program : in openGL.Program.view);
-------------
--- Mixin ---
-------------

View File

@@ -1,14 +1,3 @@
with
openGL.Tasks,
GL.Binding,
GL.lean,
ada.Strings.fixed;
with ada.Text_IO; use ada.Text_IO;
package body openGL.texture_Set
is
@@ -113,150 +102,6 @@ is
-- function Texture (in_Set : in Item) return openGL.Texture.Object
-- is
-- begin
-- return in_Set.Textures (1).Object;
-- end Texture;
--
--
--
--
-- procedure Texture_is (in_Set : in out Item; Now : in openGL.Texture.Object)
-- is
-- begin
-- in_Set.Textures (1).Object := Now;
-- in_Set.is_Transparent := in_Set.is_Transparent
-- or Now .is_Transparent;
--
-- if in_Set.Count = 0
-- then
-- in_Set.Count := 1;
-- end if;
-- end Texture_is;
-- procedure enable (the_Textures : in out Item;
-- Program : in openGL.Program.view)
-- is
-- use GL,
-- GL.Binding,
-- openGL.Texture;
--
-- begin
-- Tasks.check;
--
-- if not the_Textures.initialised
-- then
-- for i in 1 .. the_Textures.Count
-- loop
-- declare
-- use ada.Strings,
-- ada.Strings.fixed;
--
-- Id : constant texture_Id := texture_Id (i);
-- begin
-- null;
--
-- -- declare
-- -- uniform_Name : aliased constant String :="Textures[" & Trim (Natural'Image (i - 1), Left) & "]";
-- -- begin
-- -- the_Textures.Textures (Id).texture_Uniform := Program.uniform_Variable (Named => uniform_Name);
-- -- end;
--
-- -- declare
-- -- uniform_Name : constant String := "Fade[" & Trim (Natural'Image (i - 1), Left) & "]";
-- -- begin
-- -- the_Textures.Textures (Id).fade_Uniform := Program.uniform_Variable (Named => uniform_Name);
-- -- end;
-- end;
-- end loop;
--
-- the_Textures.Initialised := True;
-- end if;
--
--
-- for i in 1 .. the_Textures.Count
-- loop
-- declare
-- use GL.lean;
--
-- use type GL.GLint;
--
-- type texture_Units is array (texture_Id) of GLenum;
--
-- all_texture_Units : constant texture_Units := (GL_TEXTURE0,
-- GL_TEXTURE1,
-- GL_TEXTURE2,
-- GL_TEXTURE3,
-- GL_TEXTURE4,
-- GL_TEXTURE5,
-- GL_TEXTURE6,
-- GL_TEXTURE7,
-- GL_TEXTURE8,
-- GL_TEXTURE9,
-- GL_TEXTURE10,
-- GL_TEXTURE11,
-- GL_TEXTURE12,
-- GL_TEXTURE13,
-- GL_TEXTURE14,
-- GL_TEXTURE15,
-- GL_TEXTURE16,
-- GL_TEXTURE17,
-- GL_TEXTURE18,
-- GL_TEXTURE19,
-- GL_TEXTURE20,
-- GL_TEXTURE21,
-- GL_TEXTURE22,
-- GL_TEXTURE23,
-- GL_TEXTURE24,
-- GL_TEXTURE25,
-- GL_TEXTURE26,
-- GL_TEXTURE27,
-- GL_TEXTURE28,
-- GL_TEXTURE29,
-- GL_TEXTURE30,
-- GL_TEXTURE31);
--
-- Id : constant texture_Id := texture_Id (i);
-- begin
-- null;
-- -- glUniform1i (the_Textures.Textures (Id).texture_Uniform.gl_Variable,
-- -- GLint (i) - 1);
-- -- glActiveTexture (all_texture_Units (Id));
-- -- glBindTexture (GL_TEXTURE_2D,
-- -- the_Textures.Textures (Id).Object.Name);
-- end;
--
--
-- -- declare
-- -- use ada.Strings,
-- -- ada.Strings.fixed;
-- --
-- -- uniform_Name : constant String := "Fade[" & Trim (Natural'Image (i - 1), Left) & "]";
-- -- Uniform : constant openGL.Variable.uniform.float := Program.uniform_Variable (uniform_Name);
-- -- Id : constant texture_Id := texture_Id (i);
-- -- begin
-- -- -- put_Line ("Fade:" & the_Textures.Textures (texture_Id (i)).Fade'Image);
-- --
-- -- -- the_Textures.Textures (Id).fade_Uniform.Value_is (Real (the_Textures.Textures (texture_Id (i)).Fade));
-- -- -- Uniform.Value_is (Real (the_Textures.Textures (texture_Id (i)).Fade));
-- -- null;
-- -- end;
-- end loop;
--
--
-- -- declare
-- -- the_texture_count_Uniform : constant openGL.Variable.uniform.int := Program.uniform_Variable ("texture_Count");
-- -- begin
-- -- the_texture_count_Uniform.Value_is (the_Textures.Count);
-- -- end;
-- end enable;
-----------
--- Streams
--

View File

@@ -1,5 +1,4 @@
with
openGL.Program,
openGL.Texture,
ada.Calendar;
@@ -71,7 +70,7 @@ is
type Animation (frame_Count : Positive) is
record
frame_Duration : Duration := 0.1;
next_frame_Time : ada.Calendar.Time := ada.Calendar.Clock;
next_frame_Time : ada.Calendar.Time := ada.Calendar.Clock;
Current : frame_Id := 1;
Frames : texture_Set.Frames (1 .. frame_Count);
@@ -127,23 +126,14 @@ is
initialised : Boolean := False;
end record;
-- procedure enable (the_Textures : in out Item;
-- Program : in openGL.Program.view);
procedure Texture_is (in_Set : in out Item; Which : texture_ID := 1; Now : in openGL.Texture.Object);
function Texture (in_Set : in Item; Which : texture_ID := 1) return openGL.Texture.Object;
-- procedure Texture_is (in_Set : in out Item; Now : in openGL.Texture.Object);
-- function Texture (in_Set : in Item) return openGL.Texture.Object;
private
-----------
--- Streams
--

View File

@@ -1,6 +1,7 @@
with
ada.unchecked_Deallocation;
package body openGL.Visual
is