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

31
3-mid/opengl/Overview Normal file
View File

@@ -0,0 +1,31 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~
'openGL' Component Overview
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Platforms
---------
- eGL (preferred)
- glX (til eGL is fully supported (ask nVidia))
- Windows (if/when contributed)
- Apple (if/when contributed)
Profiles
--------
- Safe (safety critical)
- Lean (embedded)
- Desk (desktop)
Source Folders
--------------
- source: Code common to all openGL profiles.
- source/safe: Code common to 'Safety Critical' and 'Desktop' openGL profiles.
- source/lean: Code common to 'Embedded' and 'Desktop' openGL profiles.
- source/desk: Code specific to 'Desktop' openGL profile.
Installation
------------
Add the '.../opengl/library' folder to your GNAT_PROJECT_PATH.

23
3-mid/opengl/alire.toml Normal file
View File

@@ -0,0 +1,23 @@
name = "lace_opengl"
description = "Provides an openGL engine."
version = "0.1.1"
authors = ["Rod Kay"]
maintainers = ["Rod Kay <rodakay5@gmail.com>"]
maintainers-logins = ["charlie5"]
licenses = "ISC"
website = "https://github.com/charlie5/lace-alire"
tags = ["graphics", "3d"]
project-files = ["library/opengl.gpr"]
[[depends-on]]
lace_collada = "~0.1"
libfreetype = "^2"
[depends-on."case(os)"."windows"]
libmesa = "*"
[environment.'case(distribution)'.msys2.C_INCLUDE_PATH]
append = "${DISTRIB_ROOT}/mingw64/include/freetype2"

View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -e
if [ "$LACE" = "" ]; then
echo Please ensure the LACE environment variable points to the Lace installation root folder.
exit
fi
mkdir -p assets
cd assets
ln -s $LACE/3-mid/opengl/assets opengl
echo Done.

View 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;

View 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;

View 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;

View 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;

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

View File

@@ -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;

View File

@@ -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;

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@@ -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;

View File

@@ -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;

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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

File diff suppressed because it is too large Load Diff

View 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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -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;

View File

@@ -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;

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View 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;

View 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;

View File

@@ -0,0 +1,16 @@
with
"opengl",
"swig",
"lace_shared";
project Egl_linkage_Test
is
for Object_Dir use "build";
for Exec_Dir use ".";
for Main use ("launch_egl_linkage_test.adb");
package Linker is
for Default_Switches ("ada") use ("-g", "-lEGL");
end Linker;
end Egl_linkage_Test;

View File

@@ -0,0 +1,74 @@
with
eGL.Binding,
Swig,
interfaces.C.Strings,
System;
procedure launch_egl_linkage_Test
--
-- Tests linkage to eGL functions.
-- Is not meant to be run.
--
is
use eGL,
eGL.Binding,
System;
an_EGLint : EGLint;
an_EGLdisplay : EGLdisplay;
an_EGLboolean : EGLboolean;
an_EGLsurface : EGLsurface;
an_EGLcontext : EGLcontext;
a_chars_ptr : interfaces.C.strings.chars_ptr;
a_void_ptr : swig.void_ptr;
an_EGLdisplay_pointer : access EGLdisplay;
begin
an_EGLint := eglGetError;
an_EGLdisplay := eglGetDisplay (null);
an_EGLboolean := eglInitialize (null_Address, null, null);
an_EGLboolean := eglTerminate (null_Address);
a_chars_ptr := eglQueryString (null_Address, 0);
an_EGLboolean := eglGetConfigs (null_Address, null, 0, null);
an_EGLboolean := eglChooseConfig (null_Address, null, null, 0, null);
an_EGLboolean := eglGetConfigAttrib (null_Address, null_Address, 0, null);
an_EGLsurface := eglCreateWindowSurface (null_Address, null_Address, 0, null);
an_EGLsurface := eglCreatePbufferSurface (null_Address, null_Address, null);
an_EGLsurface := eglCreatePixmapSurface (null_Address, null_Address, 0, null);
an_EGLboolean := eglDestroySurface (null_Address, null_Address);
an_EGLboolean := eglQuerySurface (null_Address, null_Address, 0, null);
an_EGLboolean := eglBindAPI (0);
an_EGLboolean := eglQueryAPI;
an_EGLboolean := eglWaitClient;
an_EGLboolean := eglReleaseThread;
an_EGLsurface := eglCreatePbufferFromClientBuffer
(null_Address, 0, null_Address, null_Address, null);
an_EGLboolean := eglSurfaceAttrib (null_Address, null_Address, 0, 0);
an_EGLboolean := eglBindTexImage (null_Address, null_Address, 0);
an_EGLboolean := eglReleaseTexImage (null_Address, null_Address, 0);
an_EGLboolean := eglSwapInterval (null_Address, 0);
an_EGLcontext := eglCreateContext (null_Address, null_Address, null_Address, null);
an_EGLboolean := eglDestroyContext (null_Address, null_Address);
an_EGLboolean := eglMakeCurrent (null_Address, null_Address, null_Address, null_Address);
an_EGLcontext := eglGetCurrentContext;
an_EGLsurface := eglGetCurrentSurface (0);
an_EGLdisplay := eglGetCurrentDisplay;
an_EGLboolean := eglQueryContext (null_Address, null_Address, 0, null);
an_EGLboolean := eglWaitGL;
an_EGLboolean := eglWaitNative (0);
an_EGLboolean := eglSwapBuffers (null_Address, null_Address);
an_EGLboolean := eglCopyBuffers (null_Address, null_Address, 0);
a_void_ptr := eglGetProcAddress (Interfaces.C.Strings.null_ptr);
an_EGLdisplay_pointer
:= egl_DEFAULT_DISPLAY;
an_EGLcontext := egl_NO_CONTEXT;
an_EGLdisplay := egl_NO_DISPLAY;
an_EGLsurface := egl_NO_SURFACE;
an_EGLint := egl_DONT_CARE;
end launch_egl_linkage_Test;

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,12 @@
#version 140
in vec4 frag_Color;
out vec4 final_Color;
void
main()
{
final_Color = frag_Color;
}

View File

@@ -0,0 +1,23 @@
#version 140
uniform mat4 mvp_Transform;
uniform vec3 Scale;
in vec3 Site;
in vec4 Color;
out vec3 frag_Site;
out vec4 frag_Color;
void main()
{
// Pass some variables to the fragment shader.
//
frag_Site = Site;
frag_Color = Color;
// Apply all matrix transformations to 'Site'.
//
gl_Position = mvp_Transform * vec4 (Site * Scale, 1);
}

View File

@@ -0,0 +1,15 @@
#version 140
uniform sampler2D sTexture;
varying vec4 vColor;
varying vec2 vCoords;
void main()
{
gl_FragColor = mix (texture2D (sTexture, vCoords),
vColor,
0.5);
}

View File

@@ -0,0 +1,19 @@
#version 140
uniform mat4 mvp_Transform;
uniform vec3 Scale;
attribute vec3 Site;
attribute vec4 Color;
attribute vec2 Coords;
varying vec4 vColor;
varying vec2 vCoords;
void main()
{
gl_Position = mvp_Transform * vec4 (Site * Scale, 1.0);
vColor = Color;
vCoords = Coords;
}

View File

@@ -0,0 +1,123 @@
#version 140
struct light
{
vec4 Site;
vec3 Color;
float Attenuation;
float ambient_Coefficient;
float cone_Angle;
vec3 cone_Direction;
};
uniform mat4 model_Transform;
uniform mat3 inverse_model_Rotation;
uniform vec3 camera_Site;
uniform vec3 specular_Color; // The materials specular color.
uniform int light_Count;
uniform light Lights [10];
in vec3 frag_Site;
in vec3 frag_Normal;
in vec4 frag_Color;
in float frag_Shine;
out vec4 final_Color;
vec3
apply_Light (light Light,
vec3 surface_Color,
vec3 Normal,
vec3 surface_Site,
vec3 Surface_to_Camera)
{
vec3 Surface_to_Light;
float Attenuation = 1.0;
if (Light.Site.w == 0.0)
{
// Directional light.
//
Surface_to_Light = normalize (-Light.Site.xyz);
Attenuation = 1.0; // No attenuation for directional lights.
}
else
{
// Point light.
//
vec3 Surface_to_Light_vector = Light.Site.xyz - surface_Site;
float Distance_to_Light = length (Surface_to_Light_vector);
Surface_to_Light = normalize (Surface_to_Light_vector);
Attenuation = 1.0
/ ( 1.0
+ Light.Attenuation
* pow (Distance_to_Light, 2));
// Cone restrictions which affects attenuation.
//
float Light_to_Surface_Angle = degrees (acos (dot (-Surface_to_Light,
normalize (Light.cone_Direction))));
if (Light_to_Surface_Angle > Light.cone_Angle)
{
Attenuation = 0.0;
}
}
vec3 lit_surface_Color = surface_Color * Light.Color;
vec3 Ambient = Light.ambient_Coefficient * lit_surface_Color;
float diffuse_Coefficient = max (0.0,
dot (Normal,
Surface_to_Light));
vec3 Diffuse = diffuse_Coefficient * lit_surface_Color;
float specular_Coefficient = 0.0;
if (diffuse_Coefficient > 0.0)
specular_Coefficient = pow (max (0.0,
dot (Surface_to_Camera,
reflect (-Surface_to_Light,
Normal))),
frag_Shine);
vec3 Specular = specular_Coefficient * specular_Color * Light.Color;
return Ambient + Attenuation * (Diffuse + Specular); // Linear color (before gamma correction).
}
void
main()
{
vec3 surface_Site = vec3 ( model_Transform
* vec4 (frag_Site, 1));
vec4 surface_Color = frag_Color;
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);
for (int i = 0; i < light_Count; ++i)
{
linear_Color += apply_Light (Lights [i],
surface_Color.rgb,
Normal,
surface_Site,
Surface_to_Camera);
}
vec3 Gamma = vec3 (1.0 / 2.2);
final_Color = vec4 (pow (linear_Color, // Final color (after gamma correction).
Gamma),
surface_Color.a);
}

View File

@@ -0,0 +1,29 @@
#version 140
uniform mat4 mvp_Transform;
uniform vec3 Scale;
in vec3 Site;
in vec3 Normal;
in vec4 Color;
in float Shine;
out vec3 frag_Site;
out vec3 frag_Normal;
out vec4 frag_Color;
out float frag_Shine;
void main()
{
// Pass some variables to the fragment shader.
//
frag_Site = Site;
frag_Normal = Normal;
frag_Color = Color;
frag_Shine = Shine;
// Apply all matrix transformations to 'Site'.
//
gl_Position = mvp_Transform * vec4 (Site * Scale, 1);
}

View File

