-
Notifications
You must be signed in to change notification settings - Fork 0
/
Display.cs
executable file
·194 lines (171 loc) · 3.13 KB
/
Display.cs
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
using System;
using AllegroSharp.Bridge;
namespace AllegroSharp
{
public sealed class Display : IDisposable
{
public static Display Create(int width, int height)
{
var display = Allegro5.al_create_display(width, height);
if (display == IntPtr.Zero)
{
return null;
}
return new Display(display);
}
public static int Flags
{
get
{
return Allegro5.al_get_display_flags();
}
}
public static void SetNewOption(int option, int value, int importance)
{
Allegro5.al_set_new_display_option(option, value, importance);
}
public static int GetOption(int option)
{
return Allegro5.al_get_display_option(option);
}
public static void Clear(Color color)
{
Allegro5.al_clear_to_color(color);
}
public static Display Current
{
get
{
var display = Allegro5.al_get_current_display();
if (display != IntPtr.Zero)
{
return new Display(display);
}
return null;
}
set
{
SetCurrent(value);
}
}
public static bool SetCurrent(Display display)
{
if (display == null)
{
return Allegro5.al_set_current_display(IntPtr.Zero);
}
else
{
return Allegro5.al_set_current_display(display.Ptr);
}
}
public static Bitmap Icon
{
set
{
if (value == null)
{
Allegro5.al_set_display_icon(IntPtr.Zero);
}
else
{
Allegro5.al_set_display_icon(value.Ptr);
}
}
}
public static void Flip()
{
Allegro5.al_flip_display();
}
public bool AcknowledgeResize()
{
return Allegro5.al_acknowledge_resize(Ptr);
}
public static Bitmap FrontBuffer
{
get
{
var bitmap = Allegro5.al_get_frontbuffer();
if (bitmap != IntPtr.Zero)
{
return new Bitmap(bitmap);
}
return null;
}
}
public static Bitmap BackBuffer
{
get
{
var bitmap = Allegro5.al_get_backbuffer();
if (bitmap != IntPtr.Zero)
{
return new Bitmap(bitmap);
}
return null;
}
}
public int Height
{
get
{
return Allegro5.al_get_display_height(Ptr);
}
}
public int Width
{
get
{
return Allegro5.al_get_display_width(Ptr);
}
}
public void GetWindowPosition(out int x, out int y)
{
Allegro5.al_get_window_position(Ptr, out x, out y);
}
public static bool InhibitScreensaver(bool inhibit)
{
return Allegro5.al_inhibit_screensaver(inhibit);
}
public static bool Resize(int width, int height)
{
return Allegro5.al_resize_display(width, height);
}
public static string Title
{
set
{
Allegro5.al_set_window_title(value);
}
}
public static bool WaitForVSync()
{
return Allegro5.al_wait_for_vsync();
}
public EventSource EventSource
{
get
{
var eventSource = Allegro5.al_get_display_event_source(Ptr);
if (eventSource != IntPtr.Zero)
{
return new EventSource(eventSource);
}
return null;
}
}
internal Display(IntPtr ptr)
{
Ptr = ptr;
}
public void Dispose()
{
if (Ptr != IntPtr.Zero)
{
Allegro5.al_destroy_display(Ptr);
Ptr = IntPtr.Zero;
}
}
internal IntPtr Ptr = IntPtr.Zero;
}
}