Add initial prototype.
16
3-mid/opengl/applet/demo/camera/camera_demo.gpr
Normal file
@@ -0,0 +1,16 @@
|
||||
with
|
||||
"opengl_demo",
|
||||
"lace_shared";
|
||||
|
||||
project camera_Demo
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_camera_demo.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 camera_Demo;
|
||||
69
3-mid/opengl/applet/demo/camera/launch_camera_demo.adb
Normal file
@@ -0,0 +1,69 @@
|
||||
with
|
||||
openGL.Renderer.lean,
|
||||
openGL.Camera,
|
||||
openGL.Visual,
|
||||
openGL.Palette,
|
||||
openGL.Model.box.colored,
|
||||
openGL.Demo;
|
||||
|
||||
procedure launch_Camera_Demo
|
||||
--
|
||||
-- Exercise the camera.
|
||||
--
|
||||
is
|
||||
use openGL,
|
||||
openGL.Model,
|
||||
openGL.Model.box,
|
||||
openGL.Palette,
|
||||
openGL.Math,
|
||||
openGL.linear_Algebra_3d;
|
||||
|
||||
begin
|
||||
Demo.print_Usage;
|
||||
Demo.define ("openGL 'Camera' Demo");
|
||||
|
||||
-- Setup the camera.
|
||||
--
|
||||
Demo.Camera.Position_is ([5.0, 0.0, 10.0],
|
||||
y_Rotation_from (to_Radians (0.0)));
|
||||
|
||||
declare
|
||||
-- The Model.
|
||||
--
|
||||
the_box_Model : constant openGL.Model.Box.colored.view
|
||||
:= openGL.Model.Box.colored.new_Box (size => [0.5, 0.5, 0.5],
|
||||
faces => [front => (colors => [others => (Blue, Opaque)]),
|
||||
rear => (colors => [others => (light_Blue, Opaque)]),
|
||||
upper => (colors => [others => (Green, Opaque)]),
|
||||
lower => (colors => [others => (forest_Green, Opaque)]),
|
||||
left => (colors => [others => (Dark_Red, Opaque)]),
|
||||
right => (colors => [others => (Red, Opaque)])]);
|
||||
|
||||
the_Sprite : constant openGL.Visual.view
|
||||
:= openGL.Visual.Forge.new_Visual (the_box_Model.all'Access);
|
||||
|
||||
begin
|
||||
the_Sprite.Site_is ([10.0, 0.0, 0.0]);
|
||||
|
||||
-- Main loop.
|
||||
--
|
||||
while not Demo.Done
|
||||
loop
|
||||
Demo.Dolly.evolve;
|
||||
Demo.Done := Demo.Dolly.quit_Requested;
|
||||
|
||||
-- Render all sprites.
|
||||
--
|
||||
Demo.Camera.render (Visuals => [1 => the_Sprite]);
|
||||
|
||||
while not Demo.Camera.cull_Completed
|
||||
loop
|
||||
delay Duration'Small;
|
||||
end loop;
|
||||
|
||||
Demo.Renderer.render;
|
||||
end loop;
|
||||
end;
|
||||
|
||||
Demo.destroy;
|
||||
end launch_Camera_Demo;
|
||||
17
3-mid/opengl/applet/demo/core/core_test.gpr
Normal file
@@ -0,0 +1,17 @@
|
||||
with
|
||||
"opengl_demo",
|
||||
"sdlada",
|
||||
"lace_shared";
|
||||
|
||||
project Core_Test
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_core_test.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 Core_Test;
|
||||
57
3-mid/opengl/applet/demo/core/launch_core_test.adb
Normal file
@@ -0,0 +1,57 @@
|
||||
with
|
||||
openGL.Tasks,
|
||||
openGL.Server,
|
||||
|
||||
sdl.Video.Windows.Makers,
|
||||
sdl.Video.gl,
|
||||
|
||||
ada.Task_identification,
|
||||
ada.Text_IO;
|
||||
|
||||
|
||||
procedure launch_core_Test
|
||||
--
|
||||
-- Exercise basic subprograms common to all GL profiles.
|
||||
--
|
||||
-- TODO: Complete this.
|
||||
--
|
||||
is
|
||||
use ada.Text_IO;
|
||||
use type sdl.Video.Windows.window_Flags;
|
||||
|
||||
Error : exception;
|
||||
|
||||
Window : sdl.Video.Windows.Window;
|
||||
gl_Context : sdl.Video.gl.Contexts;
|
||||
|
||||
begin
|
||||
---------
|
||||
--- Setup
|
||||
--
|
||||
|
||||
if not SDL.initialise
|
||||
then
|
||||
raise Error with "Unable to initialise SDL.";
|
||||
end if;
|
||||
|
||||
sdl.Video.Windows.Makers.create (Win => Window,
|
||||
Title => "openGL Demo",
|
||||
X => 100,
|
||||
Y => 100,
|
||||
Width => 200,
|
||||
Height => 200,
|
||||
Flags => sdl.Video.Windows.openGL
|
||||
or sdl.Video.Windows.Resizable);
|
||||
|
||||
sdl.Video.gl.create (gl_Context, From => Window);
|
||||
sdl.Video.gl.set_Current (gl_Context, To => Window);
|
||||
|
||||
openGL.Tasks.renderer_Task := ada.Task_identification.current_Task;
|
||||
|
||||
---------
|
||||
--- Tests
|
||||
--
|
||||
|
||||
put_Line ("openGL Server: " & openGL.Server.Version);
|
||||
delay 2.0;
|
||||
end launch_core_Test;
|
||||
|
After Width: | Height: | Size: 84 KiB |
|
After Width: | Height: | Size: 105 KiB |
@@ -0,0 +1,16 @@
|
||||
with
|
||||
"opengl_demo",
|
||||
"lace_shared";
|
||||
|
||||
project large_terrain_Demo
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_large_terrain_demo.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 large_terrain_Demo;
|
||||
@@ -0,0 +1,80 @@
|
||||
with
|
||||
openGL.Visual,
|
||||
openGL.Terrain,
|
||||
openGL.Demo,
|
||||
openGL.Light;
|
||||
|
||||
|
||||
procedure launch_large_Terrain_Demo
|
||||
--
|
||||
-- Exercise the culler with a large terrain grid.
|
||||
--
|
||||
is
|
||||
use openGL,
|
||||
openGL.Math,
|
||||
openGL.linear_Algebra_3d;
|
||||
|
||||
begin
|
||||
Demo.print_Usage;
|
||||
Demo.define ("openGL 'Large Terrain' Demo");
|
||||
|
||||
-- Setup the camera.
|
||||
--
|
||||
Demo.Camera.Position_is ([0.0, 100.0, 500.0],
|
||||
y_Rotation_from (to_Radians (0.0)));
|
||||
|
||||
-- Set the lights initial position to far behind and far to the left.
|
||||
--
|
||||
declare
|
||||
use openGL.Light;
|
||||
the_Light : openGL.Light.item := Demo.Renderer.new_Light;
|
||||
begin
|
||||
the_Light.Site_is ([0.0, 1000.0, 0.0]);
|
||||
Demo.Renderer.set (the_Light);
|
||||
end;
|
||||
|
||||
|
||||
declare
|
||||
Heights : constant asset_Name := to_Asset ("assets/kidwelly-terrain-510x510.png");
|
||||
Texture : constant asset_Name := to_Asset ("assets/kidwelly-terrain-texture-255x255.png");
|
||||
|
||||
Terrain : constant openGL.Visual.Grid := openGL.Terrain.new_Terrain (heights_File => Heights,
|
||||
texture_File => Texture,
|
||||
Scale => [1.0, 25.0, 1.0]);
|
||||
Count : constant Positive := Terrain'Length (1)
|
||||
* Terrain'Length (2);
|
||||
Last : Natural := 0;
|
||||
Sprites : openGL.Visual.views (1 .. Count);
|
||||
|
||||
begin
|
||||
for Row in Terrain'Range (1)
|
||||
loop
|
||||
for Col in Terrain'Range (2)
|
||||
loop
|
||||
Last := Last + 1;
|
||||
Sprites (Last) := Terrain (Row, Col);
|
||||
end loop;
|
||||
end loop;
|
||||
|
||||
|
||||
-- Main loop.
|
||||
--
|
||||
while not Demo.Done
|
||||
loop
|
||||
Demo.Dolly.evolve;
|
||||
Demo.Done := Demo.Dolly.quit_Requested;
|
||||
|
||||
Demo.Camera.render (Sprites (1 .. Last));
|
||||
|
||||
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_large_Terrain_Demo;
|
||||
BIN
3-mid/opengl/applet/demo/culler/many_boxes/assets/Face1.bmp
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
@@ -0,0 +1,84 @@
|
||||
with
|
||||
openGL.Palette,
|
||||
openGL.Model.Box.lit_colored_textured,
|
||||
openGL.Visual,
|
||||
|
||||
openGL.Demo;
|
||||
|
||||
|
||||
procedure launch_many_Boxes_Demo
|
||||
--
|
||||
-- Exercise the culler with many boxes.
|
||||
--
|
||||
is
|
||||
use openGL,
|
||||
openGL.Model,
|
||||
openGL.Model.box,
|
||||
openGL.Palette,
|
||||
openGL.Math,
|
||||
openGL.linear_Algebra_3d;
|
||||
|
||||
begin
|
||||
Demo.print_Usage;
|
||||
Demo.define ("openGL 'many Boxes' Demo");
|
||||
|
||||
-- Setup the camera.
|
||||
--
|
||||
Demo.Camera.Position_is ([0.0, 0.0, 5.0],
|
||||
y_Rotation_from (to_Radians (0.0)));
|
||||
|
||||
declare
|
||||
Face : constant asset_Name := to_Asset ("assets/Face1.bmp");
|
||||
|
||||
the_box_Model : constant Box.lit_colored_textured.view
|
||||
:= Box.lit_colored_textured.new_Box
|
||||
(size => [0.5, 0.5, 0.5],
|
||||
faces => [front => (colors => [others => (White, Opaque)], texture_name => Face),
|
||||
rear => (colors => [others => (Blue, Opaque)], texture_name => Face),
|
||||
upper => (colors => [others => (Green, Opaque)], texture_name => Face),
|
||||
lower => (colors => [others => (Green, Opaque)], texture_name => Face),
|
||||
left => (colors => [others => (Dark_Red, Opaque)], texture_name => Face),
|
||||
right => (colors => [others => (Red, Opaque)], texture_name => Face)]);
|
||||
|
||||
Size : constant Integer := 70;
|
||||
x : openGL.Real := -openGL.Real (Size) / 2.0;
|
||||
z : openGL.Real := 0.0;
|
||||
|
||||
Sprites : constant Visual.views (1 .. Size * Size) := [others => Visual.Forge.new_Visual (Model.view (the_box_Model))];
|
||||
|
||||
begin
|
||||
for i in Sprites'Range
|
||||
loop
|
||||
x := x + 1.0;
|
||||
|
||||
if i mod Size = 0
|
||||
then
|
||||
z := z - 1.0;
|
||||
x := -openGL.Real (Size) / 2.0;
|
||||
end if;
|
||||
|
||||
Sprites (i).Site_is ([x, 0.0, z]);
|
||||
end loop;
|
||||
|
||||
|
||||
-- Main loop.
|
||||
--
|
||||
while not Demo.Done
|
||||
loop
|
||||
Demo.Dolly.evolve;
|
||||
Demo.Done := Demo.Dolly.quit_Requested;
|
||||
|
||||
Demo.Camera.render (Sprites);
|
||||
|
||||
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_many_Boxes_Demo;
|
||||
@@ -0,0 +1,16 @@
|
||||
with
|
||||
"opengl_demo",
|
||||
"lace_shared";
|
||||
|
||||
project Many_Boxes_Demo
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_many_boxes_demo.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 Many_Boxes_Demo;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -0,0 +1,87 @@
|
||||
with
|
||||
openGL.Visual,
|
||||
openGL.Demo,
|
||||
openGL.Model.terrain;
|
||||
|
||||
|
||||
procedure launch_Model_scaling
|
||||
--
|
||||
-- Exercise the scaling of models.
|
||||
--
|
||||
is
|
||||
use openGL,
|
||||
openGL.Math,
|
||||
openGL.linear_Algebra_3d;
|
||||
begin
|
||||
Demo.print_Usage;
|
||||
Demo.define ("openGL 'Model Scaling' Demo");
|
||||
Demo.Camera.Position_is ([0.0, 0.0, 20.0],
|
||||
y_Rotation_from (to_Radians (0.0)));
|
||||
declare
|
||||
-- The models.
|
||||
--
|
||||
the_Models : constant openGL.Model.views := openGL.Demo.Models;
|
||||
|
||||
-- The visuals.
|
||||
--
|
||||
the_Visuals : openGL.Visual.views (the_Models'Range);
|
||||
ground_Id : Positive;
|
||||
|
||||
-- Scaling
|
||||
--
|
||||
scaling_Up : Boolean := True;
|
||||
Scale : math.Vector_3 := [1.0, 1.0, 1.0];
|
||||
|
||||
begin
|
||||
for i in the_Visuals'Range
|
||||
loop
|
||||
the_Visuals (i) := Visual.Forge.new_Visual (the_Models (i));
|
||||
|
||||
if the_Models (i).all in openGL.Model.terrain.item'Class
|
||||
then
|
||||
ground_Id := i;
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
Demo.layout (the_Visuals);
|
||||
the_Visuals (ground_Id).Site_is (the_Visuals (ground_Id).Site_of + [0.0, -15.0, 0.0]);
|
||||
|
||||
|
||||
-- Main loop.
|
||||
--
|
||||
while not Demo.Done
|
||||
loop
|
||||
if scaling_Up then Scale := Scale + [0.001, 0.001, 0.001];
|
||||
else Scale := Scale - [0.001, 0.001, 0.001];
|
||||
end if;
|
||||
|
||||
if Scale (1) > 2.0 then scaling_Up := False;
|
||||
elsif Scale (1) < 0.002 then scaling_Up := True;
|
||||
end if;
|
||||
|
||||
for Each of the_Visuals
|
||||
loop
|
||||
Each.Scale_is (Scale);
|
||||
end loop;
|
||||
|
||||
-- Handle user commands.
|
||||
--
|
||||
Demo.Dolly.evolve;
|
||||
Demo.Done := Demo.Dolly.quit_Requested;
|
||||
|
||||
-- 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_Model_scaling;
|
||||
@@ -0,0 +1,20 @@
|
||||
with
|
||||
"opengl_demo",
|
||||
"lace_shared";
|
||||
|
||||
project Model_scaling
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_model_scaling.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;
|
||||
|
||||
package Linker is
|
||||
for Default_Switches ("ada") use ("-g", "-lX11", "-lGL", "-lexpat");
|
||||
end Linker;
|
||||
|
||||
end Model_scaling;
|
||||
@@ -0,0 +1,80 @@
|
||||
with
|
||||
openGL.Visual,
|
||||
openGL.Model.Arrow.colored,
|
||||
openGL.Demo;
|
||||
|
||||
|
||||
procedure launch_render_Arrows
|
||||
--
|
||||
-- Exercise the render of arrow models.
|
||||
--
|
||||
is
|
||||
use openGL,
|
||||
openGL.Model,
|
||||
openGL.Math,
|
||||
openGL.linear_Algebra_3d;
|
||||
begin
|
||||
Demo.print_Usage;
|
||||
Demo.define ("openGL 'Render Arrows' Demo");
|
||||
Demo.Camera.Position_is ([0.0, 0.0, 10.0],
|
||||
y_Rotation_from (to_Radians (0.0)));
|
||||
declare
|
||||
-- The Models.
|
||||
--
|
||||
the_Arrow_Model : constant Model.Arrow.colored.view
|
||||
:= Model.Arrow.colored.new_Arrow (End_2 => [0.0, 5.0, 0.0]);
|
||||
|
||||
the_spinner_Arrow_Model : constant Model.Arrow.colored.view
|
||||
:= Model.Arrow.colored.new_Arrow (End_1 => [0.0, -2.5, 0.0],
|
||||
End_2 => [0.0, 2.5, 0.0]);
|
||||
-- The Sprites.
|
||||
--
|
||||
use openGL.Visual.Forge;
|
||||
|
||||
the_Sprites : constant openGL.Visual.views := [new_Visual ( the_Arrow_Model.all'Access),
|
||||
new_Visual (the_spinner_Arrow_Model.all'Access)];
|
||||
Angle : Radians := 0.0;
|
||||
Site : openGL.Vector_2;
|
||||
|
||||
use openGL.Geometry_2d;
|
||||
begin
|
||||
-- Main loop.
|
||||
--
|
||||
while not Demo.Done
|
||||
loop
|
||||
Site := to_Site (polar_Site' (Angle => Angle,
|
||||
Extent => 5.0));
|
||||
|
||||
the_Arrow_Model.End_Site_is (Now => math.Vector_3 (Site & 0.0),
|
||||
for_End => 2);
|
||||
|
||||
the_Sprites (2).Spin_is (to_Rotation (Axis => [0.0, 0.0, 1.0],
|
||||
Angle => Angle));
|
||||
-- Handle user commands.
|
||||
--
|
||||
Demo.Dolly.evolve;
|
||||
Demo.Done := Demo.Dolly.quit_Requested;
|
||||
|
||||
-- Render the sprites.
|
||||
--
|
||||
Demo.Camera.render (the_Sprites);
|
||||
|
||||
while not Demo.Camera.cull_Completed
|
||||
loop
|
||||
delay Duration'Small;
|
||||
end loop;
|
||||
|
||||
Demo.Renderer.render;
|
||||
Demo.FPS_Counter.increment; -- Frames per second display.
|
||||
|
||||
Angle := Angle + 0.001;
|
||||
|
||||
if Angle >= to_Radians (Degrees' (360.0))
|
||||
then
|
||||
Angle := 0.0;
|
||||
end if;
|
||||
end loop;
|
||||
end;
|
||||
|
||||
Demo.destroy;
|
||||
end launch_render_Arrows;
|
||||
@@ -0,0 +1,20 @@
|
||||
with
|
||||
"opengl_demo",
|
||||
"lace_shared";
|
||||
|
||||
project render_Arrows
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_render_arrows.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;
|
||||
|
||||
package Linker is
|
||||
for Default_Switches ("ada") use ("-g", "-lX11", "-lGL");
|
||||
end Linker;
|
||||
|
||||
end render_Arrows;
|
||||
2701
3-mid/opengl/applet/demo/models/render_asteroids/assets/gaspra.tab
Normal file
@@ -0,0 +1,95 @@
|
||||
with
|
||||
openGL.Model.any,
|
||||
openGL.Visual,
|
||||
openGL.Light.directional,
|
||||
openGL.Demo;
|
||||
|
||||
procedure launch_render_Asteroids
|
||||
--
|
||||
-- Render with a few asteroids.
|
||||
--
|
||||
is
|
||||
use openGL,
|
||||
openGL.Math,
|
||||
openGL.linear_Algebra_3d;
|
||||
|
||||
begin
|
||||
Demo.define ("openGL 'Render Asteroids' Demo");
|
||||
Demo.print_Usage ("Use space ' ' to cycle through models.");
|
||||
Demo.Camera.Position_is ((0.0, 0.0, 200.0),
|
||||
y_Rotation_from (to_Radians (0.0)));
|
||||
|
||||
declare
|
||||
the_Light : openGL.Light.directional.item := Demo.Renderer.Light (1);
|
||||
begin
|
||||
the_Light.Site_is ((5_000.0, 2_000.0, 5_000.0));
|
||||
Demo.Renderer.Light_is (1, the_Light);
|
||||
end;
|
||||
|
||||
declare
|
||||
-- The models.
|
||||
--
|
||||
|
||||
gaspra_Model : constant openGL.Model.any.view := openGL.Model.any.new_Model (Model => to_Asset ("assets/gaspra.tab"),
|
||||
Texture => null_Asset,
|
||||
Texture_is_lucid => False);
|
||||
the_Models : constant openGL.Model.views := (1 => gaspra_Model.all'unchecked_Access);
|
||||
|
||||
-- The visuals.
|
||||
--
|
||||
use openGL.Visual.Forge;
|
||||
|
||||
the_Visuals : openGL.Visual.views (the_Models'Range);
|
||||
Current : Integer := the_Visuals'First;
|
||||
|
||||
begin
|
||||
for i in the_Visuals'Range
|
||||
loop
|
||||
the_Visuals (i) := new_Visual (the_Models (i));
|
||||
end loop;
|
||||
|
||||
-- Main loop.
|
||||
--
|
||||
while not Demo.Done
|
||||
loop
|
||||
Demo.Dolly.evolve;
|
||||
Demo.Done := Demo.Dolly.quit_Requested;
|
||||
|
||||
declare
|
||||
Command : Character;
|
||||
Avail : Boolean;
|
||||
begin
|
||||
Demo.Dolly.get_last_Character (Command, Avail);
|
||||
|
||||
if Avail
|
||||
then
|
||||
case Command
|
||||
is
|
||||
when ' ' =>
|
||||
if Current = the_Visuals'Last
|
||||
then Current := the_Visuals'First;
|
||||
else Current := Current + 1;
|
||||
end if;
|
||||
|
||||
when others =>
|
||||
null;
|
||||
end case;
|
||||
end if;
|
||||
end;
|
||||
|
||||
-- Render all visuals.
|
||||
--
|
||||
Demo.Camera.render ((1 => the_Visuals (Current)));
|
||||
|
||||
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_Asteroids;
|
||||
@@ -0,0 +1,16 @@
|
||||
with
|
||||
"opengl_demo",
|
||||
"lace_shared";
|
||||
|
||||
project render_Asteroids
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_render_asteroids.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_Asteroids;
|
||||
@@ -0,0 +1,70 @@
|
||||
with
|
||||
openGL.Visual,
|
||||
openGL.Model.Billboard. textured,
|
||||
openGL.Model.Billboard.colored_textured,
|
||||
openGL.Palette,
|
||||
openGL.Demo;
|
||||
|
||||
procedure launch_render_Billboards
|
||||
--
|
||||
-- Exercise the render of billboard models.
|
||||
--
|
||||
is
|
||||
use openGL,
|
||||
openGL.Model,
|
||||
openGL.Math,
|
||||
openGL.linear_Algebra_3d;
|
||||
|
||||
the_Texture : constant openGL.asset_Name := to_Asset ("assets/opengl/texture/Face1.bmp");
|
||||
begin
|
||||
Demo.print_Usage;
|
||||
Demo.define ("openGL 'Render Billboards' Demo");
|
||||
Demo.Camera.Position_is ([0.0, 0.0, 10.0],
|
||||
y_Rotation_from (to_Radians (0.0)));
|
||||
declare
|
||||
-- The Models.
|
||||
--
|
||||
the_Billboard_Model : constant Model.Billboard.textured.view
|
||||
:= Model.Billboard.textured.forge.new_Billboard (--Scale => (1.0, 1.0, 1.0),
|
||||
Plane => Billboard.xy,
|
||||
Texture => the_Texture);
|
||||
|
||||
the_colored_Billboard_Model : constant Model.Billboard.colored_textured.view
|
||||
:= Model.Billboard.colored_textured.new_Billboard (--Scale => (1.0, 1.0, 1.0),
|
||||
Plane => Billboard.xy,
|
||||
Color => (Palette.Green, Opaque),
|
||||
Texture => the_Texture);
|
||||
-- The Sprites.
|
||||
--
|
||||
use openGL.Visual.Forge;
|
||||
|
||||
the_Sprites : constant openGL.Visual.views := [new_Visual ( the_Billboard_Model.all'Access),
|
||||
new_Visual (the_colored_Billboard_Model.all'Access)];
|
||||
begin
|
||||
the_Sprites (2).Site_is ([3.0, 0.0, 0.0]);
|
||||
|
||||
-- Main loop.
|
||||
--
|
||||
while not Demo.Done
|
||||
loop
|
||||
-- Handle user commands.
|
||||
--
|
||||
Demo.Dolly.evolve;
|
||||
Demo.Done := Demo.Dolly.quit_Requested;
|
||||
|
||||
-- Render the sprites.
|
||||
--
|
||||
Demo.Camera.render (the_Sprites);
|
||||
|
||||
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_Billboards;
|
||||
@@ -0,0 +1,21 @@
|
||||
with
|
||||
"opengl_demo",
|
||||
"lace_shared";
|
||||
|
||||
project render_Billboards
|
||||
is
|
||||
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_render_billboards.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;
|
||||
|
||||
package Linker is
|
||||
for Default_Switches ("ada") use ("-g", "-lX11", "-lGL");
|
||||
end Linker;
|
||||
|
||||
end render_Billboards;
|
||||
@@ -0,0 +1,99 @@
|
||||
with
|
||||
openGL.Visual,
|
||||
|
||||
openGL.Model.Box. colored,
|
||||
openGL.Model.Box.textured,
|
||||
openGL.Model.Box.lit_colored_textured,
|
||||
|
||||
openGL.Palette,
|
||||
openGL.Demo;
|
||||
|
||||
procedure launch_render_Boxes
|
||||
--
|
||||
-- Exercise the rendering of box models.
|
||||
--
|
||||
is
|
||||
use openGL,
|
||||
openGL.Model,
|
||||
openGL.Math,
|
||||
openGL.linear_Algebra_3d;
|
||||
|
||||
the_Texture : constant openGL.asset_Name := to_Asset ("assets/opengl/texture/Face1.bmp");
|
||||
begin
|
||||
Demo.print_Usage;
|
||||
Demo.define ("openGL 'Render Boxes' Demo");
|
||||
Demo.Camera.Position_is ([0.0, 0.0, 10.0],
|
||||
y_Rotation_from (to_Radians (0.0)));
|
||||
declare
|
||||
use openGL.Model.box,
|
||||
openGL.Palette;
|
||||
|
||||
-- The Models.
|
||||
--
|
||||
the_Box_1_Model : constant Model.Box.colored.view
|
||||
:= Model.Box.colored.new_Box
|
||||
(Size => [1.0, 2.0, 1.0],
|
||||
Faces => [Front => (Colors => [others => (Blue, Opaque)]),
|
||||
Rear => (Colors => [others => (Blue, Opaque)]),
|
||||
Upper => (Colors => [others => (Green, Opaque)]),
|
||||
Lower => (Colors => [others => (Green, Opaque)]),
|
||||
Left => (Colors => [others => (Dark_Red, Opaque)]),
|
||||
Right => (Colors => [others => (Red, Opaque)])]);
|
||||
|
||||
the_Box_2_Model : constant Model.Box.lit_colored_textured.view
|
||||
:= Model.Box.lit_colored_textured.new_Box
|
||||
(Size => [1.0, 2.0, 1.0],
|
||||
Faces => [Front => (Colors => [others => (Blue, Opaque)], texture_Name => the_Texture),
|
||||
Rear => (Colors => [others => (Blue, Opaque)], texture_Name => the_Texture),
|
||||
Upper => (Colors => [others => (Green, Opaque)], texture_Name => the_Texture),
|
||||
Lower => (Colors => [others => (Green, Opaque)], texture_Name => the_Texture),
|
||||
Left => (Colors => [others => (Dark_Red, Opaque)], texture_Name => the_Texture),
|
||||
Right => (Colors => [others => (Red, Opaque)], texture_Name => the_Texture)]);
|
||||
|
||||
the_Box_3_Model : constant Model.Box.textured.view
|
||||
:= Model.Box.textured.new_Box
|
||||
(Size => [1.0, 2.0, 1.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 Visuals.
|
||||
--
|
||||
use openGL.Visual.Forge;
|
||||
|
||||
the_Visuals : constant openGL.Visual.views := [1 => new_Visual (the_Box_1_Model.all'Access),
|
||||
2 => new_Visual (the_Box_2_Model.all'Access),
|
||||
3 => new_Visual (the_Box_3_Model.all'Access)];
|
||||
begin
|
||||
the_Visuals (1).Site_is ([-3.0, 0.0, 0.0]);
|
||||
the_Visuals (2).Site_is ([ 0.0, 0.0, 0.0]);
|
||||
the_Visuals (3).Site_is ([ 3.0, 0.0, 0.0]);
|
||||
|
||||
-- Main loop.
|
||||
--
|
||||
while not Demo.Done
|
||||
loop
|
||||
-- Handle user commands.
|
||||
--
|
||||
Demo.Dolly.evolve;
|
||||
Demo.Done := Demo.Dolly.quit_Requested;
|
||||
|
||||
-- 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_Boxes;
|
||||
@@ -0,0 +1,16 @@
|
||||
with
|
||||
"opengl_demo",
|
||||
"lace_shared";
|
||||
|
||||
project render_Boxes
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_render_boxes.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_Boxes;
|
||||
@@ -0,0 +1,71 @@
|
||||
with
|
||||
openGL.Visual,
|
||||
openGL.Model.Capsule.lit_colored_textured,
|
||||
openGL.Palette,
|
||||
openGL.Light,
|
||||
openGL.Demo;
|
||||
|
||||
|
||||
procedure launch_render_Capsules
|
||||
--
|
||||
-- Exercise the render of capsule models.
|
||||
--
|
||||
is
|
||||
use openGL,
|
||||
openGL.Model,
|
||||
openGL.Math,
|
||||
openGL.linear_Algebra_3d;
|
||||
begin
|
||||
Demo.print_Usage;
|
||||
Demo.define ("openGL 'Render Capsules' Demo");
|
||||
Demo.Camera.Position_is ([0.0, 3.0, 10.0],
|
||||
y_Rotation_from (to_Radians (-0.0)));
|
||||
Demo.Dolly.Speed_is (0.1);
|
||||
|
||||
declare
|
||||
use openGL.Palette;
|
||||
|
||||
the_Light : openGL.Light.item := Demo.Renderer.new_Light;
|
||||
the_Texture : constant asset_Name := to_Asset ("assets/opengl/texture/Face1.bmp");
|
||||
|
||||
-- The Models.
|
||||
--
|
||||
the_Capsule_Model : constant Model.Capsule.lit_colored_textured.view
|
||||
:= Model.Capsule.lit_colored_textured.new_Capsule (Radius => 0.5,
|
||||
Height => 2.0,
|
||||
Color => (White, Opaque),
|
||||
Image => the_Texture);
|
||||
-- The Visuals.
|
||||
--
|
||||
use openGL.Visual.Forge;
|
||||
|
||||
the_Visuals : constant openGL.Visual.views := [1 => new_Visual (the_Capsule_Model.all'Access)];
|
||||
begin
|
||||
the_Light.Site_is ([0.0, 5.0, 10.0]);
|
||||
Demo.Renderer.set (the_Light);
|
||||
|
||||
-- Main loop.
|
||||
--
|
||||
while not Demo.Done
|
||||
loop
|
||||
-- Handle user commands.
|
||||
--
|
||||
Demo.Dolly.evolve;
|
||||
Demo.Done := Demo.Dolly.quit_Requested;
|
||||
|
||||
-- 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_Capsules;
|
||||
@@ -0,0 +1,16 @@
|
||||
with
|
||||
"opengl_demo",
|
||||
"lace_shared";
|
||||
|
||||
project render_Capsules
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_render_capsules.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_Capsules;
|
||||
@@ -0,0 +1,206 @@
|
||||
with
|
||||
openGL.Model.hex_grid,
|
||||
openGL.Visual,
|
||||
openGL.Light,
|
||||
openGL.Palette,
|
||||
openGL.IO,
|
||||
openGL.Demo;
|
||||
|
||||
|
||||
procedure launch_render_Hex_Grid
|
||||
--
|
||||
-- Renders a hexagon grid.
|
||||
--
|
||||
is
|
||||
use openGL,
|
||||
openGL.Math,
|
||||
openGL.linear_Algebra_3D,
|
||||
openGL.Palette;
|
||||
|
||||
begin
|
||||
Demo.print_Usage;
|
||||
Demo.define ("openGL 'Render Hex Grid' Demo",
|
||||
Width => 1_000,
|
||||
Height =>1_000);
|
||||
|
||||
Demo.Camera.Position_is ([0.0, 40.0, 0.0],
|
||||
x_Rotation_from (to_Radians (90.0)));
|
||||
|
||||
-- declare
|
||||
-- use openGL.Light;
|
||||
-- the_Light : openGL.Light.item := Demo.Renderer.new_Light;
|
||||
-- begin
|
||||
-- the_Light.Site_is ([5_000.0, 2_000.0, 5_000.0]);
|
||||
-- the_Light.Color_is (White);
|
||||
--
|
||||
-- Demo.Renderer.set (the_Light);
|
||||
-- end;
|
||||
|
||||
|
||||
declare
|
||||
-- The models.
|
||||
--
|
||||
|
||||
heights_File : constant asset_Name := to_Asset ("assets/kidwelly-terrain-127x127.png");
|
||||
|
||||
heights_File_1x1 : constant asset_Name := to_Asset ("assets/test-1x1.png");
|
||||
|
||||
heights_File_2x1 : constant asset_Name := to_Asset ("assets/test-2x1.png");
|
||||
heights_File_1x2 : constant asset_Name := to_Asset ("assets/test-1x2.png");
|
||||
heights_File_2x2 : constant asset_Name := to_Asset ("assets/test-2x2.png");
|
||||
|
||||
heights_File_3x1 : constant asset_Name := to_Asset ("assets/test-3x1.png");
|
||||
heights_File_1x3 : constant asset_Name := to_Asset ("assets/test-1x3.png");
|
||||
|
||||
|
||||
heights_File_3x3 : constant asset_Name := to_Asset ("assets/test-3x3.png");
|
||||
heights_File_4x4 : constant asset_Name := to_Asset ("assets/test-4x4.png");
|
||||
heights_File_5x5 : constant asset_Name := to_Asset ("assets/test-5x5.png");
|
||||
|
||||
|
||||
the_Region : constant IO.height_Map_view := IO.to_height_Map (heights_File, 10.0);
|
||||
|
||||
the_Region_1x1 : constant IO.height_Map_view := IO.to_height_Map (heights_File_1x1, 10.0);
|
||||
|
||||
the_Region_2x1 : constant IO.height_Map_view := IO.to_height_Map (heights_File_2x1, 10.0);
|
||||
the_Region_1x2 : constant IO.height_Map_view := IO.to_height_Map (heights_File_1x2, 10.0);
|
||||
the_Region_2x2 : constant IO.height_Map_view := IO.to_height_Map (heights_File_2x2, 10.0);
|
||||
|
||||
the_Region_3x1 : constant IO.height_Map_view := IO.to_height_Map (heights_File_3x1, 10.0);
|
||||
the_Region_1x3 : constant IO.height_Map_view := IO.to_height_Map (heights_File_1x3, 10.0);
|
||||
|
||||
the_Region_3x3 : constant IO.height_Map_view := IO.to_height_Map (heights_File_3x3, 10.0);
|
||||
the_Region_4x4 : constant IO.height_Map_view := IO.to_height_Map (heights_File_4x4, 10.0);
|
||||
the_Region_5x5 : constant IO.height_Map_view := IO.to_height_Map (heights_File_5x5, 10.0);
|
||||
|
||||
Color : constant openGL.lucid_Color := (Green, Opaque);
|
||||
|
||||
the_grid_Model : constant Model.hex_grid.view
|
||||
:= Model.hex_grid.new_Grid (heights_Asset => heights_File,
|
||||
Heights => the_Region.all'Access,
|
||||
Color => Color);
|
||||
|
||||
the_grid_Model_1x1 : constant Model.hex_grid.view
|
||||
:= Model.hex_grid.new_Grid (heights_Asset => heights_File_1x1,
|
||||
Heights => the_Region_1x1.all'Access,
|
||||
Color => Color);
|
||||
|
||||
the_grid_Model_2x1 : constant Model.hex_grid.view
|
||||
:= Model.hex_grid.new_Grid (heights_Asset => heights_File_2x1,
|
||||
Heights => the_Region_2x1.all'Access,
|
||||
Color => Color);
|
||||
|
||||
the_grid_Model_1x2 : constant Model.hex_grid.view
|
||||
:= Model.hex_grid.new_Grid (heights_Asset => heights_File_1x2,
|
||||
Heights => the_Region_1x2.all'Access,
|
||||
Color => Color);
|
||||
|
||||
the_grid_Model_2x2 : constant Model.hex_grid.view
|
||||
:= Model.hex_grid.new_Grid (heights_Asset => heights_File_2x2,
|
||||
Heights => the_Region_2x2.all'Access,
|
||||
Color => Color);
|
||||
|
||||
the_grid_Model_3x1 : constant Model.hex_grid.view
|
||||
:= Model.hex_grid.new_Grid (heights_Asset => heights_File_3x1,
|
||||
Heights => the_Region_3x1.all'Access,
|
||||
Color => Color);
|
||||
|
||||
the_grid_Model_1x3 : constant Model.hex_grid.view
|
||||
:= Model.hex_grid.new_Grid (heights_Asset => heights_File_1x3,
|
||||
Heights => the_Region_1x3.all'Access,
|
||||
Color => Color);
|
||||
|
||||
the_grid_Model_3x3 : constant Model.hex_grid.view
|
||||
:= Model.hex_grid.new_Grid (heights_Asset => heights_File_3x3,
|
||||
Heights => the_Region_3x3.all'Access,
|
||||
Color => Color);
|
||||
|
||||
the_grid_Model_4x4 : constant Model.hex_grid.view
|
||||
:= Model.hex_grid.new_Grid (heights_Asset => heights_File_4x4,
|
||||
Heights => the_Region_4x4.all'Access,
|
||||
Color => Color);
|
||||
|
||||
the_grid_Model_5x5 : constant Model.hex_grid.view
|
||||
:= Model.hex_grid.new_Grid (heights_Asset => heights_File_5x5,
|
||||
Heights => the_Region_5x5.all'Access,
|
||||
Color => Color);
|
||||
|
||||
-- The visual.
|
||||
--
|
||||
use openGL.Visual.Forge;
|
||||
|
||||
the_Grid : constant openGL.Visual.view := new_Visual (the_grid_Model .all'Access);
|
||||
|
||||
the_Grid_1x1 : constant openGL.Visual.view := new_Visual (the_grid_Model_1x1.all'Access);
|
||||
|
||||
the_Grid_2x1 : constant openGL.Visual.view := new_Visual (the_grid_Model_2x1.all'Access);
|
||||
the_Grid_1x2 : constant openGL.Visual.view := new_Visual (the_grid_Model_1x2.all'Access);
|
||||
the_Grid_2x2 : constant openGL.Visual.view := new_Visual (the_grid_Model_2x2.all'Access);
|
||||
|
||||
the_Grid_3x1 : constant openGL.Visual.view := new_Visual (the_grid_Model_3x1.all'Access);
|
||||
the_Grid_1x3 : constant openGL.Visual.view := new_Visual (the_grid_Model_1x3.all'Access);
|
||||
|
||||
the_Grid_3x3 : constant openGL.Visual.view := new_Visual (the_grid_Model_3x3.all'Access);
|
||||
the_Grid_4x4 : constant openGL.Visual.view := new_Visual (the_grid_Model_4x4.all'Access);
|
||||
the_Grid_5x5 : constant openGL.Visual.view := new_Visual (the_grid_Model_5x5.all'Access);
|
||||
|
||||
begin
|
||||
the_Grid .Site_is ([ 0.0, 0.0, 0.0]);
|
||||
|
||||
the_Grid_1x1.Site_is ([ 0.0, 0.0, -10.0]);
|
||||
|
||||
the_Grid_2x1.Site_is ([ 0.0, 0.0, 0.0]);
|
||||
the_Grid_1x2.Site_is ([ 0.0, 0.0, 5.0]);
|
||||
the_Grid_2x2.Site_is ([ 0.0, 0.0, -5.0]);
|
||||
|
||||
the_Grid_3x1.Site_is ([ 5.0, 0.0, 0.0]);
|
||||
the_Grid_1x3.Site_is ([ 5.0, 0.0, 5.0]);
|
||||
|
||||
the_Grid_3x3.Site_is ([-10.0, 0.0, -10.0]);
|
||||
the_Grid_4x4.Site_is ([-10.0, 0.0, 0.0]);
|
||||
the_Grid_5x5.Site_is ([-10.0, 0.0, 10.0]);
|
||||
|
||||
|
||||
-- Main loop.
|
||||
--
|
||||
while not Demo.Done
|
||||
loop
|
||||
Demo.Dolly.evolve;
|
||||
Demo.Done := Demo.Dolly.quit_Requested;
|
||||
|
||||
-- Render all visuals.
|
||||
--
|
||||
|
||||
Demo.Camera.render ([1 => the_Grid]);
|
||||
|
||||
-- Demo.Camera.render ([1 => the_Grid_1x1]);
|
||||
-- Demo.Camera.render ([1 => the_Grid_2x1]);
|
||||
-- Demo.Camera.render ([1 => the_Grid_1x2]);
|
||||
-- Demo.Camera.render ([1 => the_Grid_3x1]);
|
||||
|
||||
-- Demo.Camera.render ([the_Grid_1x1,
|
||||
--
|
||||
-- the_Grid_2x1,
|
||||
-- the_Grid_1x2,
|
||||
-- the_Grid_2x2,
|
||||
--
|
||||
-- the_Grid_3x1,
|
||||
-- the_Grid_1x3,
|
||||
--
|
||||
-- the_Grid_3x3,
|
||||
-- the_Grid_4x4,
|
||||
-- the_Grid_5x5]);
|
||||
|
||||
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_render_Hex_Grid;
|
||||
@@ -0,0 +1,16 @@
|
||||
with
|
||||
"opengl_demo",
|
||||
"lace_shared";
|
||||
|
||||
project render_Hex_Grid
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_render_hex_grid.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_Hex_Grid;
|
||||
|
After Width: | Height: | Size: 105 KiB |
|
After Width: | Height: | Size: 34 KiB |
@@ -0,0 +1,129 @@
|
||||
with
|
||||
openGL.Model,
|
||||
openGL.Visual,
|
||||
openGL.Light,
|
||||
openGL.Palette,
|
||||
openGL.Demo;
|
||||
|
||||
|
||||
procedure launch_render_Models
|
||||
--
|
||||
-- Exercise the renderer with an example of all the models.
|
||||
--
|
||||
is
|
||||
use openGL,
|
||||
openGL.Math,
|
||||
openGL.linear_Algebra_3D,
|
||||
openGL.Palette;
|
||||
|
||||
begin
|
||||
Demo.print_Usage ("Use space ' ' to cycle through models.");
|
||||
Demo.define ("openGL 'Render Models' Demo");
|
||||
Demo.Camera.Position_is ([0.0, 2.0, 10.0],
|
||||
y_Rotation_from (to_Radians (0.0)));
|
||||
|
||||
declare
|
||||
use openGL.Light;
|
||||
the_Light : openGL.Light.item := Demo.Renderer.new_Light;
|
||||
begin
|
||||
-- the_Light.Kind_is (Diffuse);
|
||||
-- the_Light.Site_is ((0.0, 0.0, 5.0));
|
||||
the_Light.Site_is ([5_000.0, 2_000.0, 5_000.0]);
|
||||
-- the_Light.Site_is ((000.0, 5_000.0, 000.0));
|
||||
|
||||
the_Light.Color_is (White);
|
||||
-- the_Light.ambient_Coefficient_is (0.91);
|
||||
|
||||
Demo.Renderer.set (the_Light);
|
||||
end;
|
||||
|
||||
|
||||
-- Set the lights initial position to far behind and far to the left.
|
||||
--
|
||||
-- declare
|
||||
-- use openGL.Palette;
|
||||
--
|
||||
-- initial_Site : constant openGL.Vector_3 := (0.0, 0.0, 15.0);
|
||||
-- cone_Direction : constant openGL.Vector_3 := (0.0, 0.0, -1.0);
|
||||
--
|
||||
-- Light : openGL.Light.diffuse.item := Demo.Renderer.Light (Id => 1);
|
||||
-- begin
|
||||
-- Light.Color_is (Ambient => (Grey, Opaque),
|
||||
-- Diffuse => (White, Opaque));
|
||||
-- -- Specular => (White, Opaque));
|
||||
--
|
||||
-- Light.Position_is (initial_Site);
|
||||
-- Light.cone_Direction_is (cone_Direction);
|
||||
--
|
||||
-- Demo.Renderer.Light_is (Id => 1, Now => Light);
|
||||
-- end;
|
||||
|
||||
|
||||
|
||||
declare
|
||||
-- The models.
|
||||
--
|
||||
the_Models : constant openGL.Model.views := openGL.Demo.Models;
|
||||
|
||||
-- The visuals.
|
||||
--
|
||||
use openGL.Visual.Forge;
|
||||
|
||||
the_Visuals : openGL.Visual.views (the_Models'Range);
|
||||
Current : Integer := the_Visuals'First;
|
||||
|
||||
begin
|
||||
for i in the_Visuals'Range
|
||||
loop
|
||||
the_Visuals (i) := new_Visual (the_Models (i));
|
||||
end loop;
|
||||
|
||||
the_Visuals (3).Site_is ([0.0, 0.0, -50.0]);
|
||||
|
||||
-- Main loop.
|
||||
--
|
||||
while not Demo.Done
|
||||
loop
|
||||
Demo.Dolly.evolve;
|
||||
Demo.Done := Demo.Dolly.quit_Requested;
|
||||
|
||||
declare
|
||||
Command : Character;
|
||||
Avail : Boolean;
|
||||
begin
|
||||
Demo.Dolly.get_last_Character (Command, Avail);
|
||||
|
||||
if Avail
|
||||
then
|
||||
case Command
|
||||
is
|
||||
when ' ' =>
|
||||
if Current = the_Visuals'Last
|
||||
then Current := the_Visuals'First;
|
||||
else Current := Current + 1;
|
||||
end if;
|
||||
|
||||
when others =>
|
||||
null;
|
||||
end case;
|
||||
end if;
|
||||
end;
|
||||
|
||||
-- Render all visuals.
|
||||
--
|
||||
Demo.Camera.render ([1 => the_Visuals (Current)]);
|
||||
|
||||
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_render_Models;
|
||||
@@ -0,0 +1,16 @@
|
||||
with
|
||||
"opengl_demo",
|
||||
"lace_shared";
|
||||
|
||||
project render_Models
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_render_models.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_Models;
|
||||
|
After Width: | Height: | Size: 105 KiB |
|
After Width: | Height: | Size: 34 KiB |
@@ -0,0 +1,97 @@
|
||||
with
|
||||
openGL.Model,
|
||||
openGL.Visual,
|
||||
openGL.Light,
|
||||
openGL.Demo;
|
||||
|
||||
|
||||
procedure launch_render_Screenshot
|
||||
--
|
||||
-- Take a screenshot.
|
||||
--
|
||||
is
|
||||
use openGL,
|
||||
openGL.Math,
|
||||
openGL.linear_Algebra_3d;
|
||||
|
||||
begin
|
||||
Demo.print_Usage ("Use 't' or 'T' to take a screenshot.");
|
||||
Demo.define ("openGL 'Render Screenshot' Demo");
|
||||
Demo.Camera.Position_is ([0.0, 2.0, 10.0],
|
||||
y_Rotation_from (to_Radians (0.0)));
|
||||
|
||||
declare
|
||||
the_Light : openGL.Light.item := Demo.Renderer.new_Light;
|
||||
begin
|
||||
the_Light.Site_is ([5_000.0, 2_000.0, 5_000.0]);
|
||||
Demo.Renderer.set (the_Light);
|
||||
end;
|
||||
|
||||
declare
|
||||
-- The models.
|
||||
--
|
||||
the_Models : constant openGL.Model.views := openGL.Demo.Models;
|
||||
|
||||
-- The visuals.
|
||||
--
|
||||
use openGL.Visual.Forge;
|
||||
|
||||
the_Visuals : openGL.Visual.views (the_Models'Range);
|
||||
Current : Integer := the_Visuals'First;
|
||||
|
||||
begin
|
||||
for i in the_Visuals'Range
|
||||
loop
|
||||
the_Visuals (i) := new_Visual (the_Models (i));
|
||||
end loop;
|
||||
|
||||
-- Main loop.
|
||||
--
|
||||
while not Demo.Done
|
||||
loop
|
||||
Demo.Dolly.evolve;
|
||||
Demo.Done := Demo.Dolly.quit_Requested;
|
||||
|
||||
declare
|
||||
Command : Character;
|
||||
Avail : Boolean;
|
||||
begin
|
||||
Demo.Dolly.get_last_Character (Command, Avail);
|
||||
|
||||
if Avail
|
||||
then
|
||||
case Command
|
||||
is
|
||||
when ' ' =>
|
||||
if Current = the_Visuals'Last
|
||||
then
|
||||
Current := the_Visuals'First;
|
||||
else
|
||||
Current := Current + 1;
|
||||
end if;
|
||||
|
||||
when 't' | 'T' =>
|
||||
Demo.Renderer.Screenshot ("sshot.bmp");
|
||||
|
||||
when others =>
|
||||
null;
|
||||
end case;
|
||||
end if;
|
||||
end;
|
||||
|
||||
-- Render all visuals.
|
||||
--
|
||||
Demo.Camera.render ([1 => the_Visuals (Current)]);
|
||||
|
||||
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_Screenshot;
|
||||
@@ -0,0 +1,16 @@
|
||||
with
|
||||
"opengl_demo",
|
||||
"lace_shared";
|
||||
|
||||
project render_Screenshot
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_render_screenshot.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_Screenshot;
|
||||
@@ -0,0 +1,94 @@
|
||||
with
|
||||
openGL.Visual,
|
||||
openGL.Palette,
|
||||
openGL.Font,
|
||||
openGL.Model.Text.lit_colored,
|
||||
openGL.Demo;
|
||||
|
||||
procedure launch_render_Text
|
||||
--
|
||||
-- Render updated text.
|
||||
--
|
||||
is
|
||||
use openGL,
|
||||
openGL.Palette,
|
||||
openGL.Math,
|
||||
openGL.linear_Algebra_3d;
|
||||
|
||||
the_font_Id : constant openGL.Font.font_Id := (to_Asset ("assets/opengl/font/LiberationMono-Regular.ttf"), 24);
|
||||
|
||||
begin
|
||||
Demo.print_Usage ("Use space ' ' to cycle the text.");
|
||||
openGL.Demo.define ("openGL 'Render Text' Demo");
|
||||
|
||||
-- Setup the camera.
|
||||
--
|
||||
Demo.Camera.Position_is ([3.0, 0.0, 10.0],
|
||||
y_Rotation_from (to_Radians (0.0)));
|
||||
|
||||
Demo.Renderer.add_Font (the_font_Id);
|
||||
|
||||
declare
|
||||
-- The model.
|
||||
--
|
||||
the_Text_Model : constant Model.Text.lit_colored.view
|
||||
:= Model.Text.lit_colored.new_Text (Text => "Howdy",
|
||||
Font => the_font_Id,
|
||||
Color => (Red, Opaque),
|
||||
Centered => False);
|
||||
|
||||
-- The sprites.
|
||||
--
|
||||
use openGL.Visual.Forge;
|
||||
|
||||
the_Sprites : constant openGL.Visual.views := [1 => new_Visual (the_Text_Model.all'Access)];
|
||||
Current : constant Integer := the_Sprites'First;
|
||||
|
||||
begin
|
||||
-- Main loop.
|
||||
--
|
||||
while not Demo.Done
|
||||
loop
|
||||
Demo.Dolly.evolve;
|
||||
Demo.Done := Demo.Dolly.quit_Requested;
|
||||
|
||||
declare
|
||||
Command : Character;
|
||||
Avail : Boolean;
|
||||
begin
|
||||
Demo.Dolly.get_last_Character (Command, Avail);
|
||||
|
||||
if Avail
|
||||
then
|
||||
case Command
|
||||
is
|
||||
when ' ' =>
|
||||
if the_Text_Model.Text = "Howdy"
|
||||
then
|
||||
the_Text_Model.Text_is ("Doody");
|
||||
else
|
||||
the_Text_Model.Text_is ("Howdy");
|
||||
end if;
|
||||
|
||||
when others =>
|
||||
null;
|
||||
end case;
|
||||
end if;
|
||||
end;
|
||||
|
||||
-- Render all sprites.
|
||||
--
|
||||
Demo.Camera.render ([1 => the_Sprites (Current)]);
|
||||
|
||||
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_Text;
|
||||
@@ -0,0 +1,16 @@
|
||||
with
|
||||
"opengl_demo",
|
||||
"lace_shared";
|
||||
|
||||
project render_Text
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_render_text.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_Text;
|
||||
122
3-mid/opengl/applet/demo/two_cameras/launch_two_cameras_demo.adb
Normal file
@@ -0,0 +1,122 @@
|
||||
with
|
||||
openGL.Camera,
|
||||
openGL.Palette,
|
||||
openGL.Model.Box .lit_colored_textured,
|
||||
openGL.Model.Sphere.lit_colored_textured,
|
||||
openGL.Visual,
|
||||
openGL.Demo;
|
||||
|
||||
procedure launch_two_Cameras_Demo
|
||||
--
|
||||
-- Exercise the culler with two cameras.
|
||||
--
|
||||
is
|
||||
use openGL,
|
||||
openGL.Model,
|
||||
openGL.Model.Box,
|
||||
openGL.Palette,
|
||||
openGL.Math,
|
||||
openGL.linear_Algebra_3d;
|
||||
|
||||
Camera_2 : openGL.Camera.item;
|
||||
begin
|
||||
Demo.print_Usage;
|
||||
openGL.Demo.define ("openGL 'Two Cameras' Demo");
|
||||
|
||||
-- Setup the extra camera.
|
||||
--
|
||||
Camera_2.define;
|
||||
Camera_2.Renderer_is (Demo.Renderer'unchecked_Access);
|
||||
|
||||
Camera_2.Position_is ([0.0, 20.0, 0.0],
|
||||
y_Rotation_from (to_Radians (0.0)));
|
||||
|
||||
Camera_2.Viewport_is (width => 1000,
|
||||
height => 1000);
|
||||
|
||||
|
||||
-- Create the sprites.
|
||||
--
|
||||
declare
|
||||
use openGL.Math.Functions;
|
||||
|
||||
-- The Models.
|
||||
--
|
||||
the_Face : constant asset_Name := to_Asset ("assets/opengl/texture/Face1.bmp");
|
||||
the_box_Model : constant Model.box.lit_colored_textured.view
|
||||
:= Model.box.lit_colored_textured.new_Box
|
||||
(size => [0.5, 0.5, 0.5],
|
||||
faces => [front => (colors => [others => (White, Opaque)], texture_name => the_Face),
|
||||
rear => (colors => [others => (Blue, Opaque)], texture_name => the_Face),
|
||||
upper => (colors => [others => (Green, Opaque)], texture_name => the_Face),
|
||||
lower => (colors => [others => (Green, Opaque)], texture_name => the_Face),
|
||||
left => (colors => [others => (Dark_Red, Opaque)], texture_name => the_Face),
|
||||
right => (colors => [others => (Red, Opaque)], texture_name => the_Face)]);
|
||||
|
||||
the_ball_Model : constant Model.Sphere.lit_colored_textured.view
|
||||
:= Model.Sphere.lit_colored_textured.new_Sphere (radius => 0.5);
|
||||
|
||||
-- The Sprites.
|
||||
--
|
||||
the_Sprites : constant Visual.views (1 .. 4_000) := [others => Visual.Forge.new_Visual (Model.view ( the_box_Model))];
|
||||
the_Sprites_2 : constant Visual.views (1 .. 4_000) := [others => Visual.Forge.new_Visual (Model.view (the_ball_Model))];
|
||||
|
||||
grid_Size : constant openGL.Real := SqRt (openGL.Real (the_Sprites'Length));
|
||||
x : openGL.Real := -grid_Size / 2.0;
|
||||
z : openGL.Real := 0.0;
|
||||
|
||||
begin
|
||||
Demo.Dolly.Speed_is (0.1);
|
||||
|
||||
for i in the_Sprites'Range
|
||||
loop
|
||||
x := x + 1.0;
|
||||
|
||||
if i mod Integer (SqRt (openGL.Real (the_Sprites'Length))) = 0
|
||||
then
|
||||
z := z - 1.0;
|
||||
x := -grid_Size / 2.0;
|
||||
end if;
|
||||
|
||||
the_Sprites (i).Site_is ([x, 0.0, z]);
|
||||
end loop;
|
||||
|
||||
|
||||
for i in the_Sprites_2'Range
|
||||
loop
|
||||
x := x + 1.2;
|
||||
|
||||
if i mod Integer (SqRt (openGL.Real (the_Sprites_2'Length))) = 0
|
||||
then
|
||||
z := z - 1.0;
|
||||
x := -grid_Size / 2.0;
|
||||
end if;
|
||||
|
||||
the_Sprites_2 (i).Site_is ([x, 0.0, z]);
|
||||
end loop;
|
||||
|
||||
|
||||
-- Main loop.
|
||||
--
|
||||
while not Demo.Done
|
||||
loop
|
||||
Demo.Dolly.evolve;
|
||||
Demo.Done := Demo.Dolly.quit_Requested;
|
||||
|
||||
Demo.Camera.render (the_Sprites);
|
||||
Camera_2 .render (the_Sprites_2);
|
||||
|
||||
while not ( Demo.Camera.cull_Completed
|
||||
and Camera_2 .cull_Completed)
|
||||
loop
|
||||
delay Duration'Small;
|
||||
end loop;
|
||||
|
||||
Demo.Renderer.render;
|
||||
Demo.FPS_Counter.increment; -- Frames per second display.
|
||||
end loop;
|
||||
end;
|
||||
|
||||
Demo.destroy;
|
||||
Camera_2.destroy;
|
||||
end launch_two_Cameras_Demo;
|
||||
16
3-mid/opengl/applet/demo/two_cameras/two_cameras_demo.gpr
Normal file
@@ -0,0 +1,16 @@
|
||||
with
|
||||
"opengl_demo",
|
||||
"lace_shared";
|
||||
|
||||
project two_cameras_Demo
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_two_cameras_demo.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 two_cameras_Demo;
|
||||