@@ -0,0 +1,127 @@
#version 140
struct light
{
vec4 Site;
vec3 Color;
float Attenuation;
float ambient_Coefficient;
float cone_Angle;
vec3 cone_Direction;
};
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];
in vec3 frag_Site;
in vec3 frag_Normal;
in vec4 frag_Color;
in vec2 frag_Coords;
in float frag_Shine;
out vec4 final_Color;
vec3
apply_Light (light Light,
vec3 surface_Color,
vec3 Normal,
vec3 surface_Site,
vec3 Surface_to_Camera)
{
vec3 Surface_to_Light;
float Attenuation = 1.0;
if (Light.Site.w == 0.0)
{
// Directional light.
//
Surface_to_Light = normalize (-Light.Site.xyz);
Attenuation = 1.0; // No attenuation for directional lights.
}
else
{
// Point light.
//
vec3 Surface_to_Light_vector = Light.Site.xyz - surface_Site;
float Distance_to_Light = length (Surface_to_Light_vector);
Surface_to_Light = normalize (Surface_to_Light_vector);
Attenuation = 1.0
/ ( 1.0
+ Light.Attenuation
* pow (Distance_to_Light, 2));
// Cone restrictions which affects attenuation.
//
float Light_to_Surface_Angle = degrees (acos (dot (-Surface_to_Light,
normalize (Light.cone_Direction))));
if (Light_to_Surface_Angle > Light.cone_Angle)
{
Attenuation = 0.0;
}
}
vec3 lit_surface_Color = surface_Color * Light.Color;
vec3 Ambient = Light.ambient_Coefficient * lit_surface_Color;
float diffuse_Coefficient = max (0.0,
dot (Normal,
Surface_to_Light));
vec3 Diffuse = diffuse_Coefficient * lit_surface_Color;
float specular_Coefficient = 0.0;
if (diffuse_Coefficient > 0.0)
specular_Coefficient = pow (max (0.0,
dot (Surface_to_Camera,
reflect (-Surface_to_Light,
Normal))),
frag_Shine);
vec3 Specular = specular_Coefficient * specular_Color * Light.Color;
return Ambient + Attenuation * (Diffuse + Specular); // Linear color (before gamma correction).
}
void
main()
{
vec3 surface_Site = vec3 ( model_Transform
* vec4 (frag_Site, 1));
vec4 surface_Color = ( texture (Texture, frag_Coords)
+ frag_Color)
/ 2.0;
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);
for (int i = 0; i < light_Count; ++i)
{
linear_Color += apply_Light (Lights [i],
surface_Color.rgb,
Normal,
surface_Site,
Surface_to_Camera);
}
vec3 Gamma = vec3 (1.0 / 2.2);
final_Color = vec4 (pow (linear_Color, // Final color (after gamma correction).
Gamma),
surface_Color.a);
}

View File

@@ -0,0 +1,114 @@
#version 140
uniform mat4 mvp_Transform;
uniform vec3 Scale;
uniform mat4 bone_Matrices[120];
in vec3 Site;
in vec3 Normal;
in vec4 Color;
in vec2 Coords;
in float Shine;
in vec4 bone_Ids;
in vec4 bone_Weights;
out vec3 frag_Site;
out vec3 frag_Normal;
out vec4 frag_Color;
out vec2 frag_Coords;
out float frag_Shine;
const float c_zero = 0.0;
const float c_one = 1.0;
void main()
{
vec4 transformedPosition = vec4 (0.0);
vec3 transformedNormal = vec3 (0.0);
if (int (bone_Ids.x) == 0) // No bones affect this vertex.
{
transformedPosition = vec4 (Site, c_one);
transformedNormal = Normal;
}
else
{
// Bone 1.
//
mat4 m44 = bone_Matrices [int (bone_Ids.x) - 1];
// Transform the offset by bone 1.
transformedPosition += m44 * vec4 (Site, c_one) * bone_Weights.x;
mat3 m33 = mat3 (m44[0].xyz,
m44[1].xyz,
m44[2].xyz);
// Transform the normal by bone 1.
transformedNormal += m33 * Normal * bone_Weights.x;
if (int (bone_Ids.y) != 0)
{
// Bone 2.
//
m44 = bone_Matrices [int (bone_Ids.y) - 1];
// Transform the offset by bone 2.
transformedPosition += m44 * vec4 (Site, c_one) * bone_Weights.y;
m33 = mat3 (m44[0].xyz,
m44[1].xyz,
m44[2].xyz);
// Transform the normal by bone 2.
transformedNormal += m33 * Normal * bone_Weights.y;
if (int (bone_Ids.z) != 0)
{
// Bone 3.
//
m44 = bone_Matrices [int (bone_Ids.z) - 1];
// Transform the offset by bone 3.
transformedPosition += m44 * vec4 (Site, c_one) * bone_Weights.z;
m33 = mat3(m44[0].xyz,
m44[1].xyz,
m44[2].xyz);
// Transform the normal by bone 3.
transformedNormal += m33 * Normal * bone_Weights.z;
if (int (bone_Ids.w) != 0)
{
// Bone 4.
//
m44 = bone_Matrices [int (bone_Ids.w) - 1];
// Transform the offset by bone 4.
transformedPosition += m44 * vec4 (Site, c_one) * bone_Weights.w;
m33 = mat3 (m44[0].xyz,
m44[1].xyz,
m44[2].xyz);
// Transform the normal by bone 4.
transformedNormal += m33 * Normal * bone_Weights.w;
}
}
}
}
// Pass some variables to the fragment shader.
//
frag_Site = Site;
frag_Normal = normalize (transformedNormal);
frag_Color = Color;
frag_Coords = Coords;
frag_Shine = Shine;
// Apply all matrix transformations to 'Site'.
//
gl_Position = mvp_Transform * (transformedPosition * vec4 (Scale, 1));
}

View File

@@ -0,0 +1,132 @@
#version 140
struct light
{
vec4 Site;
vec3 Color;
float Attenuation;
float ambient_Coefficient;
float cone_Angle;
vec3 cone_Direction;
};
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];
in vec3 frag_Site;
in vec3 frag_Normal;
in vec4 frag_Color;
in vec2 frag_Coords;
in float frag_Shine;
out vec4 final_Color;
vec3
apply_Light (light Light,
vec3 surface_Color,
vec3 Normal,
vec3 surface_Site,
vec3 Surface_to_Camera)
{
vec3 Surface_to_Light;
float Attenuation = 1.0;
if (Light.Site.w == 0.0)
{
// Directional light.
//
Surface_to_Light = normalize (-Light.Site.xyz);
Attenuation = 1.0; // No attenuation for directional lights.
}
else
{
// Difuse light.
//
vec3 Surface_to_Light_vector = Light.Site.xyz - surface_Site;
float Distance_to_Light = length (Surface_to_Light_vector);
Surface_to_Light = normalize (Surface_to_Light_vector);
Attenuation = 1.0
/ ( 1.0
+ Light.Attenuation
* pow (Distance_to_Light, 2));
// Cone restrictions which affects attenuation.
//
float Light_to_Surface_Angle = degrees (acos (dot (-Surface_to_Light,
normalize (Light.cone_Direction))));
if (Light_to_Surface_Angle > Light.cone_Angle)
{
Attenuation = 0.0;
}
}
vec3 lit_surface_Color = surface_Color * Light.Color;
vec3 Ambient = Light.ambient_Coefficient * lit_surface_Color;
float diffuse_Coefficient = max (0.0,
dot (Normal,
Surface_to_Light));
vec3 Diffuse = diffuse_Coefficient * lit_surface_Color;
float specular_Coefficient = 0.0;
if (diffuse_Coefficient > 0.0)
specular_Coefficient = pow (max (0.0,
dot (Surface_to_Camera,
reflect (-Surface_to_Light,
Normal))),
frag_Shine);
vec3 Specular = specular_Coefficient * specular_Color * Light.Color;
return Ambient + Attenuation * (Diffuse + Specular); // Linear color (before gamma correction).
}
void
main()
{
vec4 texture_Color = texture (Texture, frag_Coords);
vec4 surface_Color = vec4 (mix (texture_Color.rgb,
frag_Color .rgb,
0.5),
texture_Color.a
* frag_Color .a);
vec3 surface_Site = vec3 ( model_Transform
* vec4 (frag_Site, 1));
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);
for (int i = 0; i < light_Count; ++i)
{
linear_Color += apply_Light (Lights [i],
surface_Color.rgb,
Normal,
surface_Site,
Surface_to_Camera);
}
vec3 Gamma = vec3 (1.0 / 2.2);
final_Color = vec4 (pow (linear_Color, // Final color (after gamma correction).
Gamma),
surface_Color.a);
}

View File

@@ -0,0 +1,126 @@
#version 140
struct light
{
vec4 Site;
vec3 Color;
float Attenuation;
float ambient_Coefficient;
float cone_Angle;
vec3 cone_Direction;
};
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];
in vec3 frag_Site;
in vec3 frag_Normal;
in vec4 frag_Color;
in vec2 frag_Coords;
in float frag_Shine;
out vec4 final_Color;
vec3
apply_Light (light Light,
vec3 surface_Color,
vec3 Normal,
vec3 surface_Site,
vec3 Surface_to_Camera)
{
vec3 Surface_to_Light;
float Attenuation = 1.0;
if (Light.Site.w == 0.0)
{
// Directional light.
//
Surface_to_Light = normalize (-Light.Site.xyz);
Attenuation = 1.0; // No attenuation for directional lights.
}
else
{
// Point light.
//
vec3 Surface_to_Light_vector = Light.Site.xyz - surface_Site;
float Distance_to_Light = length (Surface_to_Light_vector);
Surface_to_Light = normalize (Surface_to_Light_vector);
Attenuation = 1.0
/ ( 1.0
+ Light.Attenuation
* pow (Distance_to_Light, 2));
// Cone restrictions which affects attenuation.
//
float Light_to_Surface_Angle = degrees (acos (dot (-Surface_to_Light,
normalize (Light.cone_Direction))));
if (Light_to_Surface_Angle > Light.cone_Angle)
{
Attenuation = 0.0;
}
}
vec3 lit_surface_Color = surface_Color * Light.Color;
vec3 Ambient = Light.ambient_Coefficient * lit_surface_Color;
float diffuse_Coefficient = max (0.0,
dot (Normal,
Surface_to_Light));
vec3 Diffuse = diffuse_Coefficient * lit_surface_Color;
float specular_Coefficient = 0.0;
if (diffuse_Coefficient > 0.0)
specular_Coefficient = pow (max (0.0,
dot (Surface_to_Camera,
reflect (-Surface_to_Light,
Normal))),
frag_Shine);
vec3 Specular = specular_Coefficient * specular_Color * Light.Color;
return Ambient + Attenuation * (Diffuse + Specular); // Linear color (before gamma correction).
}
void
main()
{
vec3 surface_Site = vec3 ( model_Transform
* vec4 (frag_Site, 1));
vec4 surface_Color = mix (texture (Texture, frag_Coords),
frag_Color,
0.5);
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);
for (int i = 0; i < light_Count; ++i)
{
linear_Color += apply_Light (Lights [i],
surface_Color.rgb,
Normal,
surface_Site,
Surface_to_Camera);
}
vec3 Gamma = vec3 (1.0 / 2.2);
final_Color = vec4 (pow (linear_Color, // Final color (after gamma correction).
Gamma),
surface_Color.a);
}

View File

@@ -0,0 +1,32 @@
#version 140
uniform mat4 mvp_Transform;
uniform vec3 Scale;
in vec3 Site;
in vec3 Normal;
in vec4 Color;
in vec2 Coords;
in float Shine;
out vec3 frag_Site;
out vec3 frag_Normal;
out vec4 frag_Color;
out vec2 frag_Coords;
out float frag_Shine;
void main()
{
// Pass some variables to the fragment shader.
//
frag_Site = Site;
frag_Normal = Normal;
frag_Color = Color;
frag_Coords = Coords;
frag_Shine = Shine;
// Apply all matrix transformations to 'Site'.
//
gl_Position = mvp_Transform * vec4 (Site * Scale, 1);
}

View File

