opengl: Bug fixes for opengl mesa software rendering.

This commit is contained in:
Rod Kay
2024-04-24 18:15:27 +10:00
parent ef35111c0a
commit e202ce548d
9 changed files with 75 additions and 35 deletions

View File

@@ -3,7 +3,9 @@ with
openGL.Visual,
openGL.Light,
openGL.Palette,
openGL.Demo;
openGL.Demo,
ada.Text_IO;
procedure launch_render_Models
@@ -14,7 +16,8 @@ is
use openGL,
openGL.Math,
openGL.linear_Algebra_3D,
openGL.Palette;
openGL.Palette,
ada.Text_IO;
begin
Demo.print_Usage ("Use space ' ' to cycle through models.");

View File

@@ -1,12 +1,12 @@
#version 140
#version 410
// Texturing snippet.
//
uniform int texture_Count;
uniform sampler2D Textures [32];
uniform float Fade [32];
uniform sampler2D Textures [16];
uniform float Fade [16];
vec4
apply_Texturing (vec2 Coords)
@@ -32,6 +32,7 @@ apply_Texturing (vec2 Coords)
struct light
{
vec4 Site;
float Strength;
vec3 Color;
float Attenuation;
float ambient_Coefficient;

View File

@@ -1,6 +1,6 @@
uniform int texture_Count;
uniform sampler2D Textures [32];
uniform float Fade [32];
uniform sampler2D Textures [16];
uniform float Fade [16];
vec4
apply_Texturing (vec2 Coords)

View File

@@ -1 +1 @@
#version 140
#version 410

View File

@@ -235,11 +235,13 @@ is
End_1 => [0.0, 0.0, 0.0],
End_2 => [5.0, 5.0, 0.0]);
the_collada_Model : constant Model.any.view
:= Model.any.new_Model (--Scale => (1.0, 1.0, 1.0),
Model => to_Asset ("assets/opengl/model/human.dae"),
Texture => the_Texture,
Texture_is_lucid => False);
-- The collada model requires 'Desktop' openGL build mode.
--
-- the_collada_Model : constant Model.any.view
-- := Model.any.new_Model (--Scale => (1.0, 1.0, 1.0),
-- Model => to_Asset ("assets/opengl/model/human.dae"),
-- Texture => the_Texture,
-- Texture_is_lucid => False);
the_wavefront_Model : constant Model.any.view
:= Model.any.new_Model (--Scale => (1.0, 1.0, 1.0),
@@ -267,6 +269,7 @@ is
the_segment_line_Model : constant Model.segment_line.view
:= Model.segment_line.new_segment_line_Model (Color => Green);
-- Terrain
--
heights_File : constant asset_Name := to_Asset ("assets/opengl/terrain/kidwelly-terrain.png");
@@ -318,7 +321,7 @@ is
the_rounded_hexagon_column_Model.all'Access,
the_line_Model.all'Access,
the_collada_Model.all'Access,
-- the_collada_Model.all'Access,
the_wavefront_Model.all'Access,
the_segment_line_Model.all'Access];

View File

@@ -29,23 +29,23 @@ is
GL_TEXTURE12,
GL_TEXTURE13,
GL_TEXTURE14,
GL_TEXTURE15,
GL_TEXTURE16,
GL_TEXTURE17,
GL_TEXTURE18,
GL_TEXTURE19,
GL_TEXTURE20,
GL_TEXTURE21,
GL_TEXTURE22,
GL_TEXTURE23,
GL_TEXTURE24,
GL_TEXTURE25,
GL_TEXTURE26,
GL_TEXTURE27,
GL_TEXTURE28,
GL_TEXTURE29,
GL_TEXTURE30,
GL_TEXTURE31);
GL_TEXTURE15);
-- GL_TEXTURE16,
-- GL_TEXTURE17,
-- GL_TEXTURE18,
-- GL_TEXTURE19,
-- GL_TEXTURE20,
-- GL_TEXTURE21,
-- GL_TEXTURE22,
-- GL_TEXTURE23,
-- GL_TEXTURE24,
-- GL_TEXTURE25,
-- GL_TEXTURE26,
-- GL_TEXTURE27,
-- GL_TEXTURE28,
-- GL_TEXTURE29,
-- GL_TEXTURE30,
-- GL_TEXTURE31);

View File

@@ -9,7 +9,10 @@ package openGL.texture_Set
-- Facilitates texturing of geometries.
--
is
max_Textures : constant := 32;
--- Note that Mesa currently only supports 16 texture units.
--
-- max_Textures : constant := 32;
max_Textures : constant := 16;
type texture_Id is range 1 .. max_Textures;

View File

@@ -121,8 +121,12 @@ is
if Status = 0
then
declare
use ada.Text_IO;
compile_Log : constant String := Self.shader_info_Log;
begin
new_Line;
put_Line ("Shader compile log:");
put_Line (compile_Log);
Self.destroy;
raise Error with "'" & to_Ada (the_Source) & "' compilation failed ~ " & compile_Log;
end;
@@ -147,8 +151,34 @@ is
procedure define (Self : in out Item; Kind : in Shader.Kind;
shader_Snippets : in asset_Names)
is
use ada.Text_IO,
interfaces.C;
the_Source : aliased constant C.char_array := to_C_char_array (shader_Snippets);
begin
-- if Debug
-- then
new_Line;
put_Line ("Shader snippets:");
for Each of shader_Snippets
loop
put_Line (to_String (Each));
end loop;
new_Line;
new_Line;
new_Line;
new_Line;
put_Line ("Shader source code:");
put_Line (to_Ada (the_Source));
put_Line ("End source code!");
new_Line;
new_Line;
new_Line;
new_Line;
-- end if;
create_Shader (Self, Kind, the_Source);
end define;

View File

@@ -102,7 +102,7 @@ is
the_graphics_Model := openGL .Model.view (the_graphics_Models.Element (the_Pair.graphics_Model_Id));
the_physics_Model := physics.Model.view ( the_physics_Models.Element (the_Pair. physics_Model_Id));
the_Sprite := gel.Sprite.forge.new_Sprite ("1Sprite" & the_Pair.sprite_Id'Image,
the_Sprite := gel.Sprite.forge.new_Sprite ("Sprite" & the_Pair.sprite_Id'Image,
sprite.World_view (the_World),
get_Translation (the_Pair.Transform),
the_graphics_Model,