gel.demo: Use 'gel_sdl'.

This commit is contained in:
Rod Kay
2023-11-03 18:02:10 +11:00
parent 0b4d19522b
commit 2f6670a24c
34 changed files with 217 additions and 123 deletions

View File

@@ -6,17 +6,24 @@ set -e
## Clean
#
rm -fr ./dsa
gprclean -r -P ../gel_demo.gpr -Xrestrictions=xgc -Xopengl_platform=glx -Xopengl_profile=lean
gprclean -r -P ../gel_demo.gpr -Xrestrictions=xgc -Xopengl_platform=egl -Xopengl_profile=lean
#########
## Build
#
mkdir --parents dsa/x86_64-unknown-linux-gnu/obj
cp /usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/adalib/a-sttebu.ali \
dsa/x86_64-unknown-linux-gnu/obj
set +e
po_gnatdist -Xrestrictions=xgc -Xopengl_platform=glx -Xopengl_profile=lean -P demo_dsa.gpr simple_dsa.cfg
po_gnatdist -Xrestrictions=xgc -Xopengl_platform=egl -Xopengl_profile=lean -P demo_dsa.gpr simple_dsa.cfg
set -e
echo __________________________________________________ PHASE 2 _____________________________________________
cp dsa/x86_64-unknown-linux-gnu/obj/*.o dsa/x86_64-unknown-linux-gnu/partitions/simple_dsa/server_partition
cp dsa/x86_64-unknown-linux-gnu/obj/*.o dsa/x86_64-unknown-linux-gnu/partitions/simple_dsa/client_partition
po_gnatdist -Xrestrictions=xgc -Xopengl_platform=glx -Xopengl_profile=lean -P demo_dsa.gpr simple_dsa.cfg
po_gnatdist -Xrestrictions=xgc -Xopengl_platform=egl -Xopengl_profile=lean -P demo_dsa.gpr simple_dsa.cfg

View File

@@ -1,8 +1,8 @@
with
"gel",
"../gel_demo",
"lace_shared";
project GEL_fused
is
for Source_Dirs use (".");

View File

@@ -1,5 +1,5 @@
with
"gel",
"gel_sdl",
"lace_shared";
project gel_Demo

View File

@@ -3,10 +3,12 @@ with
gel_demo_Server,
gel.Applet.client_World,
gel.Window.setup,
gel.Forge,
gel.Camera,
openGL.Light,
ada.Calendar,
ada.Text_IO,
ada.Exceptions;
@@ -40,6 +42,17 @@ is
the_Applet.client_Camera.Site_is ([0.0, 0.0, 20.0]);
the_Applet.enable_simple_Dolly (1);
-- Set the lights position.
--
declare
Light : openGL.Light.item := the_Applet.Renderer.new_Light;
begin
Light.Site_is ([0.0, -1000.0, 0.0]);
the_Applet.Renderer.set (Light);
end;
next_render_Time := ada.Calendar.clock;
-- Begin processing.

View File

@@ -1,5 +1,34 @@
#version 140
// Texturing snippet.
//
uniform int texture_Count;
uniform sampler2D Textures [32];
uniform float Fade [32];
vec4
apply_Texturing (vec2 Coords)
{
vec4 Color = vec4 (0);
for (int i = 0; i < texture_Count; ++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;
}
struct light
{
vec4 Site;
@@ -15,7 +44,7 @@ uniform mat4 model_Transform;
uniform mat3 inverse_model_Rotation;
uniform vec3 camera_Site;
uniform vec3 specular_Color; // The materials specular color.
uniform sampler2D Texture;
//uniform sampler2D Texture;
uniform int light_Count;
uniform light Lights [10];
@@ -95,8 +124,8 @@ apply_Light (light Light,
void
main()
{
vec4 texture_Color = texture (Texture, frag_Coords);
vec4 texture_Color = apply_Texturing (frag_Coords); // texture (Texture, frag_Coords);
vec4 surface_Color = vec4 (mix (texture_Color.rgb,
frag_Color .rgb,
0.5),

View File

@@ -1,5 +1,32 @@
#version 140
// Texturing snippet.
//
uniform int texture_Count;
uniform sampler2D Textures [32];
uniform float Fade [32];
vec4
apply_Texturing (vec2 Coords)
{
vec4 Color = vec4 (0);
for (int i = 0; i < texture_Count; ++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;
}
struct light
{
vec4 Site;
@@ -15,7 +42,7 @@ uniform mat4 model_Transform;
uniform mat3 inverse_model_Rotation;
uniform vec3 camera_Site;
uniform vec3 specular_Color; // The materials specular color.
uniform sampler2D Texture;
//uniform sampler2D Texture;
uniform int light_Count;
uniform light Lights [10];
@@ -29,6 +56,8 @@ in float frag_Shine;
out vec4 final_Color;
vec3
apply_Light (light Light,
vec3 surface_Color,
@@ -92,16 +121,15 @@ apply_Light (light Light,
void
main()
{
vec3 surface_Site = vec3 ( model_Transform
* vec4 (frag_Site, 1));
vec4 surface_Color = mix (texture (Texture, frag_Coords),
vec4 surface_Color = mix (apply_Texturing (frag_Coords),
frag_Color,
0.5);
vec3 Surface_to_Camera = normalize (camera_Site - surface_Site);
vec3 Normal = normalize (frag_Normal * inverse_model_Rotation);
@@ -118,8 +146,7 @@ main()
Surface_to_Camera);
}
vec3 Gamma = vec3 (1.0 / 2.2);
vec3 Gamma = vec3 (1.0 / 2.2);
final_Color = vec4 (pow (linear_Color, // Final color (after gamma correction).
Gamma),
surface_Color.a);

View File

@@ -1,4 +1,6 @@
#version 140
// Include 'version.header'.
// Include 'texturing.frag'.
struct light
{
@@ -15,7 +17,7 @@ uniform mat4 model_Transform;
uniform mat3 inverse_model_Rotation;
uniform vec3 camera_Site;
uniform vec3 specular_Color; // The materials specular color.
uniform sampler2D Texture;
uniform int light_Count;
uniform light Lights [10];
@@ -28,6 +30,8 @@ in float frag_Shine;
out vec4 final_Color;
vec3
apply_Light (light Light,
vec3 surface_Color,
@@ -91,18 +95,16 @@ apply_Light (light Light,
void
main()
{
vec3 surface_Site = vec3 ( model_Transform
* vec4 (frag_Site, 1));
vec4 surface_Color = texture (Texture, frag_Coords);
vec4 surface_Color = apply_Texturing (frag_Coords);
vec3 Surface_to_Camera = normalize (camera_Site - surface_Site);
vec3 Normal = normalize ( frag_Normal
* inverse_model_Rotation);
// Combine color from all the lights.
//
vec3 linear_Color = vec3 (0);
@@ -116,8 +118,7 @@ main()
Surface_to_Camera);
}
vec3 Gamma = vec3 (1.0 / 2.2);
vec3 Gamma = vec3 (1.0 / 2.2);
final_Color = vec4 (pow (linear_Color, // Final color (after gamma correction).
Gamma),
surface_Color.a);

View File

@@ -1,12 +1,11 @@
#version 140
// Include 'version.header'.
// Include 'texturing.frag'.
uniform sampler2D sTexture;
varying vec4 vColor;
varying vec2 vCoords;
in vec2 frag_Coords;
out vec4 final_Color;
void main()
{
gl_FragColor = texture2D (sTexture, vCoords) * vColor; // Modulate light color with texture.
}
final_Color = apply_Texturing (frag_Coords);
}

View File

@@ -1,25 +1,16 @@
#version 140
uniform mat4 mvp_Transform;
uniform vec3 Scale;
uniform mat4 mvp_Transform;
uniform vec3 Scale;
in vec3 Site;
in vec2 Coords;
attribute vec3 Site;
attribute vec2 Coords;
varying vec4 vColor;
varying vec2 vCoords;
const float c_zero = 0.0;
const float c_one = 1.0;
out vec2 frag_Coords;
void main()
{
frag_Coords = Coords;
gl_Position = mvp_Transform * vec4 (Site * Scale, 1.0);
vColor = vec4 (1.0, 1.0, 1.0, 1.0);
vCoords = Coords;
}

View File

@@ -1,5 +1,5 @@
with
"gel",
"gel_sdl",
"lace_shared";

View File

@@ -1,6 +1,6 @@
with
gel.Window.setup,
gel.Applet.gui_and_sim_world,
gel.Applet.gui_world,
gel.Forge,
gel.Sprite,
@@ -28,10 +28,10 @@ is
openGL.Model.box,
opengl.Palette;
the_Applet : constant gel.Applet.gui_and_sim_world.view := gel.Forge.new_gui_and_sim_Applet ("mixed Shapes", 1536, 864);
the_Applet : constant gel.Applet.gui_world.view := gel.Forge.new_gui_Applet ("mixed Shapes", 1536, 864);
text_line_Site : gel.Math.Vector_3 := (-10.0, 50.0, -60.0);
text_line_Site : gel.Math.Vector_3 := [-10.0, 50.0, -60.0];
procedure put_Line (Message : in String)
is
@@ -94,8 +94,8 @@ is
the_terrain_physics_Model : constant physics.Model.view
:= physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.heightfield,
Heights => new physics.Heightfield' (to_Heightfield (gl_Heights.all)),
height_Range => (0.0, 200.0)),
Scale => (hs, 1.0, hs));
height_Range => [0.0, 200.0]),
Scale => [hs, 1.0, hs]);
the_Terrain : constant gel.Sprite.view
:= gel.Sprite.forge.new_Sprite ("demo.Terrain",
the_Applet.gui_World.all'Access,
@@ -105,15 +105,14 @@ is
begin
-- Setup the applet.
--
the_Applet.gui_Camera.Site_is ((0.0, 4.0, 30.0)); -- Position the camera.
the_Applet.sim_Camera.Site_is ((0.0, 4.0, 30.0)); -- Position the camera.
the_Applet.gui_Camera.Site_is ([0.0, 4.0, 30.0]); -- Position the camera.
the_Applet.enable_simple_Dolly (in_World => the_Applet.sim_World.Id); -- Enable user camera control via keyboard.
the_Applet.enable_simple_Dolly (in_World => the_Applet.gui_World.Id); -- Enable user camera control via keyboard.
the_Applet.Dolly.Speed_is (0.1);
the_Applet.Renderer.Background_is (sky_Blue);
the_Applet.sim_World.Gravity_is ((0.0, -9.8, 0.0));
the_Applet.gui_World.Gravity_is ([0.0, -9.8, 0.0]);
-- Camera controls text.
@@ -131,7 +130,7 @@ begin
Light : openGL.Light.item := the_Applet.Renderer.new_Light;
begin
Light.Kind_is (Diffuse);
Light.Site_is ((0.0, 100.0, 100.0));
Light.Site_is ([0.0, 100.0, 100.0]);
Light.ambient_Coefficient_is (0.2);
the_Applet.Renderer.set (Light);
@@ -140,7 +139,7 @@ begin
-- Terrain.
--
the_Applet.sim_World.add (the_Terrain); -- Add the terrain.
the_Applet.gui_World.add (the_Terrain); -- Add the terrain.
-- Add several sprites of each shape.
@@ -151,13 +150,13 @@ begin
-- Box
--
the_box_Model : constant openGL.Model.box.colored.view
:= openGL.Model.box.colored.new_Box (Size => (1.0, 1.0, 1.0),
Faces => (Front => (Colors => (others => (Red, Opaque))),
Rear => (Colors => (others => (Green, Opaque))),
Upper => (Colors => (others => (Violet, Opaque))),
Lower => (Colors => (others => (Yellow, Opaque))),
Left => (Colors => (others => (Cyan, Opaque))),
Right => (Colors => (others => (Magenta, Opaque)))));
:= openGL.Model.box.colored.new_Box (Size => [1.0, 1.0, 1.0],
Faces => [Front => (Colors => [others => (Red, Opaque)]),
Rear => (Colors => [others => (Green, Opaque)]),
Upper => (Colors => [others => (Violet, Opaque)]),
Lower => (Colors => [others => (Yellow, Opaque)]),
Left => (Colors => [others => (Cyan, Opaque)]),
Right => (Colors => [others => (Magenta, Opaque)])]);
the_box_physics_Model : constant physics.Model.view
:= physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.Cube,
half_Extents => the_box_Model.Size / 2.0),
@@ -232,8 +231,8 @@ begin
the_multi_Sphere_physics_Model : constant physics.Model.view
:= physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.multi_Sphere,
Sites => new physics.Vector_3_array' ((-0.5, 0.0, 0.0),
( 0.5, 0.0, 0.0)),
Sites => new physics.Vector_3_array' ([-0.5, 0.0, 0.0],
[ 0.5, 0.0, 0.0]),
Radii => new gel.math.Vector' (1 => 0.5,
2 => 0.5)),
Mass => 1.0);
@@ -249,41 +248,41 @@ begin
--
s : constant := 0.5;
the_hull_Model : constant openGL.Model.box.colored.view
:= openGL.Model.box.colored.new_Box (Size => (s * 2.0, s * 2.0, s * 2.0),
Faces => (others => (others => (others => (Palette.random_Color, Opaque)))));
:= openGL.Model.box.colored.new_Box (Size => [s * 2.0, s * 2.0, s * 2.0],
Faces => [others => (others => [others => (Palette.random_Color, Opaque)])]);
the_hull_physics_Model : constant physics.Model.view
:= physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.hull,
Points => new physics.Vector_3_array' ((-s, -s, s),
( s, -s, s),
( s, s, s),
(-s, s, s),
:= physics.Model.forge.new_physics_Model (Mass => 1.0,
shape_Info => (Kind => physics.Model.hull,
Points => new physics.Vector_3_array' ([-s, -s, s],
[ s, -s, s],
[ s, s, s],
[-s, s, s],
(-s, -s, -s),
( s, -s, -s),
( s, s, -s),
(-s, s, -s))),
Mass => 1.0);
the_Hull : constant gel.Sprite.view
[-s, -s, -s],
[ s, -s, -s],
[ s, s, -s],
[-s, s, -s])));
the_Hull : constant gel.Sprite.view
:= gel.Sprite.forge.new_Sprite ("demo.Hull",
the_Applet.gui_World.all'Access,
Origin_3D,
the_hull_Model.all'Access,
the_hull_physics_Model);
begin
the_Applet.sim_World.add (the_Ball);
the_Applet.sim_World.add (the_Box);
the_Applet.sim_World.add (the_Cone);
the_Applet.sim_World.add (the_Capsule);
the_Applet.sim_World.add (the_multi_Sphere);
the_Applet.sim_World.add (the_Hull);
the_Applet.gui_World.add (the_Ball);
the_Applet.gui_World.add (the_Box);
the_Applet.gui_World.add (the_Cone);
the_Applet.gui_World.add (the_Capsule);
the_Applet.gui_World.add (the_multi_Sphere);
the_Applet.gui_World.add (the_Hull);
the_Ball .Site_is (( x, y, 0.0));
the_Box .Site_is (( 0.0, y, -2.5));
the_Cone .Site_is (( 0.0, y, 0.0));
the_Capsule .Site_is (( 0.0 + X, y, 0.0 + x));
the_multi_Sphere.Site_is ((-4.0, y, 4.4));
the_Hull .Site_is (( 4.0, y, 4.4));
the_Ball .Site_is ([ x, y, 0.0]);
the_Box .Site_is ([ 0.0, y, -2.5]);
the_Cone .Site_is ([ 0.0, y, 0.0]);
the_Capsule .Site_is ([ 0.0 + X, y, 0.0 + x]);
the_multi_Sphere.Site_is ([-4.0, y, 4.4]);
the_Hull .Site_is ([ 4.0, y, 4.4]);
x := x + 2.0;
y := y + 2.0;

View File

@@ -1,7 +1,8 @@
with
"gel",
"gel_sdl",
"lace_shared";
project Hello_SDL_GEL
is
for Object_Dir use "build";

View File

@@ -1,7 +1,8 @@
with
"gel",
"gel_sdl",
"lace_shared";
project opengl_Model
is
for Object_Dir use "build";

View File

@@ -1,7 +1,8 @@
with
"gel",
"gel_sdl",
"lace_shared";
project Mouse_Motion
is
for Object_Dir use "build";

View File

@@ -1,7 +1,8 @@
with
"gel",
"gel_sdl",
"lace_shared";
project Mouse_selection
is
for Object_Dir use "build";

View File

@@ -1,5 +1,5 @@
with
"gel",
"gel_sdl",
"lace_shared";

View File

@@ -1,4 +1,5 @@
with "gel";
with
"gel_sdl";
project Human_Model_V1
@@ -8,15 +9,19 @@ is
for Exec_Dir use ".";
for Main use ("launch_human_model_v1.adb");
for Languages use ("Ada");
type Os_Type is
("Windows_NT", "Linux", "MacOSX");
Os : Os_Type := external ("OS");
type Restrictions is
("xgc", "ravenscar");
Restrictions : Restrictions := external ("restrictions");
type Platform is
("egl", "glx");
Opengl_Platform : Platform := external ("opengl_platform");
type Profile is
("safe", "lean", "desk");
Opengl_Profile : Profile := external ("opengl_profile");

View File

@@ -1,5 +1,5 @@
with
"gel",
"gel_sdl",
"lace_shared";

View File

@@ -1,7 +1,8 @@
with
"gel",
"gel_sdl",
"lace_shared";
project box_rig_1_bone_Demo
is
for Object_Dir use "build";

View File

@@ -1,7 +1,8 @@
with
"gel",
"gel_sdl",
"lace_shared";
project rig_Demo
is
for Object_Dir use "build";

View File

@@ -1,7 +1,8 @@
with
"gel",
"gel_sdl",
"lace_shared";
project human_rig_Demo
is
for Object_Dir use "build";

View File

@@ -1,7 +1,8 @@
with
"gel",
"gel_sdl",
"lace_shared";
project Chains_2D
is
for Object_Dir use "build";
@@ -14,4 +15,4 @@ is
package Compiler renames Lace_shared.Compiler;
package Binder renames Lace_shared.Binder;
end Chains_2D;
end Chains_2D;

View File

@@ -1,7 +1,8 @@
with
"gel",
"gel_sdl",
"lace_shared";
project Drop_Ball_On_Box
is
for Object_Dir use "build";
@@ -19,4 +20,4 @@ is
for Linker_Options use ("-g", "-lGL", "-lGLU", "-lglut", "-lSDL2");
end Linker;
end Drop_Ball_On_Box;
end Drop_Ball_On_Box;

View File

@@ -1,7 +1,8 @@
with
"gel",
"gel_sdl",
"lace_shared";
project drop_Box_on_Box
is
for Object_Dir use "build";
@@ -14,4 +15,4 @@ is
package Compiler renames Lace_shared.Compiler;
package Binder renames Lace_shared.Binder;
end drop_Box_on_Box;
end drop_Box_on_Box;

View File

@@ -1,7 +1,8 @@
with
"gel",
"gel_sdl",
"lace_shared";
project hinged_Box
is
for Object_Dir use "build";
@@ -14,4 +15,4 @@ is
package Compiler renames Lace_shared.Compiler;
package Binder renames Lace_shared.Binder;
end hinged_Box;
end hinged_Box;

View File

@@ -1,7 +1,8 @@
with
"gel",
"gel_sdl",
"lace_shared";
project mixed_Joints
is
for Object_Dir use "build";
@@ -14,4 +15,4 @@ is
package Compiler renames Lace_shared.Compiler;
package Binder renames Lace_shared.Binder;
end mixed_Joints;
end mixed_Joints;

View File

@@ -1,7 +1,8 @@
with
"gel",
"gel_sdl",
"lace_shared";
project mixed_Joints_2D
is
for Object_Dir use "build";
@@ -14,4 +15,4 @@ is
package Compiler renames Lace_shared.Compiler;
package Binder renames Lace_shared.Binder;
end mixed_Joints_2D;
end mixed_Joints_2D;

View File

@@ -1,7 +1,8 @@
with
"gel",
"gel_sdl",
"lace_shared";
project mixed_Shapes
is
for Object_Dir use "build";
@@ -14,4 +15,4 @@ is
package Compiler renames Lace_shared.Compiler;
package Binder renames Lace_shared.Binder;
end mixed_Shapes;
end mixed_Shapes;

View File

@@ -1,7 +1,8 @@
with
"gel",
"gel_sdl",
"lace_shared";
project text_sprite_Demo
is
for Object_Dir use "build";
@@ -14,4 +15,4 @@ is
package Compiler renames Lace_shared.Compiler;
package Binder renames Lace_shared.Binder;
end text_sprite_Demo;
end text_sprite_Demo;