@@ -0,0 +1,127 @@
#version 140
struct light
{
vec4 Site;
vec3 Color;
float Attenuation;
float ambient_Coefficient;
float cone_Angle;
vec3 cone_Direction;
};
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];
in vec3 frag_Site;
in vec3 frag_Normal;
in vec4 frag_Color;
in vec2 frag_Coords;
in float frag_Shine;
out vec4 final_Color;
vec3
apply_Light (light Light,
vec3 surface_Color,
vec3 Normal,
vec3 surface_Site,
vec3 Surface_to_Camera)
{
vec3 Surface_to_Light;
float Attenuation = 1.0;
if (Light.Site.w == 0.0)
{
// Directional light.
//
Surface_to_Light = normalize (-Light.Site.xyz);
Attenuation = 1.0; // No attenuation for directional lights.
}
else
{
// Point light.
//
vec3 Surface_to_Light_vector = Light.Site.xyz - surface_Site;
float Distance_to_Light = length (Surface_to_Light_vector);
Surface_to_Light = normalize (Surface_to_Light_vector);
Attenuation = 1.0
/ ( 1.0
+ Light.Attenuation
* pow (Distance_to_Light, 2));
// Cone restrictions which affects attenuation.
//
float Light_to_Surface_Angle = degrees (acos (dot (-Surface_to_Light,
normalize (Light.cone_Direction))));
if (Light_to_Surface_Angle > Light.cone_Angle)
{
Attenuation = 0.0;
}
}
vec3 lit_surface_Color = surface_Color * Light.Color;
vec3 Ambient = Light.ambient_Coefficient * lit_surface_Color;
float diffuse_Coefficient = max (0.0,
dot (Normal,
Surface_to_Light));
vec3 Diffuse = diffuse_Coefficient * lit_surface_Color;
float specular_Coefficient = 0.0;
if (diffuse_Coefficient > 0.0)
specular_Coefficient = pow (max (0.0,
dot (Surface_to_Camera,
reflect (-Surface_to_Light,
Normal))),
frag_Shine);
vec3 Specular = specular_Coefficient * specular_Color * Light.Color;
return Ambient + Attenuation * (Diffuse + Specular); // Linear color (before gamma correction).
}
void
main()
{
vec3 surface_Site = vec3 ( model_Transform
* vec4 (frag_Site, 1));
vec4 surface_Color = mix (texture (Texture, frag_Coords),
frag_Color,
0.5);
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);
for (int i = 0; i < light_Count; ++i)
{
linear_Color += apply_Light (Lights [i],
surface_Color.rgb,
Normal,
surface_Site,
Surface_to_Camera);
}
vec3 Gamma = vec3 (1.0 / 2.2);
final_Color = vec4 (pow (linear_Color, // Final color (after gamma correction).
Gamma),
surface_Color.a);
}

View File

@@ -0,0 +1,114 @@
#version 140
uniform mat4 mvp_Transform;
uniform vec3 Scale;
uniform mat4 bone_Matrices[120];
in vec3 Site;
in vec3 Normal;
in vec4 Color;
in vec2 Coords;
in float Shine;
in vec4 bone_Ids;
in vec4 bone_Weights;
out vec3 frag_Site;
out vec3 frag_Normal;
out vec4 frag_Color;
out vec2 frag_Coords;
out float frag_Shine;
const float c_zero = 0.0;
const float c_one = 1.0;
void main()
{
vec4 transformedPosition = vec4 (0.0);
vec3 transformedNormal = vec3 (0.0);
if (int (bone_Ids.x) == 0) // No bones affect this vertex.
{
transformedPosition = vec4 (Site, c_one);
transformedNormal = Normal;
}
else
{
// Bone 1.
//
mat4 m44 = bone_Matrices [int (bone_Ids.x) - 1];
// Transform the offset by bone 1.
transformedPosition += m44 * vec4 (Site, c_one) * bone_Weights.x;
mat3 m33 = mat3 (m44[0].xyz,
m44[1].xyz,
m44[2].xyz);
// Transform the normal by bone 1.
transformedNormal += m33 * Normal * bone_Weights.x;
if (int (bone_Ids.y) != 0)
{
// Bone 2.
//
m44 = bone_Matrices [int (bone_Ids.y) - 1];
// Transform the offset by bone 2.
transformedPosition += m44 * vec4 (Site, c_one) * bone_Weights.y;
m33 = mat3 (m44[0].xyz,
m44[1].xyz,
m44[2].xyz);
// Transform the normal by bone 2.
transformedNormal += m33 * Normal * bone_Weights.y;
if (int (bone_Ids.z) != 0)
{
// Bone 3.
//
m44 = bone_Matrices [int (bone_Ids.z) - 1];
// Transform the offset by bone 3.
transformedPosition += m44 * vec4 (Site, c_one) * bone_Weights.z;
m33 = mat3(m44[0].xyz,
m44[1].xyz,
m44[2].xyz);
// Transform the normal by bone 3.
transformedNormal += m33 * Normal * bone_Weights.z;
if (int (bone_Ids.w) != 0)
{
// Bone 4.
//
m44 = bone_Matrices [int (bone_Ids.w) - 1];
// Transform the offset by bone 4.
transformedPosition += m44 * vec4 (Site, c_one) * bone_Weights.w;
m33 = mat3 (m44[0].xyz,
m44[1].xyz,
m44[2].xyz);
// Transform the normal by bone 4.
transformedNormal += m33 * Normal * bone_Weights.w;
}
}
}
}
// Pass some variables to the fragment shader.
//
frag_Site = Site;
frag_Normal = normalize (transformedNormal);
frag_Color = Color;
frag_Coords = Coords;
frag_Shine = Shine;
// Apply all matrix transformations to 'Site'.
//
gl_Position = mvp_Transform * (transformedPosition * vec4 (Scale, 1));
}

View File

@@ -0,0 +1,124 @@
#version 140
struct light
{
vec4 Site;
vec3 Color;
float Attenuation;
float ambient_Coefficient;
float cone_Angle;
vec3 cone_Direction;
};
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];
in vec3 frag_Site;
in vec3 frag_Normal;
in vec2 frag_Coords;
in float frag_Shine;
out vec4 final_Color;
vec3
apply_Light (light Light,
vec3 surface_Color,
vec3 Normal,
vec3 surface_Site,
vec3 Surface_to_Camera)
{
vec3 Surface_to_Light;
float Attenuation = 1.0;
if (Light.Site.w == 0.0)
{
// Directional light.
//
Surface_to_Light = normalize (-Light.Site.xyz);
Attenuation = 1.0; // No attenuation for directional lights.
}
else
{
// Point light.
//
vec3 Surface_to_Light_vector = Light.Site.xyz - surface_Site;
float Distance_to_Light = length (Surface_to_Light_vector);
Surface_to_Light = normalize (Surface_to_Light_vector);
Attenuation = 1.0
/ ( 1.0
+ Light.Attenuation
* pow (Distance_to_Light, 2));
// Cone restrictions which affects attenuation.
//
float Light_to_Surface_Angle = degrees (acos (dot (-Surface_to_Light,
normalize (Light.cone_Direction))));
if (Light_to_Surface_Angle > Light.cone_Angle)
{
Attenuation = 0.0;
}
}
vec3 lit_surface_Color = surface_Color * Light.Color;
vec3 Ambient = Light.ambient_Coefficient * lit_surface_Color;
float diffuse_Coefficient = max (0.0,
dot (Normal,
Surface_to_Light));
vec3 Diffuse = diffuse_Coefficient * lit_surface_Color;
float specular_Coefficient = 0.0;
if (diffuse_Coefficient > 0.0)
specular_Coefficient = pow (max (0.0,
dot (Surface_to_Camera,
reflect (-Surface_to_Light,
Normal))),
frag_Shine);
vec3 Specular = specular_Coefficient * specular_Color * Light.Color;
return Ambient + Attenuation * (Diffuse + Specular); // Linear color (before gamma correction).
}
void
main()
{
vec3 surface_Site = vec3 ( model_Transform
* vec4 (frag_Site, 1));
vec4 surface_Color = texture (Texture, 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);
for (int i = 0; i < light_Count; ++i)
{
linear_Color += apply_Light (Lights [i],
surface_Color.rgb,
Normal,
surface_Site,
Surface_to_Camera);
}
vec3 Gamma = vec3 (1.0 / 2.2);
final_Color = vec4 (pow (linear_Color, // Final color (after gamma correction).
Gamma),
surface_Color.a);
}

View File

@@ -0,0 +1,29 @@
#version 140
uniform mat4 mvp_Transform;
uniform vec3 Scale;
in vec3 Site;
in vec3 Normal;
in vec2 Coords;
in float Shine;
out vec3 frag_Site;
out vec3 frag_Normal;
out vec2 frag_Coords;
out float frag_Shine;
void main()
{
// Pass some variables to the fragment shader.
//
frag_Site = Site;
frag_Normal = Normal;
frag_Coords = Coords;
frag_Shine = Shine;
// Apply all matrix transformations to 'Site'.
//
gl_Position = mvp_Transform * vec4 (Site * Scale, 1);
}

View File

@@ -0,0 +1,124 @@
#version 140
struct light
{
vec4 Site;
vec3 Color;
float Attenuation;
float ambient_Coefficient;
float cone_Angle;
vec3 cone_Direction;
};
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];
in vec3 frag_Site;
in vec3 frag_Normal;
in vec2 frag_Coords;
in float frag_Shine;
out vec4 final_Color;
vec3
apply_Light (light Light,
vec3 surface_Color,
vec3 Normal,
vec3 surface_Site,
vec3 Surface_to_Camera)
{
vec3 Surface_to_Light;
float Attenuation = 1.0;
if (Light.Site.w == 0.0)
{
// Directional light.
//
Surface_to_Light = normalize (-Light.Site.xyz);
Attenuation = 1.0; // No attenuation for directional lights.
}
else
{
// Point light.
//
vec3 Surface_to_Light_vector = Light.Site.xyz - surface_Site;
float Distance_to_Light = length (Surface_to_Light_vector);
Surface_to_Light = normalize (Surface_to_Light_vector);
Attenuation = 1.0
/ ( 1.0
+ Light.Attenuation
* pow (Distance_to_Light, 2));
// Cone restrictions which affects attenuation.
//
float Light_to_Surface_Angle = degrees (acos (dot (-Surface_to_Light,
normalize (Light.cone_Direction))));
if (Light_to_Surface_Angle > Light.cone_Angle)
{
Attenuation = 0.0;
}
}
vec3 lit_surface_Color = surface_Color * Light.Color;
vec3 Ambient = Light.ambient_Coefficient * lit_surface_Color;
float diffuse_Coefficient = max (0.0,
dot (Normal,
Surface_to_Light));
vec3 Diffuse = diffuse_Coefficient * lit_surface_Color;
float specular_Coefficient = 0.0;
if (diffuse_Coefficient > 0.0)
specular_Coefficient = pow (max (0.0,
dot (Surface_to_Camera,
reflect (-Surface_to_Light,
Normal))),
frag_Shine);
vec3 Specular = specular_Coefficient * specular_Color * Light.Color;
return Ambient + Attenuation * (Diffuse + Specular); // Linear color (before gamma correction).
}
void
main()
{
vec3 surface_Site = vec3 ( model_Transform
* vec4 (frag_Site, 1));
vec4 surface_Color = texture (Texture, 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);
for (int i = 0; i < light_Count; ++i)
{
linear_Color += apply_Light (Lights [i],
surface_Color.rgb,
Normal,
surface_Site,
Surface_to_Camera);
}
vec3 Gamma = vec3 (1.0 / 2.2);
final_Color = vec4 (pow (linear_Color, // Final color (after gamma correction).
Gamma),
surface_Color.a);
}

View File

