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