-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplayer-graphics2d.adb
169 lines (144 loc) · 4.97 KB
/
player-graphics2d.adb
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
with Player.Aux;
package body Player.Graphics2d is
package C renames Standard.Interfaces.C;
------------
-- Create --
------------
procedure Create
(This : in out Object;
Conn : in Client.Connection_Type;
Index : in Natural := 0)
is
function C_Create (Conn : in Types.Handle; Index : in C.int)
return Types.Handle;
pragma Import (C, C_Create, "playerc_graphics2d_create");
begin
Interfaces.Create (Interfaces.Object (This), Conn, Index);
Set_Handle (This, C_Create (Client.Get_Handle (Conn), C.int (Index)));
end Create;
-------------
-- Destroy --
-------------
procedure Destroy (This : in out Object) is
begin
Destroy_Handle (-This);
Clear_Handle (This);
end Destroy;
---------------
-- Subscribe --
---------------
procedure Subscribe (This : in out Object; Mode : in Access_Modes) is
function C_Subscribe (This : in Types.Handle; Mode : in Access_Modes)
return C.int;
pragma Import (C, C_Subscribe, "playerc_graphics2d_subscribe");
begin
Aux.Check (C_Subscribe (-This, Mode));
Interfaces.Subscribe (Interfaces.Object (This), Mode);
end Subscribe;
-----------------
-- Unsubscribe --
-----------------
procedure Unsubscribe (This : in out Object) is
function C_Unsubscribe (This : in Types.Handle) return C.Int;
pragma Import (C, C_Unsubscribe, "playerc_graphics2d_unsubscribe");
begin
Aux.Check (C_Unsubscribe (-This));
Interfaces.Unsubscribe (Interfaces.Object (This));
end Unsubscribe;
-----------
-- Clear --
-----------
procedure Clear (This : in out Object) is
function C_Clear (This : in Types.Handle) return C.Int;
pragma Import (C, C_Clear, "playerc_graphics2d_clear");
begin
Aux.Check (C_Clear (-This));
end Clear;
---------------
-- Set_Color --
---------------
procedure Set_Color (This : in out Object;
Color : in Types.Player_Color_Type)
is
function Internal (This : Types.Handle;
A, R, G, B : C.Int) return C.Int;
pragma Import (C, Internal, "player_ada_graphics2d_set_color");
begin
Aux.Check (Internal (-This,
C.Int (Color.Alpha),
C.Int (Color.Red),
C.Int (Color.Green),
C.Int (Color.Blue)));
end Set_Color;
---------------
-- Get_Color --
---------------
function Get_Color (This : Object) return Types.Player_Color_Type is
procedure Internal (This : Types.Handle;
A, R, G, B : access C.Int);
pragma Import (C, Internal, "player_ada_graphics2d_get_color");
A, R, G, B : aliased C.int;
use Player.Types;
begin
Internal (-This, A'Access, R'Access, G'Access, B'Access);
return (Alpha => Uint8 (A),
Red => Uint8 (R),
Green => Uint8 (G),
Blue => Uint8 (B));
end Get_Color;
-------------------
-- Draw_Polyline --
-------------------
procedure Draw_Polyline (This : in out Object;
Points : in Types.Point_2d_Array)
is
function C_Draw (This : in Types.Handle;
Points : access Point_2d;
Count : in C.Int) return C.Int;
pragma Import (C, C_Draw, "playerc_graphics2d_draw_polyline");
begin
Aux.Check
(C_Draw (-This, Points (Points'First)'Unrestricted_Access, Points'Length));
end Draw_Polyline;
-------------------
-- Draw_Polyline --
-------------------
procedure Draw_Polyline (This : in out Object;
Points : in Types.Point_2d_Vector)
is
Pts : Types.Point_2d_Array (Points.First_Index .. Points.Last_Index);
begin
for I in Pts'Range loop
Pts (I) := Points.Element (I);
end loop;
Draw_Polyline (This, Pts);
end Draw_Polyline;
------------------
-- Fill_Polygon --
------------------
procedure Fill_Polygon (This : in out Object;
Points : in Types.Point_2d_Array)
is
function C_Draw (This : Types.Handle;
Points : access Point_2d;
Count : C.Int;
Fill : C.Int;
Color : Types.Player_Color_Type) return C.Int;
pragma Import (C, C_Draw, "playerc_graphics2d_draw_polygon");
begin
Aux.Check (C_Draw (-This, Points (Points'First)'Unrestricted_Access, Points'Length, 1, This.Get_Color));
end Fill_Polygon;
------------------
-- Fill_Polygon --
------------------
procedure Fill_Polygon (This : in out Object;
Points : in Types.Point_2d_Vector)
is
Pts : Types.Point_2d_Array (Points.First_Index .. Points.Last_Index);
begin
for I in Pts'Range loop
Pts (I) := Points.Element (I);
end loop;
Fill_Polygon (This, Pts);
end Fill_Polygon;
end Player.Graphics2d;