@@ -0,0 +1,116 @@
#version 140
uniform mat4 mvp_Transform;
uniform vec3 Scale;
uniform mat4 bone_Matrices[120];
in vec3 Site;
in vec3 Normal;
in vec2 Coords;
in float Shine;
in vec4 bone_Ids;
in vec4 bone_Weights;
out vec3 frag_Site;
out vec3 frag_Normal;
out vec2 frag_Coords;
out float frag_Shine;
const float c_zero = 0.0;
const float c_one = 1.0;
void main()
{
vec4 transformedPosition = vec4 (0.0);
vec3 transformedNormal = vec3 (0.0);
if (int (bone_Ids.x) == 0) // No bones affect this vertex.
{
transformedPosition = vec4 (Site, c_one);
transformedNormal = Normal;
}
else
{
// Bone 1.
//
mat4 m44 = bone_Matrices [int (bone_Ids.x) - 1];
// Transform the offset by bone 1.
transformedPosition += m44 * vec4 (Site, c_one) * bone_Weights.x;
mat3 m33 = mat3 (m44[0].xyz,
m44[1].xyz,
m44[2].xyz);
// Transform the normal by bone 1.
transformedNormal += m33 * Normal * bone_Weights.x;
if (int(bone_Ids.y) != 0)
{
// Bone 2.
//
m44 = bone_Matrices [int (bone_Ids.y) - 1];
// Transform the offset by bone 2.
transformedPosition += m44 * vec4 (Site, c_one) * bone_Weights.y;
m33 = mat3 (m44[0].xyz,
m44[1].xyz,
m44[2].xyz);
// Transform the normal by bone 2.
transformedNormal += m33 * Normal * bone_Weights.y;
if (int (bone_Ids.z) != 0)
{
// Bone 3.
//
m44 = bone_Matrices [int (bone_Ids.z) - 1];
// Transform the offset by bone 3.
transformedPosition += m44 * vec4 (Site, c_one) * bone_Weights.z;
m33 = mat3 (m44[0].xyz,
m44[1].xyz,
m44[2].xyz);
// Transform the normal by bone 3.
transformedNormal += m33 * Normal * bone_Weights.z;
if (int (bone_Ids.w) != 0)
{
// Bone 4.
//
m44 = bone_Matrices [int (bone_Ids.w) - 1];
// Transform the offset by bone 4.
transformedPosition += m44 * vec4 (Site, c_one) * bone_Weights.w;
m33 = mat3 (m44[0].xyz,
m44[1].xyz,
m44[2].xyz);
// Transform the normal by bone 4.
transformedNormal += m33 * Normal * bone_Weights.w;
}
}
}
}
// Pass some variables to the fragment shader.
//
frag_Site = transformedPosition.xyz * Scale;
frag_Normal = normalize (transformedNormal);
frag_Coords = Coords;
frag_Shine = Shine;
// Apply all matrix transformations to 'Site'.
//
gl_Position = mvp_Transform * transformedPosition;
gl_Position = mvp_Transform * (transformedPosition * vec4 (Scale, 1));
}

View File

@@ -0,0 +1,69 @@
#version 120
struct directional_light
{
vec3 direction; // Normalized light direction in eye space.
vec3 halfplane; // Normalized half-plane vector.
vec4 ambient_color;
vec4 diffuse_color;
vec4 specular_color;
bool is_on;
};
uniform mat3 inv_modelview_Matrix;
uniform directional_light uLights [8];
uniform float uShine;
attribute vec3 aNormal;
attribute vec4 aColor;
varying vec4 vColor;
const float c_zero = 0.0;
const float c_one = 1.0;
vec4 // Returns the computed color.
directional_light_color (in vec3 normal, // 'normal' has been transformed into eye space and normalized.
in directional_light light)
{
if (!light.is_on)
return vec4 (0.0, 0.0, 0.0, 0.0);
vec4 computed_color = vec4 (c_zero, c_zero, c_zero, c_zero);
float NdotL; // Dot product of normal and light direction.
float NdotH; // Dot product of normal and half-plane vector.
NdotL = max (c_zero, dot (normal, light.direction));
NdotH = max (c_zero, dot (normal, light.halfplane));
computed_color += ( light.ambient_color * aColor);
computed_color += (NdotL * light.diffuse_color * aColor);
if (NdotH > c_zero)
computed_color += (pow (NdotH, uShine) * aColor * light.specular_color);
return computed_color;
}
void main()
{
vec3 light_Normal = normalize (aNormal) * inv_modelview_Matrix;
vColor = vec4 (0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < 8; i++)
{
vColor += directional_light_color (light_Normal, uLights [i]);
}
}

View File

@@ -0,0 +1,12 @@
#version 140
uniform sampler2D sTexture;
varying vec4 vColor;
varying vec2 vCoords;
void main()
{
gl_FragColor = texture2D (sTexture, vCoords) * vColor; // Modulate light color with texture.
}

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View File

@@ -0,0 +1,64 @@
with
"opengl_core",
"../private/freetype/library/freetype",
"collada",
"lace_shared";
--library
project Opengl
is
type Profile is ("safe", "lean", "desk");
The_Profile : Profile := external ("opengl_profile", "lean");
for Create_Missing_Dirs use "True";
for Object_Dir use "build";
for Library_Dir use "lib";
-- for Library_Name use "opengl";
case The_Profile is
when "safe" =>
for Source_Dirs use ("../source/safe");
when "lean" =>
for Source_Dirs use ("../source/lean",
"../source/lean/buffer",
"../source/lean/geometry/**",
"../source/lean/light",
"../source/lean/model",
"../source/lean/renderer",
"../source/lean/shader",
"../source/lean/support",
"../source/lean/text",
"../source/lean/io",
"../source/lean/text/private");
when "desk" =>
for Source_Dirs use ("../source/lean",
"../source/lean/buffer",
"../source/lean/geometry/**",
"../source/lean/light",
"../source/lean/model",
"../source/lean/renderer",
"../source/lean/shader",
"../source/lean/support",
"../source/lean/text",
"../source/lean/io",
"../source/lean/text/private",
"../source/desk");
end case;
package Builder renames Lace_shared.Builder;
package Binder renames Lace_shared.Binder;
package Compiler is
for Default_Switches ("ada") use Lace_shared.Compiler_Options;
for Switches ("opengl-io.adb") use ("-O0");
end Compiler;
package Linker
is
for Linker_Options use ("-g", "-lEGL", "-lGLESv2", "-lSDL2");
end Linker;
end Opengl;

View File

@@ -0,0 +1,44 @@
with
"../private/gl/library/gl",
"../private/gid/gid",
"math",
"lace_shared";
--library
project Opengl_Core
is
type Platform is ("egl", "glx", "osmesa");
The_Platform : Platform := external ("opengl_platform", "egl");
for Create_Missing_Dirs use "True";
for Object_Dir use "build";
for Library_Dir use "lib";
-- for Library_Name use "opengl_core";
case The_Platform is
when "egl" => for Languages use ("Ada");
when "glx" => for Languages use ("Ada", "C");
when "osmesa" => for Languages use ("Ada", "C");
end case;
for Source_Dirs use ("../source",
"../source/profile/" & external ("opengl_profile", "lean"),
"../source/platform/" & external ("opengl_platform", "egl"),
"../source/platform/" & external ("opengl_platform", "egl") & "/private",
"../source/platform/" & external ("opengl_platform", "egl") & "/private/thin");
package Builder renames Lace_shared.Builder;
package Compiler is
for Default_Switches ("ada") use Lace_shared.Compiler_Options;
for Switches ("opengl-images.adb") use ("-O0");
end Compiler;
package Binder renames Lace_shared.Binder;
end Opengl_Core;

View File

@@ -0,0 +1,24 @@
with
"opengl",
"sdlada",
"lace_shared";
--library
project openGL_Demo
is
for Create_Missing_Dirs use "True";
for Source_Dirs use ("../source/demo");
for Object_Dir use "build";
for Library_Dir use "lib";
-- for Library_Name use "openGL_Demo";
package Builder renames Lace_shared.Builder;
package Compiler
is
for Default_Switches ("ada") use Lace_shared.Compiler_Options;
for Switches ("opengl-images.adb") use ("-O0");
end Compiler;
end openGL_Demo;

View File

