Add initial prototype.

This commit is contained in:
Rod Kay
2022-07-31 17:34:54 +10:00
commit 54a53b2ac0
1421 changed files with 358874 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
with
"opengl_demo",
"lace_shared";
project diffuse_Light
is
for Object_Dir use "build";
for Exec_Dir use ".";
for Main use ("launch_diffuse_light.adb");
package Ide renames Lace_shared.Ide;
package Builder renames Lace_shared.Builder;
package Compiler renames Lace_shared.Compiler;
package Binder renames Lace_shared.Binder;
end diffuse_Light;

View File

@@ -0,0 +1,107 @@
with
openGL.Light,
openGL.Visual,
openGL.Model.Box.lit_textured,
openGL.Palette,
openGL.Demo;
procedure launch_diffuse_Light
--
-- Exercise the rendering of models with a diffuse light.
--
is
use openGL,
openGL.Model,
openGL.Math,
openGL.linear_Algebra_3d;
the_Texture : constant asset_Name := to_Asset ("assets/opengl/texture/Face1.bmp");
begin
Demo.print_Usage;
Demo.define ("openGL 'diffuse Light' Demo");
Demo.Camera.Position_is ((0.0, 0.0, 10.0),
y_Rotation_from (to_Radians (0.0)));
declare
use openGL.Model.box,
openGL.Visual.Forge,
openGL.Light,
openGL.Palette;
-- The Model.
--
the_Box : constant Model.Box.lit_textured.view
:= openGL.Model.Box.lit_textured.new_Box (Size => (4.0, 4.0, 4.0),
Faces => (Front => (texture_Name => the_Texture),
Rear => (texture_Name => the_Texture),
Upper => (texture_Name => the_Texture),
Lower => (texture_Name => the_Texture),
Left => (texture_Name => the_Texture),
Right => (texture_Name => the_Texture)));
-- The Visual.
--
the_Visuals : constant openGL.Visual.views := (1 => new_Visual (the_Box.all'Access));
-- The Light.
--
the_Light : openGL.Light.item := Demo.Renderer.new_Light;
initial_Site : constant openGL.Vector_3 := (0.0, 0.0, 15.0);
site_Delta : openGL.Vector_3 := (1.0, 0.0, 0.0);
cone_Direction : constant openGL.Vector_3 := (0.0, 0.0, -1.0);
begin
-- Setup the visual.
--
the_Visuals (1).Site_is (Origin_3D);
the_Visuals (1).Spin_is (y_Rotation_from (to_Radians (20.0)));
-- Setup the light.
--
the_Light. Kind_is (Diffuse);
the_Light. Site_is (initial_Site);
the_Light.Color_is (White);
the_Light. cone_Angle_is (5.0);
the_Light. cone_Direction_is (cone_Direction);
the_Light.ambient_Coefficient_is (0.015);
Demo.Renderer.set (the_Light);
-- Main loop.
--
while not Demo.Done
loop
-- Handle user commands.
--
Demo.Dolly.evolve;
Demo.Done := Demo.Dolly.quit_Requested;
-- Move the light.
--
if the_Light.Site (1) > 2.0 then site_Delta (1) := -0.01;
elsif the_Light.Site (1) < -2.0 then site_Delta (1) := 0.01;
end if;
the_Light.Site_is (the_Light.Site + site_Delta);
Demo.Renderer.set (the_Light);
-- Render the sprites.
--
Demo.Camera.render (the_Visuals);
while not Demo.Camera.cull_Completed
loop
delay Duration'Small;
end loop;
Demo.Renderer.render;
Demo.FPS_Counter.increment; -- Frames per second display.
delay 1.0 / 60.0;
end loop;
end;
Demo.destroy;
end launch_diffuse_Light;

View File

@@ -0,0 +1,104 @@
with
openGL.Light,
openGL.Visual,
openGL.Model.Sphere.lit_colored_textured,
openGL.Model.Sphere.lit_colored,
openGL.Palette,
openGL.Demo;
procedure launch_render_Lighting
--
-- Exercise the rendering of lit models.
--
is
use openGL,
openGL.Model,
openGL.Math,
openGL.linear_Algebra_3d;
the_Texture : constant asset_Name := to_Asset ("assets/opengl/texture/Face1.bmp");
begin
Demo.print_Usage ("To see the light move, disable 'Sync to VBlank'.");
Demo.define ("openGL 'render Lighting' Demo");
Demo.Camera.Position_is ([0.0, 0.0, 10.0],
y_Rotation_from (to_Radians (0.0)));
declare
use openGL.Palette;
-- The Models.
--
the_Ball_1_Model : constant Model.Sphere.lit_colored_textured.view
:= openGL.Model.Sphere.lit_colored_textured.new_Sphere (Radius => 1.0,
Image => the_Texture);
the_Ball_2_Model : constant Model.Sphere.lit_colored.view
:= openGL.Model.Sphere.lit_colored.new_Sphere (Radius => 1.0,
Color => (light_Apricot, Opaque));
-- The Visuals.
--
use openGL.Visual.Forge;
the_Visuals : constant openGL.Visual.views := [1 => new_Visual (the_Ball_1_Model.all'Access),
2 => new_Visual (the_Ball_2_Model.all'Access)];
the_Light : openGL.Light.item := Demo.Renderer.new_Light;
-- Light movement.
--
initial_Site : constant openGL.Vector_3 := [-10_000.0, 0.0, 10_000.0];
site_Delta : openGL.Vector_3 := [ 1.0, 0.0, 0.0];
begin
the_Visuals (1).Site_is ([0.0, 1.0, 0.0]);
the_Visuals (2).Site_is ([0.0, -1.0, 0.0]);
-- Set the lights initial position to far behind and far to the left.
--
the_Light.Site_is (initial_Site);
Demo.Renderer.set (the_Light);
-- Main loop.
--
while not Demo.Done
loop
-- Handle user commands.
--
Demo.Dolly.evolve;
Demo.Done := Demo.Dolly.quit_Requested;
-- Move the light.
--
if the_Light.Site (1) > 10_000.0
then
site_Delta (1) := -1.0;
the_Light.Color_is (Palette.dark_Green);
elsif the_Light.Site (1) < -10_000.0
then
site_Delta (1) := 1.0;
the_Light.Color_is (openGL.Palette.dark_Red);
end if;
the_Light.Site_is (the_Light.Site + site_Delta);
Demo.Renderer.set (the_Light);
-- Render the sprites.
--
Demo.Camera.render (the_Visuals);
while not Demo.Camera.cull_Completed
loop
delay Duration'Small;
end loop;
Demo.Renderer.render;
Demo.FPS_Counter.increment; -- Frames per second display.
end loop;
end;
Demo.destroy;
end launch_render_Lighting;

View File

@@ -0,0 +1,16 @@
with
"opengl_demo",
"lace_shared";
project render_Lighting
is
for Object_Dir use "build";
for Exec_Dir use ".";
for Main use ("launch_render_lighting.adb");
package Ide renames Lace_shared.Ide;
package Builder renames Lace_shared.Builder;
package Compiler renames Lace_shared.Compiler;
package Binder renames Lace_shared.Binder;
end render_Lighting;