1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115 | with
openGL.Tasks,
GL.lean,
System,
ada.unchecked_Conversion;
package body openGL.Attribute
is
use GL.lean;
---------
-- Forge
--
procedure define (Self : in out Item)
is
begin
null;
end define;
procedure destroy (Self : in out Item)
is
begin
null;
end destroy;
package body Forge
is
function to_Attribute (Name : in String;
gl_Location : in gl.GLuint;
Size : in gl.GLint;
data_Kind : in Attribute.data_Kind;
Stride : in Natural;
Offset : in storage_Offset;
Normalized : in Boolean) return Item
is
begin
return (name => new String'(Name),
location => gl_Location,
size => Size,
data_kind => data_Kind,
vertex_stride => gl.GLint (Stride),
offset => Offset,
normalized => Boolean'Pos (Normalized));
end to_Attribute;
function new_Attribute (Name : in String;
gl_Location : in gl.GLuint;
Size : in gl.GLint;
data_Kind : in Attribute.data_Kind;
Stride : in Natural;
Offset : in Storage_Offset;
Normalized : in Boolean) return View
is
begin
return new Item' (to_Attribute (Name,
gl_Location,
Size,
data_Kind,
Stride,
Offset,
Normalized));
end new_Attribute;
end Forge;
--------------
-- Attributes
--
function Name (Self : in Item'Class) return String
is
begin
return Self.Name.all;
end Name;
function gl_Location (Self : in Item'Class) return gl.GLuint
is
begin
return Self.Location;
end gl_Location;
--------------
-- Operations
--
procedure enable (Self : in Item)
is
use GL,
system.Storage_Elements;
type GLvoid_access is access all GLvoid;
function to_GL is new ada.unchecked_Conversion (attribute.data_Kind, gl.GLenum); -- TODO: Address different sizes warning.
function to_GL is new ada.unchecked_Conversion (storage_Offset, GLvoid_access);
begin
Tasks.check;
glEnableVertexAttribArray (Index => Self.gl_Location);
glVertexAttribPointer (Index => Self.gl_Location,
Size => Self.Size,
the_Type => to_GL (Self.data_Kind),
Normalized => Self.Normalized,
Stride => Self.vertex_Stride,
Ptr => to_GL (Self.Offset));
end enable;
end openGL.Attribute;
|