@@ -0,0 +1,16 @@
with
"../../../library/freetype",
"lace_shared";
project freetype_linkage_Test
is
for Object_Dir use "build";
for Exec_Dir use ".";
for Main use ("launch_freetype_linkage_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 freetype_linkage_Test;

View File

@@ -0,0 +1,126 @@
with
freetype_C.Binding,
freetype_C.FT_Vector,
freetype_C.FT_Bitmap,
freetype_C.FT_Size_Metrics,
freetype_C.FT_BBox,
freetype_C.FT_CharMapRec,
interfaces.C.Strings;
procedure launch_freetype_linkage_Test
--
-- Tests linkage to Freetype functions.
-- Is not meant to be run.
--
is
use Freetype_C,
freetype_C.Binding,
Interfaces;
an_Error : FT_Error;
pragma Unreferenced (an_Error);
an_FT_UShort : FT_UShort;
pragma Unreferenced (an_FT_UShort);
an_FT_Uint : FT_Uint;
pragma Unreferenced (an_FT_Uint);
an_FT_Int : FT_Int;
pragma Unreferenced (an_FT_Int);
an_FT_Long : FT_Long;
pragma Unreferenced (an_FT_Long);
an_FT_Outline : access FT_Outline;
pragma Unreferenced (an_FT_Outline);
an_FT_Vector : FT_Vector.Item;
pragma Unreferenced (an_FT_Vector);
an_FT_Bitmap : FT_Bitmap.Item;
pragma Unreferenced (an_FT_Bitmap);
an_Unsigned : interfaces.c.unsigned;
pragma Unreferenced (an_Unsigned);
an_FT_Size_Metrics : FT_Size_Metrics.Item;
pragma Unreferenced (an_FT_Size_Metrics);
an_FT_Face : access freetype_c.FT_FaceRec;
pragma Unreferenced (an_FT_Face);
an_FT_SizeRec : access freetype_c.FT_SizeRec;
pragma Unreferenced (an_FT_SizeRec);
an_FT_BBox : FT_BBox.item;
pragma Unreferenced (an_FT_BBox);
an_FT_CharMap : access freetype_c.FT_CharMapRec.Item;
pragma Unreferenced (an_FT_CharMap);
an_FT_GlyphSlot : access freetype_c.FT_GlyphSlotRec;
pragma Unreferenced (an_FT_GlyphSlot);
begin
FT_Outline_Get_CBox (null, null);
an_Error := FT_Init_FreeType (null);
an_Error := FT_Done_FreeType (null);
an_Error := FT_Render_Glyph (null, FT_RENDER_MODE_NORMAL);
an_Error := FT_Set_Char_Size (null, 0, 0, 0, 0);
an_Error := FT_Done_Face (null);
an_Error := FT_Attach_File (null, Interfaces.C.Strings.null_ptr);
an_Error := FT_Set_Charmap (null, null);
an_Error := FT_Select_Charmap (null, 0);
an_FT_uint := FT_Get_Char_Index (null, 0);
an_Error := FT_Get_Kerning (null, 0, 0, 0, null);
an_Error := FT_Load_Glyph (null, 0, 0);
an_FT_Outline := FT_GlyphSlot_Get_Outline (null);
an_FT_Vector := FT_GlyphSlot_Get_Advance (null);
an_FT_Bitmap := FT_GlyphSlot_Get_Bitmap (null);
an_FT_Int := FT_GlyphSlot_Get_bitmap_left (null);
an_FT_Int := FT_GlyphSlot_Get_bitmap_top (null);
an_Unsigned := FT_GlyphSlot_Get_Format (null);
an_FT_Size_Metrics := FT_Size_Get_Metrics (null);
an_FT_Face := new_FT_Face (null, C.Strings.null_ptr);
an_FT_Face := new_FT_Memory_Face (null, null, 0);
an_FT_SizeRec := FT_Face_Get_Size (null);
an_FT_Long := FT_Face_IS_SCALABLE (null);
an_FT_Long := FT_Face_HAS_KERNING (null);
an_FT_BBox := FT_Face_Get_BBox (null);
an_FT_UShort := FT_Face_Get_units_per_EM (null);
an_FT_Long := FT_Face_Get_num_glyphs (null);
an_FT_CharMap := FT_Face_Get_charmap (null);
an_FT_CharMap := FT_Face_Get_charmap_at (null, 0);
an_FT_Int := FT_Face_Get_num_charmaps (null);
an_FT_GlyphSlot := FT_Face_Get_glyph (null);
an_Error := FT_Face_Attach_Stream (null, null, 0);
an_Unsigned := get_FT_GLYPH_FORMAT_NONE;
an_Unsigned := get_FT_GLYPH_FORMAT_COMPOSITE;
an_Unsigned := get_FT_GLYPH_FORMAT_BITMAP;
an_Unsigned := get_FT_GLYPH_FORMAT_OUTLINE;
an_Unsigned := get_FT_GLYPH_FORMAT_PLOTTER;
an_Unsigned := FT_ENCODING_NONE_enum;
an_Unsigned := FT_ENCODING_MS_SYMBOL_enum;
an_Unsigned := FT_ENCODING_UNICODE_enum;
an_Unsigned := FT_ENCODING_SJIS_enum;
an_Unsigned := FT_ENCODING_GB2312_enum;
an_Unsigned := FT_ENCODING_BIG5_enum;
an_Unsigned := FT_ENCODING_WANSUNG_enum;
an_Unsigned := FT_ENCODING_JOHAB_enum;
an_Unsigned := FT_ENCODING_ADOBE_STANDARD_enum;
an_Unsigned := FT_ENCODING_ADOBE_EXPERT_enum;
an_Unsigned := FT_ENCODING_ADOBE_CUSTOM_enum;
an_Unsigned := FT_ENCODING_ADOBE_LATIN_1_enum;
an_Unsigned := FT_ENCODING_OLD_LATIN_2_enum;
an_Unsigned := FT_ENCODING_APPLE_ROMAN_enum;
an_Unsigned := FT_LOAD_DEFAULT_flag;
an_Unsigned := FT_LOAD_NO_SCALE_flag;
an_Unsigned := FT_LOAD_NO_HINTING_flag;
an_Unsigned := FT_LOAD_RENDER_flag;
an_Unsigned := FT_LOAD_NO_BITMAP_flag;
an_Unsigned := FT_LOAD_VERTICAL_LAYOUT_flag;
an_Unsigned := FT_LOAD_FORCE_AUTOHINT_flag;
an_Unsigned := FT_LOAD_CROP_BITMAP_flag;
an_Unsigned := FT_LOAD_PEDANTIC_flag;
an_Unsigned := FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH_flag;
an_Unsigned := FT_LOAD_NO_RECURSE_flag;
an_Unsigned := FT_LOAD_IGNORE_TRANSFORM_flag;
an_Unsigned := FT_LOAD_MONOCHROME_flag;
an_Unsigned := FT_LOAD_LINEAR_DESIGN_flag;
an_Unsigned := FT_LOAD_NO_AUTOHINT_flag;
end launch_freetype_linkage_Test;

View File

@@ -0,0 +1,22 @@
with
"freetype_thin",
"lace_shared";
--library
project Freetype
is
for Source_Dirs use ("../source");
for Object_Dir use "build";
for Library_Dir use "lib";
-- for Library_Name use "freetype_ada";
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 Linker_Options use ("-g");
end Linker;
end Freetype;

View File

@@ -0,0 +1,23 @@
project FreeType_C
is
for Languages use ("C");
for Source_Dirs use ("../source/**");
for Object_Dir use "build";
for Library_Dir use "lib";
for Library_Ali_Dir use "objects";
-- for Library_Name use "freetype_c";
package Naming is
for Spec_Suffix ("c") use ".h";
for Body_Suffix ("c") use ".c";
end Naming;
package Compiler is
for Default_Switches ("c") use ("-g", "-I/usr/include/freetype2");
end Compiler;
package Linker is
for Linker_Options use ("-g", "-lfreetype");
end Linker;
end FreeType_C;

View File

@@ -0,0 +1,20 @@
with
"freetype_c",
"lace_shared";
project FreeType_thin
is
for Languages use ("Ada");
for Source_Dirs use (".", "../source/thin");
for Object_Dir use "build";
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 Linker_Options use ("-g");
end Linker;
end FreeType_thin;

View File

@@ -0,0 +1,148 @@
with
freetype.Face,
freeType_C.Binding;
package body freetype.charMap
is
use freeType_C;
-----------
-- Utility
--
function to_characterCode (From : in Character) return characterCode
is
begin
return Character'Pos (From) + 1;
end to_characterCode;
---------
-- Forge
--
function to_charMap (parent_Face : access Face.item'Class) return Item
is
use freetype_c.Binding;
use type FT_int;
Self : Item;
begin
Self.ftFace := parent_Face.freetype_Face;
Self.Err := 0;
if FT_Face_Get_charmap (Self.ftFace) = null
then
if FT_Face_Get_num_charmaps (Self.ftFace) = 0
then
Self.Err := 16#96#;
return Self;
end if;
Self.Err := FT_Set_Charmap (Self.ftFace,
FT_Face_Get_charmap_at (Self.ftFace, 0));
end if;
Self.ftEncoding := FT_Face_Get_charmap (Self.ftFace).Encoding;
for i in characterCode'(1) .. max_Precomputed
loop
Self.charIndexCache (i) := FT_Get_Char_Index (Self.ftFace,
FT_ULong (i - 1));
end loop;
return Self;
end to_charMap;
procedure destruct (Self : in out Item)
is
begin
Self.charMap.clear;
end destruct;
--------------
-- Attributes
--
function Encoding (Self : in Item) return FT_Encoding
is
begin
return Self.ftEncoding;
end Encoding;
function CharMap (Self : access Item; Encoding : in FT_Encoding) return Boolean
is
use freeType_C.Binding;
use type FT_Encoding,
FT_Error;
begin
if Self.ftEncoding = Encoding
then
Self.Err := 0;
return True;
end if;
Self.Err := FT_Select_Charmap (Self.ftFace, Encoding);
if Self.Err = 0
then
Self.ftEncoding := Encoding;
Self.charMap.clear;
end if;
return Self.Err = 0;
end CharMap;
function GlyphListIndex (Self : in Item; Character : in CharacterCode) return GlyphIndex
is
begin
return Self.charMap.Element (Character);
exception
when Constraint_Error =>
return -1;
end GlyphListIndex;
function FontIndex (Self : in Item; Character : in characterCode) return GlyphIndex
is
use freeType_C.Binding;
begin
if Character < max_Precomputed
then
return GlyphIndex (Self.charIndexCache (Character));
end if;
return GlyphIndex (FT_Get_Char_Index (Self.ftFace,
Character));
end FontIndex;
procedure insertIndex (Self : in out Item; Character : in characterCode;
containerIndex : in ada.Containers.Count_type)
is
begin
Self.charMap.insert (Character,
GlyphIndex (containerIndex));
end insertIndex;
function Error (Self : in Item) return FT_Error
is
begin
return Self.Err;
end Error;
end freetype.charMap;

View File

@@ -0,0 +1,150 @@
with
freeType_C,
interfaces.C,
ada.Containers.hashed_Maps;
limited
with
freetype.Face;
private
with
freeType_C.FT_Face,
ada.unchecked_Conversion;
package freetype.charMap
--
-- 'charMap' takes care of specifying the encoding for a font and mapping
-- character codes to glyph indices.
--
-- It doesn't preprocess all indices, only on an as needed basis. This may
-- seem like a performance penalty but it is quicker than using the 'raw'
-- freetype calls and will save significant amounts of memory when dealing
-- with unicode encoding.
--
is
type Item is tagged private;
---------
-- Types
--
use Interfaces;
subtype GlyphIndex is C.long;
subtype CharacterCode is C.unsigned_long;
function to_characterCode (From : in Character) return characterCode;
---------
-- Forge
--
function to_charMap (parent_Face : access Face.item'Class) return Item;
procedure destruct (Self : in out Item);
--------------
-- Attributes
--
function Encoding (Self : in Item) return freeType_C.FT_Encoding;
--
-- Queries for the current character map code.
--
-- Returns the current character map code.
function CharMap (Self : access Item; Encoding : in freeType_C.FT_Encoding) return Boolean;
--
-- Sets the character map for the face. If an error occurs the object is not modified.
--
-- Valid encodings as at Freetype 2.0.4
-- - ft_encoding_none
-- - ft_encoding_symbol
-- - ft_encoding_unicode
-- - ft_encoding_latin_2
-- - ft_encoding_sjis
-- - ft_encoding_gb2312
-- - ft_encoding_big5
-- - ft_encoding_wansung
-- - ft_encoding_johab
-- - ft_encoding_adobe_standard
-- - ft_encoding_adobe_expert
-- - ft_encoding_adobe_custom
-- - ft_encoding_apple_roman
--
-- Encoding: The Freetype encoding symbol.
--
-- Returns true if charmap was valid and set correctly.
function GlyphListIndex (Self : in Item; Character : in CharacterCode) return GlyphIndex;
--
-- Get the Glyph Container index of the input character.
--
-- Character: The character code of the requested glyph in the current encoding (eg apple roman).
--
-- Returns the FTGlyphContainer index for the character or zero if it wasn't found.
function FontIndex (Self : in Item; Character : in characterCode) return GlyphIndex;
--
-- Get the font glyph index of the input character.
--
-- Character: The character code of the requested glyph in the current encoding (eg apple roman).
--
-- Returns the glyph index for the character.
procedure insertIndex (Self : in out Item; Character : in characterCode;
ContainerIndex : in ada.Containers.Count_type);
--
-- Set the FTGlyphContainer index of the character code.
--
-- Character: The character code of the requested glyph in the current encoding eg apple roman.
-- containerIndex: The index into the Glyph Container of the character code.
function Error (Self : in Item) return freeType_C.FT_Error;
--
-- Queries for errors.
--
-- Returns the current error code. Zero means no error.
private
function Hash is new ada.unchecked_Conversion (CharacterCode, ada.Containers.Hash_type);
use type CharacterCode,
GlyphIndex;
package char_Maps_of_glyph_index is new ada.Containers.hashed_Maps (CharacterCode,
GlyphIndex,
Hash,
"=");
subtype char_Map_of_glyph_index is char_Maps_of_glyph_index.Map;
--
-- A structure that maps glyph indices to character codes/
max_Precomputed : constant := 128;
type Cache is array (characterCode range 1 .. max_Precomputed) of freeType_C.FT_UInt;
type Item is tagged
record
ftEncoding : freeType_C.FT_Encoding; -- Current character map code.
ftFace : freeType_C.FT_Face.item; -- The current Freetype face.
charMap : char_Maps_of_glyph_index.Map;
charIndexCache : Cache; -- Precomputed font indices.
Err : freeType_C.FT_Error; -- Current error code.
end record;
end freetype.charMap;

View File

@@ -0,0 +1,369 @@
with
freeType_C.Binding,
freeType_C.FT_Library,
freeType_C.FT_Vector,
freeType_C.Pointers,
interfaces.C.Strings,
ada.unchecked_Conversion,
ada.unchecked_Deallocation,
ada.Finalization;
package body freetype.Face
is
-----------
--- Globals
--
the_FT_Library : aliased FT_Library.item;
-----------
--- Utility
--
function to_Flag is new ada.unchecked_Conversion (FT_Kerning_Mode, C.unsigned);
procedure deallocate is new ada.Unchecked_Deallocation (float_Array, float_Array_view);
---------
--- Forge
--
package body Forge
is
function to_Face (fontFilePath : in String;
precomputeKerning : in Boolean) return Face.item
is
use freeType_C.Binding,
freeType_C.Pointers,
C.Strings;
use type freeType_C.FT_Long;
Self : Item;
the_font_Path : chars_ptr := new_String (fontFilePath);
begin
Self.numGlyphs := 0;
Self.Err := 0;
Self.ftFace := new_FT_Face (the_FT_Library, the_font_Path);
free (the_font_Path);
if Self.ftFace = null
then
raise freetype.Error with "Failed to create a freeType face for '" & fontFilePath & "'.";
end if;
Self.numGlyphs := Integer (FT_Face_Get_num_glyphs (Self.ftFace));
Self.hasKerningTable := FT_Face_HAS_KERNING (Self.ftFace) /= 0;
if Self.hasKerningTable
and precomputeKerning
then
Self.BuildKerningCache;
end if;
return Self;
end to_Face;
function to_Face (pBufferBytes : access C.unsigned_char;
bufferSizeInBytes : in Positive;
precomputeKerning : in Boolean) return Face.item
is
use freeType_C.Binding,
freeType_C.Pointers;
use type FT_Long;
Self : Face.item;
begin
Self.numGlyphs := 0;
Self.Err := 0;
Self.ftFace := new_FT_Memory_Face (the_FT_Library,
pBufferBytes.all'Access,
C.int (bufferSizeInBytes));
if Self.ftFace = null
then
raise freetype.Error with "Failed to create a freeType memory face.";
end if;
Self.numGlyphs := Integer (FT_Face_Get_num_glyphs (Self.ftFace));
Self.hasKerningTable := FT_Face_HAS_KERNING (Self.ftFace) /= 0;
if Self.hasKerningTable
and precomputeKerning
then
Self.BuildKerningCache;
end if;
return Self;
end to_Face;
procedure destruct (Self : in out Item)
is
use freeType_C.Binding;
use type Pointers.FT_FaceRec_Pointer;
begin
if Self.kerningCache /= null
then
deallocate (Self.kerningCache);
end if;
if Self.ftFace /= null
then
Self.Err := FT_Done_Face (Self.ftFace);
Self.ftFace := null;
end if;
end destruct;
end Forge;
function attach (Self : access Item; fontFilePath : in String) return Boolean
is
use freeType_C.Binding,
C.Strings;
use type FT_Error;
the_font_Path : chars_ptr := new_String (fontFilePath);
begin
Self.Err := FT_Attach_File (Self.ftFace, the_font_Path);
free (the_font_Path);
return Self.Err = 0;
end attach;
function attach (Self : access Item; pBufferBytes : access C.unsigned_char;
bufferSizeInBytes : in Positive) return Boolean
is
use freeType_C.Binding;
use type FT_Error;
begin
Self.Err := FT_Face_Attach_Stream (Self.ftFace,
pBufferBytes.all'Access,
C.size_t (bufferSizeInBytes));
return Self.Err = 0;
end Attach;
function freetype_Face (Self : in Item) return FT_Face.item
is
begin
return Self.ftFace;
end freetype_Face;
function Size (Self : access Item; Size : in Natural;
x_Res, y_Res : in Natural) return freetype.face_Size.item
is
Success : Boolean;
pragma unreferenced (Success);
begin
Success := Self.charSize.CharSize (Self.ftFace,
Size,
x_Res, y_Res);
Self.Err := Self.charSize.Error;
return Self.charSize;
end Size;
function CharMapCount (Self : in Item) return Natural
is
use freeType_C.Binding;
begin
return Natural (FT_Face_Get_num_charmaps (Self.ftFace));
end CharMapCount;
function CharMapList (Self : access Item) return FT_Encodings_view
is
use freeType_C.Binding;
begin
if Self.fontEncodingList = null
then
Self.fontEncodingList := new FT_Encodings (1 .. Self.CharMapCount);
for i in 1 .. Self.CharMapCount
loop
Self.fontEncodingList (i) := FT_Face_Get_charmap_at (Self.ftFace,
C.int (i) ).Encoding;
end loop;
end if;
return Self.fontEncodingList;
end CharMapList;
function KernAdvance (Self : access Item; Index1 : in Natural;
Index2 : in Natural) return Vector_3
is
use freeType_C.Binding;
use type FT_Error;
X, Y : Float;
kernAdvance : aliased FT_Vector.item;
begin
if not Self.hasKerningTable
or Index1 = 0
or Index2 = 0
then
return [0.0, 0.0, 0.0];
end if;
if Self.kerningCache /= null
and Index1 < max_Precomputed -- TODO: Check this whole function matches C code.
and Index2 < max_Precomputed
then
declare
max_Index : C.ptrdiff_t := C.ptrdiff_t (2 * (Index2 * max_Precomputed + Index1) + 1); -- TODO: Check this against C code.
begin
X := Float (Self.kerningCache (C.size_t (2 * (Index2 * max_Precomputed + Index1))));
Y := Float (Self.kerningCache (C.size_t (2 * (Index2 * max_Precomputed + Index1) + 1)));
return [X, Y, 0.0];
end;
end if;
kernAdvance.X := 0;
kernAdvance.Y := 0;
Self.Err := FT_Get_Kerning (Self.ftFace,
C.unsigned (index1),
C.unsigned (index2),
to_Flag (ft_Kerning_unfitted),
kernAdvance'unchecked_Access);
if Self.Err /= 0
then
return [0.0, 0.0, 0.0];
end if;
X := Float (kernAdvance.x) / 64.0;
Y := Float (kernAdvance.y) / 64.0;
return [X, Y, 0.0];
end KernAdvance;
function GlyphCount (Self : in Item) return Natural
is
begin
return Self.numGlyphs;
end GlyphCount;
function Glyph (Self : access Item; Index : in freetype.charMap.glyphIndex;
load_Flags : in freeType_C.FT_Int) return FT_GlyphSlot.item
is
use freeType_C.Binding;
use type FT_Error,
FT_Face.item;
begin
if Self.ftFace = null
then
raise freetype.Error with "Face is null.";
end if;
Self.Err := FT_Load_Glyph (Self.ftFace, FT_UInt (Index), load_Flags);
if Self.Err /= 0 then
return null;
end if;
return FT_GlyphSlot.item (FT_Face_Get_glyph (Self.ftFace));
end Glyph;
function Error (Self : in Item) return FT_Error
is
begin
return Self.Err;
end Error;
procedure BuildKerningCache (Self : in out Item)
is
use freeType_C.Binding;
use type FT_UInt,
FT_Error,
C.C_float;
max_Index : constant C.ptrdiff_t := C.ptrdiff_t (max_Precomputed * max_Precomputed * 2);
kernAdvance : aliased FT_Vector.item;
begin
kernAdvance.x := 0;
kernAdvance.y := 0;
Self.kerningCache := new float_Array' (1 .. C.size_t (max_Index) => <>);
for j in 1 .. FT_UInt' (max_Precomputed)
loop
for i in 1 .. FT_UInt' (max_Precomputed)
loop
Self.Err := FT_Get_Kerning (Self.ftFace,
i, j,
to_Flag (ft_Kerning_unfitted),
kernAdvance'unchecked_Access);
if Self.Err /= 0
then
deallocate (Self.kerningCache);
return;
end if;
Self.kerningCache (C.size_t (2 * (j * max_Precomputed + i) )) := C.C_float (kernAdvance.X) / 64.0;
Self.kerningCache (C.size_t (2 * (j * max_Precomputed + i) + 1)) := C.C_float (kernAdvance.Y) / 64.0;
end loop;
end loop;
end BuildKerningCache;
-------------------
-- Package Closure
--
type Closure is new ada.Finalization.controlled with null record;
overriding
procedure finalize (Object : in out Closure)
is
use freeType_C.Binding;
Status : FT_Error with unreferenced;
begin
Status := FT_Done_FreeType (the_FT_Library);
end finalize;
the_Closure : Closure with Unreferenced;
--------------------------
-- Package Initialisation
--
use freeType_C.Binding;
Status : FT_Error with unreferenced;
begin
Status := FT_init_FreeType (the_FT_Library'Access);
end freetype.Face;

View File

@@ -0,0 +1,150 @@
with
freetype.face_Size,
freetype.charMap,
freeType_C.FT_Face,
freeType_C.FT_GlyphSlot,
interfaces.C;
package freetype.Face
--
-- The Face class provides an abstraction layer for the Freetype Face.
--
is
type Item is tagged private;
type View is access all Item'Class;
---------
-- Types
--
type FT_Encodings is array (Positive range <>) of freeType_C.FT_Encoding;
type FT_Encodings_view is access all FT_Encodings;
---------
-- Forge
--
use Interfaces;
package Forge
is
function to_Face (fontFilePath : in String;
precomputeKerning : in Boolean) return Face.item;
--
-- Opens and reads a face file. Error is set.
function to_Face (pBufferBytes : access C.unsigned_char; -- The in-memory buffer.
bufferSizeInBytes : in Positive; -- The length of the buffer in bytes.
precomputeKerning : in Boolean) return Face.item;
--
-- Read face data from an in-memory buffer. Error is set.
procedure destruct (Self : in out Item); -- Disposes of the current Freetype face.
end Forge;
--------------
-- Attributes
--
function attach (Self : access Item; fontFilePath : in String) return Boolean;
--
-- Attach auxilliary file to font (e.g., font metrics).
--
-- fontFilePath: Auxilliary font file path.
--
-- Returns true if file has opened successfully.
function attach (Self : access Item; pBufferBytes : access C.unsigned_char;
bufferSizeInBytes : in Positive) return Boolean;
--
-- Attach auxilliary data to font (e.g., font metrics) from memory.
--
-- pBufferBytes: The in-memory buffer.
-- bufferSizeInBytes: The length of the buffer in bytes.
--
-- Returns true if file has opened successfully.
function freetype_Face (Self : in Item) return freeType_C.FT_Face.item;
--
-- Get the freetype face object.
--
-- Returns a pointer to an FT_Face.
function Size (Self : access Item; Size : in Natural;
x_Res, y_Res : in Natural) return freetype.face_Size.item;
--
-- Sets the char size for the current face.
-- This doesn't guarantee that the size was set correctly. Clients should check errors.
--
-- Size: The face size in points (1/72 inch).
-- x_Res, y_Res: The resolution of the target device.
--
-- Returns FTSize object.
function CharMapCount (Self : in Item) return Natural;
--
-- Get the number of character maps in this face.
--
-- Return character map count.
function CharMapList (Self : access Item) return FT_Encodings_view;
--
-- Get a list of character maps in this face.
--
-- Returns a pointer to the first encoding.
function KernAdvance (Self : access Item; Index1 : in Natural;
Index2 : in Natural) return Vector_3;
--
-- Gets the kerning vector between two glyphs.
function GlyphCount (Self : in Item) return Natural;
--
-- Gets the number of glyphs in the current face.
function Glyph (Self : access Item; Index : in freetype.charMap.glyphIndex;
load_Flags : in freeType_C.FT_Int) return freeType_C.FT_GlyphSlot.item;
function Error (Self : in Item) return freeType_C.FT_Error;
--
-- Return the current error code.
private
use freeType_C;
type Float_array is array (C.size_t range <>) of aliased C.c_float;
type Float_array_view is access all Float_array;
type Item is tagged
record
ftFace : FT_Face .item; -- The Freetype face.
charSize : aliased face_Size.item; -- The size object associated with this face.
numGlyphs : Natural; -- The number of glyphs in this face.
fontEncodingList : FT_Encodings_view;
hasKerningTable : Boolean; -- This face has kerning tables.
kerningCache : Float_array_view; -- If this face has kerning tables, we can cache them.
Err : FT_Error; -- Current error code. Zero means no error.
end record;
max_Precomputed : constant := 128;
procedure BuildKerningCache (Self : in out Item);
end freetype.Face;

View File

@@ -0,0 +1,142 @@
with
freeType_C.Binding,
freeType_C.Pointers;
package body freetype.face_Size
is
use freeType_C;
--------------
--- Attributes
--
function CharSize (Self : access Item; Face : in FT_Face.item;
point_Size : in Natural;
x_Resolution,
y_Resolution : in Natural) return Boolean
is
use freeType_C.Binding;
use type FT_Error,
FT_F26Dot6;
begin
if Self.Size /= point_Size
or else Self.xResolution /= x_Resolution
or else Self.yResolution /= y_Resolution
then
Self.Err := FT_Set_Char_Size (Face,
0,
FT_F26Dot6 (point_size) * 64,
FT_UInt (Self.xResolution),
FT_UInt (Self.yResolution));
if Self.Err = 0
then
Self.ftFace := Face;
Self.Size := point_Size;
Self.xResolution := x_Resolution;
Self.yResolution := y_Resolution;
Self.ftSize := FT_Face_Get_Size (Self.ftFace);
end if;
end if;
return Self.Err = 0;
end CharSize;
function CharSize (Self : in Item) return Natural
is
begin
return Self.Size;
end CharSize;
function Ascender (Self : in Item) return Float
is
use freeType_C.Binding,
freeType_C.Pointers;
begin
if Self.ftSize = null
then return 0.0;
else return Float (FT_Size_Get_Metrics (Self.ftSize).Ascender) / 64.0;
end if;
end Ascender;
function Descender (Self : in Item) return Float
is
use freeType_C.Binding,
freeType_C.Pointers;
begin
if Self.ftSize = null
then return 0.0;
else return Float (FT_Size_Get_Metrics (Self.ftSize).Descender) / 64.0;
end if;
end Descender;
function Height (Self : in Item) return Float
is
use freeType_C.Binding,
freeType_C.Pointers;
use type FT_Long;
begin
if Self.ftSize = null
then
return 0.0;
end if;
if FT_Face_IS_SCALABLE (Self.ftFace) /= 0
then
return Float (FT_Face_get_BBox (Self.ftFace).yMax - FT_Face_get_BBox (Self.ftFace).yMin)
* (Float (FT_Size_get_Metrics (Self.ftSize).y_ppem) / Float (FT_Face_get_Units_per_EM (Self.ftFace)));
else
return Float (FT_Size_get_Metrics (Self.ftSize).Height) / 64.0;
end if;
end Height;
function Width (Self : in Item) return Float
is
use freeType_C.Binding,
freeType_C.Pointers;
use type FT_Long;
begin
if Self.ftSize = null
then
return 0.0;
end if;
if FT_Face_IS_SCALABLE (Self.ftFace) /= 0
then
return Float (FT_Face_get_BBox (Self.ftFace).xMax - FT_Face_get_BBox (Self.ftFace).xMin)
* (Float (FT_Size_get_Metrics (Self.ftSize).x_ppem) / Float (FT_Face_get_Units_per_EM (Self.ftFace)));
else
return Float (FT_Size_get_Metrics (Self.ftSize).max_Advance) / 64.0;
end if;
end Width;
function Underline (Self : in Item) return Float
is
pragma unreferenced (Self);
begin
return 0.0;
end Underline;
function Error (Self : in Item) return FT_Error
is
begin
return Self.Err;
end Error;
end freetype.face_Size;

View File

@@ -0,0 +1,103 @@
with
freeType_C.FT_Face,
freeType_C.FT_Size;
package freetype.face_Size
--
-- The face_Size class provides an abstraction layer for the Freetype Size type.
--
is
type Item is tagged private;
type View is access all Item'Class;
---------
--- Forge
--
procedure destruct (Self : in out Item) is null;
--------------
--- Attributes
--
function CharSize (Self : access Item; Face : in freeType_C.FT_Face.item;
point_Size : in Natural;
x_Resolution,
y_Resolution : in Natural) return Boolean;
--
-- Sets the char size for the current face.
--
-- This doesn't guarantee that the size was set correctly. Clients should call 'check Error' for
-- more information if this function returns false. If an error does occur the size object isn't modified.
--
-- Face: Parent face for this size object.
-- point_Size: The face size in points (1/72 inch).
-- x_Resolution: The horizontal resolution of the target device.
-- y_Resolution: The vertical resolution of the target device.
--
-- Returns true if the size has been set.
function CharSize (Self : in Item) return Natural; -- Returns the char size in points.
--
-- Get the char size for the current face.
function Ascender (Self : in Item) return Float; -- Returns the Ascender height.
--
-- Gets the global ascender height for the face in pixels.
function Descender (Self : in Item) return Float; -- Returns the Descender height.
--
-- Gets the global descender height for the face in pixels.
function Height (Self : in Item) return Float; -- Returns the height in pixels.
--
-- Gets the global face height for the face.
--
-- If the face is scalable this returns the height of the global
-- bounding box which ensures that any glyph will be less than or
-- equal to this height. If the font isn't scalable there is no
-- guarantee that glyphs will not be taller than this value.
function Width (Self : in Item) return Float; -- Returns the width in pixels.
--
-- Gets the global face width for the face.
--
-- If the face is scalable this returns the width of the global
-- bounding box which ensures that any glyph will be less than or
-- equal to this width. If the font isn't scalable this value is
-- the max_advance for the face.
function Underline (Self : in Item) return Float; -- Returns the underline position in pixels.
--
-- Gets the underline position for the face.
function Error (Self : in Item) return freeType_C.FT_Error; -- Returns the current error code.
--
-- Queries for errors.
private
type Item is tagged
record
ftFace : freeType_C.FT_Face.item; -- The current Freetype face that this FTSize object relates to.
ftSize : freeType_C.FT_Size.item; -- The freetype Size.
Size : Natural := 0; -- The size in points.
xResolution, -- The horizontal resolution.
yResolution : Natural := 0; -- The vertical resolution.
Err : freeType_C.FT_Error := 0; -- Current error code. Zero means no error.
end record;
end freetype.face_Size;

View File

@@ -0,0 +1,12 @@
package Freetype
--
-- A thick bindng to the 'Freetype' font library.
--
is
pragma Pure;
Error : exception;
type Vector_3 is array (Positive range 1 .. 3) of Float;
end Freetype;

View File

@@ -0,0 +1,220 @@
with
freetype_c.FT_BBox,
freetype_c.FT_Face,
freetype_c.FT_Bitmap,
freetype_c.FT_Library,
freetype_c.FT_Size_Metrics,
freetype_c.FT_CharMapRec,
freetype_c.FT_Size,
freetype_c.FT_Vector,
freetype_c.FT_GlyphSlot,
freetype_c.FT_CharMap,
freetype_c.Pointers,
Interfaces.C.Pointers,
Interfaces.C.Strings;
package freetype_c.Binding
--
-- Provides the Freetype library functions.
--
is
use freetype_c.Pointers;
-- unsigned_char_Pointer
--
type unsigned_char_Array is array (C.size_t range <>) of aliased C.unsigned_Char;
package c_unsigned_char_Pointers is new C.Pointers (Index => C.size_t,
Element => C.unsigned_Char,
element_Array => unsigned_char_Array,
default_Terminator => 0);
subtype unsigned_char_Pointer is c_unsigned_char_Pointers.Pointer;
---------------
-- Subprograms
--
procedure FT_Outline_Get_CBox (Outline : in FT_Outline_Pointer;
acBox : in FT_BBox.Pointer);
function FT_Init_FreeType (aLibrary : in FT_Library.Pointer) return FT_Error;
function FT_Done_FreeType (aLibrary : in FT_Library.Item) return FT_Error;
function FT_Render_Glyph (Slot : in FT_GlyphSlot.Item;
render_Mode : in FT_Render_Mode) return FT_Error;
function FT_Set_Char_Size (Face : in FT_Face.Item;
char_Width : in FT_F26Dot6;
char_Height : in FT_F26Dot6;
horz_Resolution : in FT_UInt;
vert_Resolution : in FT_UInt) return FT_Error;
function FT_Done_Face (Face : in FT_Face.Item) return FT_Error;
function FT_Attach_File (Face : in FT_Face.Item;
FilePathname : in C.strings.chars_ptr) return FT_Error;
function FT_Set_Charmap (Face : in FT_Face.Item;
charMap : in FT_CharMap.Item) return FT_Error;
function FT_Select_Charmap (Face : in FT_Face.Item;
Encoding : in FT_Encoding) return FT_Error;
function FT_Get_Char_Index (Face : in FT_Face.Item;
charCode : in FT_ULong) return FT_UInt;
function FT_Get_Kerning (Face : in FT_Face.Item;
left_Glyph : in FT_UInt;
right_Glyph : in FT_UInt;
kern_Mode : in FT_UInt;
aKerning : in FT_Vector.Pointer) return FT_Error;
function FT_Load_Glyph (Face : in FT_Face.Item;
Glyph_Index : in FT_UInt;
Load_Flags : in FT_Int32) return FT_Error;
function FT_GlyphSlot_Get_Outline (Self : in FT_GlyphSlot.Item) return access FT_Outline;
function FT_GlyphSlot_Get_Advance (Self : in FT_GlyphSlot.Item) return FT_Vector.Item;
function FT_GlyphSlot_Get_Bitmap (Self : in FT_GlyphSlot.Item) return FT_Bitmap.Item;
function FT_GlyphSlot_Get_bitmap_left (Self : in FT_GlyphSlot.Item) return FT_Int;
function FT_GlyphSlot_Get_bitmap_top (Self : in FT_GlyphSlot.Item) return FT_Int;
function FT_GlyphSlot_Get_Format (Self : in FT_GlyphSlot.Item) return C.unsigned;
function FT_Size_Get_Metrics (Self : in FT_Size.Item) return FT_Size_Metrics.Item;
function new_FT_Face (Library : in FT_Library.Item;
FontFilePath : in C.strings.chars_ptr) return access FT_FaceRec;
function new_FT_Memory_Face (Library : in FT_Library.Item;
pBufferBytes : in unsigned_char_Pointer;
BufferSizeInBytes : in C.int) return access FT_FaceRec;
function FT_Face_Get_Size (Self : in FT_Face.Item) return access FT_SizeRec;
function FT_Face_IS_SCALABLE (Self : in FT_Face.Item) return FT_Long;
function FT_Face_HAS_KERNING (Self : in FT_Face.Item) return FT_Long;
function FT_Face_Get_BBox (Self : in FT_Face.Item) return FT_BBox.Item;
function FT_Face_Get_units_per_EM (Self : in FT_Face.Item) return FT_UShort;
function FT_Face_Get_num_glyphs (Self : in FT_Face.Item) return FT_Long;
function FT_Face_Get_charmap (Self : in FT_Face.Item) return access FT_CharMapRec.Item;
function FT_Face_Get_charmap_at (Self : in FT_Face.Item; Index : in C.int) return access FT_CharMapRec.Item;
function FT_Face_Get_num_charmaps (Self : in FT_Face.Item) return FT_Int;
function FT_Face_Get_glyph (Self : in FT_Face.Item) return access FT_GlyphSlotRec;
function FT_Face_Attach_Stream (Self : in FT_Face.Item; pBufferBytes : in unsigned_char_Pointer;
BufferSizeInBytes : in C.size_t) return FT_Error;
function get_FT_GLYPH_FORMAT_NONE return C.unsigned;
function get_FT_GLYPH_FORMAT_COMPOSITE return C.unsigned;
function get_FT_GLYPH_FORMAT_BITMAP return C.unsigned;
function get_FT_GLYPH_FORMAT_OUTLINE return C.unsigned;
function get_FT_GLYPH_FORMAT_PLOTTER return C.unsigned;
function FT_ENCODING_NONE_enum return FT_Encoding;
function FT_ENCODING_MS_SYMBOL_enum return FT_Encoding;
function FT_ENCODING_UNICODE_enum return FT_Encoding;
function FT_ENCODING_SJIS_enum return FT_Encoding;
function FT_ENCODING_GB2312_enum return FT_Encoding;
function FT_ENCODING_BIG5_enum return FT_Encoding;
function FT_ENCODING_WANSUNG_enum return FT_Encoding;
function FT_ENCODING_JOHAB_enum return FT_Encoding;
function FT_ENCODING_ADOBE_STANDARD_enum return FT_Encoding;
function FT_ENCODING_ADOBE_EXPERT_enum return FT_Encoding;
function FT_ENCODING_ADOBE_CUSTOM_enum return FT_Encoding;
function FT_ENCODING_ADOBE_LATIN_1_enum return FT_Encoding;
function FT_ENCODING_OLD_LATIN_2_enum return FT_Encoding;
function FT_ENCODING_APPLE_ROMAN_enum return FT_Encoding;
function FT_LOAD_DEFAULT_flag return C.unsigned;
function FT_LOAD_NO_SCALE_flag return C.unsigned;
function FT_LOAD_NO_HINTING_flag return C.unsigned;
function FT_LOAD_RENDER_flag return C.unsigned;
function FT_LOAD_NO_BITMAP_flag return C.unsigned;
function FT_LOAD_VERTICAL_LAYOUT_flag return C.unsigned;
function FT_LOAD_FORCE_AUTOHINT_flag return C.unsigned;
function FT_LOAD_CROP_BITMAP_flag return C.unsigned;
function FT_LOAD_PEDANTIC_flag return C.unsigned;
function FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH_flag
return C.unsigned;
function FT_LOAD_NO_RECURSE_flag return C.unsigned;
function FT_LOAD_IGNORE_TRANSFORM_flag return C.unsigned;
function FT_LOAD_MONOCHROME_flag return C.unsigned;
function FT_LOAD_LINEAR_DESIGN_flag return C.unsigned;
function FT_LOAD_NO_AUTOHINT_flag return C.unsigned;
private
pragma Import (C, FT_Outline_Get_CBox, "FT_Outline_Get_CBox");
pragma Import (C, FT_Init_FreeType, "FT_Init_FreeType");
pragma Import (C, FT_Done_FreeType, "FT_Done_FreeType");
pragma Import (C, FT_Render_Glyph, "FT_Render_Glyph");
pragma Import (C, FT_Set_Char_Size, "FT_Set_Char_Size");
pragma Import (C, FT_Done_Face, "FT_Done_Face");
pragma Import (C, FT_Attach_File, "FT_Attach_File");
pragma Import (C, FT_Set_Charmap, "FT_Set_Charmap");
pragma Import (C, FT_Select_Charmap, "FT_Select_Charmap");
pragma Import (C, FT_Get_Char_Index, "FT_Get_Char_Index");
pragma Import (C, FT_Get_Kerning, "FT_Get_Kerning");
pragma Import (C, FT_Load_Glyph, "FT_Load_Glyph");
pragma Import (C, FT_GlyphSlot_Get_Outline, "FT_GlyphSlot_Get_Outline");
pragma Import (C, FT_GlyphSlot_Get_Advance, "FT_GlyphSlot_Get_Advance");
pragma Import (C, FT_GlyphSlot_Get_Bitmap, "FT_GlyphSlot_Get_Bitmap");
pragma Import (C, FT_GlyphSlot_Get_bitmap_left, "FT_GlyphSlot_Get_bitmap_left");
pragma Import (C, FT_GlyphSlot_Get_bitmap_top, "FT_GlyphSlot_Get_bitmap_top");
pragma Import (C, FT_GlyphSlot_Get_Format, "FT_GlyphSlot_Get_Format");
pragma Import (C, FT_Size_Get_Metrics, "FT_Size_Get_Metrics");
pragma Import (C, new_FT_Face, "new_FT_Face");
pragma Import (C, new_FT_Memory_Face, "new_FT_Memory_Face");
pragma Import (C, FT_Face_Get_Size, "FT_Face_Get_Size");
pragma Import (C, FT_Face_IS_SCALABLE, "FT_Face_IS_SCALABLE");
pragma Import (C, FT_Face_HAS_KERNING, "FT_Face_HAS_KERNING");
pragma Import (C, FT_Face_Get_BBox, "FT_Face_Get_BBox");
pragma Import (C, FT_Face_Get_units_per_EM, "FT_Face_Get_units_per_EM");
pragma Import (C, FT_Face_Get_num_glyphs, "FT_Face_Get_num_glyphs");
pragma Import (C, FT_Face_Get_charmap, "FT_Face_Get_charmap");
pragma Import (C, FT_Face_Get_charmap_at, "FT_Face_Get_charmap_at");
pragma Import (C, FT_Face_Get_num_charmaps, "FT_Face_Get_num_charmaps");
pragma Import (C, FT_Face_Get_glyph, "FT_Face_Get_glyph");
pragma Import (C, FT_Face_Attach_Stream, "FT_Face_Attach_Stream");
pragma Import (C, get_FT_GLYPH_FORMAT_NONE, "get_FT_GLYPH_FORMAT_NONE");
pragma Import (C, get_FT_GLYPH_FORMAT_COMPOSITE, "get_FT_GLYPH_FORMAT_COMPOSITE");
pragma Import (C, get_FT_GLYPH_FORMAT_BITMAP, "get_FT_GLYPH_FORMAT_BITMAP");
pragma Import (C, get_FT_GLYPH_FORMAT_OUTLINE, "get_FT_GLYPH_FORMAT_OUTLINE");
pragma Import (C, get_FT_GLYPH_FORMAT_PLOTTER, "get_FT_GLYPH_FORMAT_PLOTTER");
pragma Import (C, FT_ENCODING_NONE_enum, "FT_ENCODING_NONE_enum");
pragma Import (C, FT_ENCODING_MS_SYMBOL_enum, "FT_ENCODING_MS_SYMBOL_enum");
pragma Import (C, FT_ENCODING_UNICODE_enum, "FT_ENCODING_UNICODE_enum");
pragma Import (C, FT_ENCODING_SJIS_enum, "FT_ENCODING_SJIS_enum");
pragma Import (C, FT_ENCODING_GB2312_enum, "FT_ENCODING_GB2312_enum");
pragma Import (C, FT_ENCODING_BIG5_enum, "FT_ENCODING_BIG5_enum");
pragma Import (C, FT_ENCODING_WANSUNG_enum, "FT_ENCODING_WANSUNG_enum");
pragma Import (C, FT_ENCODING_JOHAB_enum, "FT_ENCODING_JOHAB_enum");
pragma Import (C, FT_ENCODING_ADOBE_STANDARD_enum, "FT_ENCODING_ADOBE_STANDARD_enum");
pragma Import (C, FT_ENCODING_ADOBE_EXPERT_enum, "FT_ENCODING_ADOBE_EXPERT_enum");
pragma Import (C, FT_ENCODING_ADOBE_CUSTOM_enum, "FT_ENCODING_ADOBE_CUSTOM_enum");
pragma Import (C, FT_ENCODING_ADOBE_LATIN_1_enum, "FT_ENCODING_ADOBE_LATIN_1_enum");
pragma Import (C, FT_ENCODING_OLD_LATIN_2_enum, "FT_ENCODING_OLD_LATIN_2_enum");
pragma Import (C, FT_ENCODING_APPLE_ROMAN_enum, "FT_ENCODING_APPLE_ROMAN_enum");
pragma Import (C, FT_LOAD_DEFAULT_flag, "FT_LOAD_DEFAULT_flag");
pragma Import (C, FT_LOAD_NO_SCALE_flag, "FT_LOAD_NO_SCALE_flag");
pragma Import (C, FT_LOAD_NO_HINTING_flag, "FT_LOAD_NO_HINTING_flag");
pragma Import (C, FT_LOAD_RENDER_flag, "FT_LOAD_RENDER_flag");
pragma Import (C, FT_LOAD_NO_BITMAP_flag, "FT_LOAD_NO_BITMAP_flag");
pragma Import (C, FT_LOAD_VERTICAL_LAYOUT_flag, "FT_LOAD_VERTICAL_LAYOUT_flag");
pragma Import (C, FT_LOAD_FORCE_AUTOHINT_flag, "FT_LOAD_FORCE_AUTOHINT_flag");
pragma Import (C, FT_LOAD_CROP_BITMAP_flag, "FT_LOAD_CROP_BITMAP_flag");
pragma Import (C, FT_LOAD_PEDANTIC_flag, "FT_LOAD_PEDANTIC_flag");
pragma Import (C, FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH_flag,
"FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH_flag");
pragma Import (C, FT_LOAD_NO_RECURSE_flag, "FT_LOAD_NO_RECURSE_flag");
pragma Import (C, FT_LOAD_IGNORE_TRANSFORM_flag, "FT_LOAD_IGNORE_TRANSFORM_flag");
pragma Import (C, FT_LOAD_MONOCHROME_flag, "FT_LOAD_MONOCHROME_flag");
pragma Import (C, FT_LOAD_LINEAR_DESIGN_flag, "FT_LOAD_LINEAR_DESIGN_flag");
pragma Import (C, FT_LOAD_NO_AUTOHINT_flag, "FT_LOAD_NO_AUTOHINT_flag");
end freetype_c.Binding;

View File

@@ -0,0 +1,20 @@
package freetype_c.FT_BBox
is
type Item is
record
xMin : aliased FT_Pos;
yMin : aliased FT_Pos;
xMax : aliased FT_Pos;
yMax : aliased FT_Pos;
end record;
type Item_array is array (C.Size_t range <>) of aliased FT_BBox.Item;
type Pointer is access all FT_BBox.Item;
type Pointer_array is array (C.Size_t range <>) of aliased FT_BBox.Pointer;
type pointer_Pointer is access all FT_BBox.Pointer;
end freetype_c.FT_BBox;

View File

@@ -0,0 +1,24 @@
package freetype_c.FT_Bitmap
is
type Item is
record
Rows : aliased c.int;
Width : aliased c.int;
Pitch : aliased c.int;
Buffer : access c.unsigned_char;
num_Grays : aliased c.short;
pixel_Mode : aliased c.char;
palette_Mode : aliased c.char;
Palette : aliased System.Address;
end record;
type Item_array is array (C.Size_t range <>) of aliased FT_Bitmap.Item;
type Pointer is access all FT_Bitmap.Item;
type Pointer_array is array (C.Size_t range <>) of aliased FT_Bitmap.Pointer;
type pointer_Pointer is access all freetype_c.FT_Bitmap.Pointer;
end freetype_c.FT_Bitmap;

View File

@@ -0,0 +1,15 @@
with
freetype_c.FT_CharMapRec;
package freetype_c.FT_CharMap
is
subtype Item is FT_CharMapRec.Pointer;
type Item_array is array (interfaces.C.Size_t range <>) of aliased FT_CharMap.Item;
type Pointer is access all FT_CharMap.Item;
type Pointer_array is array (C.Size_t range <>) of aliased FT_CharMap.Pointer;
type pointer_Pointer is access all freetype_c.FT_CharMap.Pointer;
end freetype_c.FT_CharMap;

View File

@@ -0,0 +1,20 @@
package freetype_c.FT_CharMapRec
is
type Item is
record
Face : access FT_FaceRec;
Encoding : aliased FT_Encoding;
Platform_Id : aliased FT_UShort;
Encoding_Id : aliased FT_UShort;
end record;
type Item_array is array (C.Size_t range <>) of aliased FT_CharMapRec.Item;
type Pointer is access all FT_CharMapRec.Item;
type Pointer_array is array (C.Size_t range <>) of aliased FT_CharMapRec.Pointer;
type pointer_Pointer is access all FT_CharMapRec.Pointer;
end freetype_c.FT_CharMapRec;

View File

@@ -0,0 +1,16 @@
with
freetype_c.Pointers;
package freetype_c.FT_Face
is
subtype Item is Pointers.FT_FaceRec_Pointer;
type Item_array is array (C.Size_t range <>) of aliased FT_Face.Item;
type Pointer is access all FT_Face.Item;
type Pointer_array is array (C.Size_t range <>) of aliased FT_Face.Pointer;
type pointer_Pointer is access all FT_Face.Pointer;
end freetype_c.FT_Face;

View File

@@ -0,0 +1,16 @@
with
freetype_c.Pointers;
package freetype_c.FT_GlyphSlot
is
subtype Item is freetype_c.Pointers.FT_GlyphSlotRec_Pointer;
type Item_array is array (C.Size_t range <>) of aliased freetype_c.FT_GlyphSlot.Item;
type Pointer is access all freetype_c.FT_GlyphSlot.Item;
type Pointer_array is array (C.Size_t range <>) of aliased freetype_c.FT_GlyphSlot.Pointer;
type pointer_Pointer is access all freetype_c.FT_GlyphSlot.Pointer;
end freetype_c.FT_GlyphSlot;

View File

@@ -0,0 +1,16 @@
with
freetype_c.Pointers;
package freetype_c.FT_Library
is
subtype Item is Pointers.FT_LibraryRec_Pointer;
type Item_array is array (C.Size_t range <>) of aliased FT_Library.Item;
type Pointer is access all freetype_c.FT_Library.Item;
type Pointer_array is array (C.Size_t range <>) of aliased freetype_c.FT_Library.Pointer;
type pointer_Pointer is access all freetype_c.FT_Library.Pointer;
end freetype_c.FT_Library;

View File

@@ -0,0 +1,16 @@
with
freetype_c.Pointers;
package freetype_c.FT_Size
is
subtype Item is Pointers.FT_SizeRec_Pointer;
type Item_array is array (C.Size_t range <>) of aliased FT_Size.Item;
type Pointer is access all freetype_c.FT_Size.Item;
type Pointer_array is array (C.Size_t range <>) of aliased FT_Size.Pointer;
type pointer_Pointer is access all FT_Size.Pointer;
end freetype_c.FT_Size;

Some files were not shown because too many files have changed in this diff Show More