opengl.geometry: Use the 'openGL.Variable.uniform.sampler2D' type for textures.
This commit is contained in:
@@ -1,18 +1,13 @@
|
||||
with
|
||||
openGL.Primitive.indexed,
|
||||
openGL.Primitive.long_indexed,
|
||||
openGL.Variable.uniform,
|
||||
openGL.Tasks,
|
||||
|
||||
GL.Binding,
|
||||
GL.lean,
|
||||
GL.Pointers,
|
||||
|
||||
ada.Strings.fixed,
|
||||
ada.unchecked_Deallocation,
|
||||
ada.unchecked_Conversion,
|
||||
|
||||
interfaces.C.Strings;
|
||||
ada.unchecked_Deallocation;
|
||||
|
||||
|
||||
package body openGL.Geometry
|
||||
@@ -157,7 +152,11 @@ is
|
||||
procedure Texture_is (in_Set : in out texture_Set; Which : texture_ID; Now : in openGL.Texture.Object)
|
||||
is
|
||||
begin
|
||||
in_Set.Textures (Which) := (0.0, Now, 0);
|
||||
in_Set.Textures (Which) := (0.0,
|
||||
Now,
|
||||
textures_Uniform => <>,
|
||||
fade_Uniform => <>);
|
||||
|
||||
in_Set.is_Transparent := in_Set.is_Transparent
|
||||
or Now .is_Transparent;
|
||||
|
||||
@@ -576,28 +575,34 @@ is
|
||||
begin
|
||||
Tasks.check;
|
||||
|
||||
if not the_Textures.Initialised
|
||||
if not the_Textures.initialised
|
||||
then
|
||||
for i in 1 .. the_Textures.Count
|
||||
loop
|
||||
declare
|
||||
use GL.lean,
|
||||
GL.Pointers,
|
||||
ada.Strings,
|
||||
ada.Strings.fixed,
|
||||
Interfaces;
|
||||
use ada.Strings,
|
||||
ada.Strings.fixed;
|
||||
|
||||
uniform_Name : aliased C.char_array := C.to_C ("Textures[" & Trim (Natural'Image (i - 1), Left) & "]");
|
||||
uniform_Name_ptr : aliased constant C.strings.chars_ptr := C.strings.to_chars_ptr (uniform_Name'unchecked_Access);
|
||||
Id : constant texture_Id := texture_Id (i);
|
||||
Id : constant texture_Id := texture_Id (i);
|
||||
begin
|
||||
the_Textures.Textures (Id).uniform_Location := glGetUniformLocation (Program.gl_Program, +uniform_Name_ptr);
|
||||
declare
|
||||
uniform_Name : aliased constant String :="Textures[" & Trim (Natural'Image (i - 1), Left) & "]";
|
||||
begin
|
||||
the_Textures.Textures (Id).textures_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
|
||||
@@ -644,9 +649,12 @@ is
|
||||
begin
|
||||
-- put_Line ("1-openGL.Program.lit.set_Uniforms:" & loc'Image);
|
||||
|
||||
glUniform1i (the_Textures.Textures (Id).uniform_Location, -- loc,
|
||||
glUniform1i (the_Textures.Textures (Id).textures_Uniform.gl_Variable, -- loc,
|
||||
GLint (i) - 1);
|
||||
|
||||
-- glUniform1i (the_Textures.Textures (Id).textures_uniform_Location, -- loc,
|
||||
-- GLint (i) - 1);
|
||||
|
||||
glActiveTexture (all_texture_Units (Id));
|
||||
glBindTexture (GL_TEXTURE_2D,
|
||||
the_Textures.Textures (Id).Object.Name);
|
||||
|
||||
@@ -2,12 +2,15 @@ with
|
||||
openGL.Primitive,
|
||||
openGL.Buffer,
|
||||
openGL.Program,
|
||||
openGL.Texture;
|
||||
openGL.Texture,
|
||||
openGL.Variable.uniform;
|
||||
|
||||
|
||||
private
|
||||
with
|
||||
ada.Strings.unbounded;
|
||||
|
||||
|
||||
package openGL.Geometry
|
||||
--
|
||||
-- Provides a base class for openGL geometry.
|
||||
@@ -62,9 +65,10 @@ is
|
||||
|
||||
type fadeable_Texture is
|
||||
record
|
||||
Fade : fade_Level := 0.0;
|
||||
Object : openGL.Texture.Object := openGL.Texture.null_Object;
|
||||
uniform_Location : GL.GLint := 0;
|
||||
Fade : fade_Level := 0.0;
|
||||
Object : openGL.Texture.Object := openGL.Texture.null_Object;
|
||||
textures_Uniform : openGL.Variable.uniform.sampler2D;
|
||||
fade_Uniform : openGL.Variable.uniform.float;
|
||||
end record;
|
||||
|
||||
type fadeable_Textures is array (texture_Id range 1 .. max_Textures) of fadeable_Texture;
|
||||
@@ -74,12 +78,14 @@ is
|
||||
Textures : fadeable_Textures;
|
||||
Count : Natural := 0;
|
||||
is_Transparent : Boolean := False; -- Any of the textures contains lucid colors.
|
||||
Initialised : Boolean := False;
|
||||
initialised : Boolean := False;
|
||||
end record;
|
||||
|
||||
procedure enable (the_Textures : in out texture_Set;
|
||||
Program : in openGL.Program.view);
|
||||
|
||||
|
||||
|
||||
procedure Texture_is (in_Set : in out texture_Set; Which : texture_ID; Now : in openGL.Texture.Object);
|
||||
function Texture (in_Set : in texture_Set; Which : texture_ID) return openGL.Texture.Object;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user