forked from servo/rust-egl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathegl.rs
276 lines (267 loc) · 10.5 KB
/
egl.rs
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
/* automatically generated by rust-bindgen */
use std::libc::*;
use std::str::raw;
use std::ptr::to_unsafe_ptr;
pub type khronos_int32_t = int32_t;
pub type khronos_uint32_t = uint32_t;
pub type khronos_int64_t = int64_t;
pub type khronos_uint64_t = uint64_t;
pub type khronos_int8_t = c_schar;
pub type khronos_uint8_t = c_uchar;
pub type khronos_int16_t = c_short;
pub type khronos_uint16_t = c_ushort;
pub type khronos_intptr_t = c_long;
pub type khronos_uintptr_t = c_ulong;
pub type khronos_ssize_t = c_long;
pub type khronos_usize_t = c_ulong;
pub type khronos_float_t = c_float;
pub type khronos_utime_nanoseconds_t = khronos_uint64_t;
pub type khronos_stime_nanoseconds_t = khronos_int64_t;
pub type ANativeWindow = c_void;
pub type egl_native_pixmap_t = c_void;
pub type EGLNativeWindowType = *ANativeWindow;
pub type EGLNativePixmapType = *egl_native_pixmap_t;
pub type EGLNativeDisplayType = *c_void;
pub type NativeDisplayType = EGLNativeDisplayType;
pub type NativePixmapType = EGLNativePixmapType;
pub type NativeWindowType = EGLNativeWindowType;
pub type EGLint = khronos_int32_t;
pub type EGLBoolean = c_uint;
pub type EGLenum = c_uint;
pub type EGLConfig = *c_void;
pub type EGLContext = *c_void;
pub type EGLDisplay = *c_void;
pub type EGLSurface = *c_void;
pub type EGLClientBuffer = *c_void;
pub type __eglMustCastToProperFunctionPointerType = *u8;
pub type status_t = int32_t;
pub static EGL_CONTEXT_CLIENT_VERSION: c_uint = 0x3098;
pub static EGL_NO_CONTEXT: c_uint = 0;
pub static EGL_DEFAULT_DISPLAY: c_uint = 0;
pub static EGL_NONE: c_uint = 0x3038; // Attrib list terminator
pub static EGL_NO_DISPLAY: c_uint = 0;
pub static EGL_TRUE: c_uint = 1;
pub static EGL_FALSE: c_uint = 0;
pub static EGL_NO_SURFACE: c_uint = 0;
pub static EGL_SURFACE_TYPE: c_uint = 0x3033;
pub static EGL_WINDOW_BIT: c_uint = 0x0004; // EGL_SURFACE_TYPE mask bits
pub static EGL_RENDERABLE_TYPE: c_uint = 0x3040;
pub static EGL_OPENGL_ES2_BIT: c_uint = 0x0004; // EGL_RENDERABLE_TYPE mask bits
pub static EGL_HEIGHT: c_uint = 0x3056;
pub static EGL_WIDTH: c_uint = 0x3057;
pub static EGL_BUFFER_SIZE: c_uint = 0x3020;
pub static EGL_DEPTH_SIZE: c_uint = 0x3025;
pub static EGL_ALPHA_SIZE: c_uint = 0x3021;
pub static EGL_BLUE_SIZE: c_uint = 0x3022;
pub static EGL_GREEN_SIZE: c_uint = 0x3023;
pub static EGL_RED_SIZE: c_uint = 0x3024;
pub static EGL_DRAW: EGLint = 0x3059;
pub static EGL_CONTEXT_MAJOR_VERSION_KHR: c_uint = 0x3098;
pub static EGL_CONTEXT_MINOR_VERSION_KHR: c_uint = 0x30FB;
pub static EGL_CONTEXT_FLAGS_KHR: c_uint = 0x30FC;
pub static EGL_OPENGL_ES3_BIT_KHR: c_uint = 0x0040;
pub static EGL_EXTENSIONS: c_uint = 0x3055;
#[cfg(target_os = "android")]
#[link(name = "EGL")]
extern {}
pub fn GetError() -> EGLint {
unsafe {
return eglGetError();
}
}
pub fn GetDisplay(display_id: EGLNativeDisplayType) -> EGLDisplay {
unsafe {
return eglGetDisplay(display_id);
}
}
pub fn Initialize(dpy: EGLDisplay, major: &mut EGLint, minor: &mut EGLint) -> EGLBoolean {
unsafe {
return eglInitialize(dpy, to_unsafe_ptr(major), to_unsafe_ptr(minor));
}
}
pub fn Terminate(dpy: EGLDisplay) -> EGLBoolean {
unsafe {
return eglTerminate(dpy);
}
}
pub fn QueryString(dpy: EGLDisplay, name: EGLint) -> ~str {
unsafe {
return raw::from_c_str(eglQueryString(dpy, name));
}
}
pub fn GetConfigs(dpy: EGLDisplay, configs: &mut EGLConfig, config_size: EGLint, num_config: &mut EGLint) -> EGLBoolean {
unsafe {
return eglGetConfigs(dpy, to_unsafe_ptr(configs), config_size, to_unsafe_ptr(num_config));
}
}
pub fn ChooseConfig(dpy: EGLDisplay, attrib_list: *EGLint, configs: &mut EGLConfig, config_size: EGLint, num_config: &mut EGLint) -> EGLBoolean {
unsafe {
return eglChooseConfig(dpy, attrib_list, to_unsafe_ptr(configs), config_size, to_unsafe_ptr(num_config));
}
}
pub fn GetConfigAttrib(dpy: EGLDisplay, config: EGLConfig, attribute: EGLint, value: &mut EGLint) -> EGLBoolean {
unsafe {
return eglGetConfigAttrib(dpy, config, attribute, to_unsafe_ptr(value));
}
}
pub fn CreateWindowSurface(dpy: EGLDisplay, config: EGLConfig, win: EGLNativeWindowType, attrib_list: *EGLint) -> EGLSurface {
unsafe {
return eglCreateWindowSurface(dpy, config, win, attrib_list);
}
}
pub fn CreatePbufferSurface(dpy: EGLDisplay, config: EGLConfig, attrib_list: &mut EGLint) -> EGLSurface {
unsafe {
return eglCreatePbufferSurface(dpy, config, to_unsafe_ptr(attrib_list));
}
}
pub fn CreatePixmapSurface(dpy: EGLDisplay, config: EGLConfig, pixmap: EGLNativePixmapType, attrib_list: &mut EGLint) -> EGLSurface {
unsafe {
return eglCreatePixmapSurface(dpy, config, pixmap, to_unsafe_ptr(attrib_list));
}
}
pub fn DestroySurface(dpy: EGLDisplay, surface: EGLSurface) -> EGLBoolean {
unsafe {
return eglDestroySurface(dpy, surface);
}
}
pub fn QuerySurface(dpy: EGLDisplay, surface: EGLSurface, attribute: EGLint, value: &mut EGLint) -> EGLBoolean {
unsafe {
return eglQuerySurface(dpy, surface, attribute, to_unsafe_ptr(value));
}
}
pub fn BindAPI(api: EGLenum) -> EGLBoolean {
unsafe {
return eglBindAPI(api);
}
}
pub fn QueryAPI() -> EGLenum {
unsafe {
return eglQueryAPI();
}
}
pub fn WaitClient() -> EGLBoolean {
unsafe {
return eglWaitClient();
}
}
pub fn ReleaseThread() -> EGLBoolean {
unsafe {
return eglReleaseThread();
}
}
pub fn CreatePbufferFromClientBuffer(dpy: EGLDisplay, buftype: EGLenum, buffer: EGLClientBuffer, config: EGLConfig, attrib_list: &mut EGLint) -> EGLSurface {
unsafe {
return eglCreatePbufferFromClientBuffer(dpy, buftype, buffer, config, to_unsafe_ptr(attrib_list));
}
}
pub fn SurfaceAttrib(dpy: EGLDisplay, surface: EGLSurface, attribute: EGLint, value: EGLint) -> EGLBoolean {
unsafe {
return eglSurfaceAttrib(dpy, surface, attribute, value);
}
}
pub fn BindTexImage(dpy: EGLDisplay, surface: EGLSurface, buffer: EGLint) -> EGLBoolean {
unsafe {
return eglBindTexImage(dpy, surface, buffer);
}
}
pub fn ReleaseTexImage(dpy: EGLDisplay, surface: EGLSurface, buffer: EGLint) -> EGLBoolean {
unsafe {
return eglReleaseTexImage(dpy, surface, buffer);
}
}
pub fn SwapInterval(dpy: EGLDisplay, interval: EGLint) -> EGLBoolean {
unsafe {
return eglSwapInterval(dpy, interval);
}
}
pub fn CreateContext(dpy: EGLDisplay, config: EGLConfig, share_context: EGLContext, attrib_list: *EGLint) -> EGLContext {
unsafe {
return eglCreateContext(dpy, config, share_context, attrib_list);
}
}
pub fn DestroyContext(dpy: EGLDisplay, ctx: EGLContext) -> EGLBoolean {
unsafe {
return eglDestroyContext(dpy, ctx);
}
}
pub fn MakeCurrent(dpy: EGLDisplay, draw: EGLSurface, read: EGLSurface, ctx: EGLContext) -> EGLBoolean {
unsafe {
return eglMakeCurrent(dpy, draw, read, ctx);
}
}
pub fn GetCurrentContext() -> EGLContext {
unsafe {
return eglGetCurrentContext();
}
}
pub fn GetCurrentSurface(readdraw: EGLint) -> EGLSurface {
unsafe {
return eglGetCurrentSurface(readdraw);
}
}
pub fn GetCurrentDisplay() -> EGLDisplay {
unsafe {
return eglGetCurrentDisplay();
}
}
pub fn QueryContext(dpy: EGLDisplay, ctx: EGLContext, attribute: EGLint, value: &mut EGLint) -> EGLBoolean {
unsafe {
return eglQueryContext(dpy, ctx, attribute, to_unsafe_ptr(value));
}
}
pub fn WaitGL() -> EGLBoolean {
unsafe {
return eglWaitGL();
}
}
pub fn WaitNative(engine: EGLint) -> EGLBoolean {
unsafe {
return eglWaitNative(engine);
}
}
pub fn SwapBuffers(dpy: EGLDisplay, surface: EGLSurface) -> EGLBoolean {
unsafe {
return eglSwapBuffers(dpy, surface);
}
}
pub fn CopyBuffers(dpy: EGLDisplay, surface: EGLSurface, target: EGLNativePixmapType) -> EGLBoolean {
unsafe {
return eglCopyBuffers(dpy, surface, target);
}
}
#[nolink]
extern {
fn eglGetError() -> EGLint;
fn eglGetDisplay(display_id: EGLNativeDisplayType) -> EGLDisplay;
fn eglInitialize(dpy: EGLDisplay, major: *EGLint, minor: *EGLint) -> EGLBoolean;
fn eglTerminate(dpy: EGLDisplay) -> EGLBoolean;
fn eglQueryString(dpy: EGLDisplay, name: EGLint) -> *c_schar;
fn eglGetConfigs(dpy: EGLDisplay, configs: *EGLConfig, config_size: EGLint, num_config: *EGLint) -> EGLBoolean;
fn eglChooseConfig(dpy: EGLDisplay, attrib_list: *EGLint, configs: *EGLConfig, config_size: EGLint, num_config: *EGLint) -> EGLBoolean;
fn eglGetConfigAttrib(dpy: EGLDisplay, config: EGLConfig, attribute: EGLint, value: *EGLint) -> EGLBoolean;
fn eglCreateWindowSurface(dpy: EGLDisplay, config: EGLConfig, win: EGLNativeWindowType, attrib_list: *EGLint) -> EGLSurface;
fn eglCreatePbufferSurface(dpy: EGLDisplay, config: EGLConfig, attrib_list: *EGLint) -> EGLSurface;
fn eglCreatePixmapSurface(dpy: EGLDisplay, config: EGLConfig, pixmap: EGLNativePixmapType, attrib_list: *EGLint) -> EGLSurface;
fn eglDestroySurface(dpy: EGLDisplay, surface: EGLSurface) -> EGLBoolean;
fn eglQuerySurface(dpy: EGLDisplay, surface: EGLSurface, attribute: EGLint, value: *EGLint) -> EGLBoolean;
fn eglBindAPI(api: EGLenum) -> EGLBoolean;
fn eglQueryAPI() -> EGLenum;
fn eglWaitClient() -> EGLBoolean;
fn eglReleaseThread() -> EGLBoolean;
fn eglCreatePbufferFromClientBuffer(dpy: EGLDisplay, buftype: EGLenum, buffer: EGLClientBuffer, config: EGLConfig, attrib_list: *EGLint) -> EGLSurface;
fn eglSurfaceAttrib(dpy: EGLDisplay, surface: EGLSurface, attribute: EGLint, value: EGLint) -> EGLBoolean;
fn eglBindTexImage(dpy: EGLDisplay, surface: EGLSurface, buffer: EGLint) -> EGLBoolean;
fn eglReleaseTexImage(dpy: EGLDisplay, surface: EGLSurface, buffer: EGLint) -> EGLBoolean;
fn eglSwapInterval(dpy: EGLDisplay, interval: EGLint) -> EGLBoolean;
fn eglCreateContext(dpy: EGLDisplay, config: EGLConfig, share_context: EGLContext, attrib_list: *EGLint) -> EGLContext;
fn eglDestroyContext(dpy: EGLDisplay, ctx: EGLContext) -> EGLBoolean;
fn eglMakeCurrent(dpy: EGLDisplay, draw: EGLSurface, read: EGLSurface, ctx: EGLContext) -> EGLBoolean;
fn eglGetCurrentContext() -> EGLContext;
fn eglGetCurrentSurface(readdraw: EGLint) -> EGLSurface;
fn eglGetCurrentDisplay() -> EGLDisplay;
fn eglQueryContext(dpy: EGLDisplay, ctx: EGLContext, attribute: EGLint, value: *EGLint) -> EGLBoolean;
fn eglWaitGL() -> EGLBoolean;
fn eglWaitNative(engine: EGLint) -> EGLBoolean;
fn eglSwapBuffers(dpy: EGLDisplay, surface: EGLSurface) -> EGLBoolean;
fn eglCopyBuffers(dpy: EGLDisplay, surface: EGLSurface, target: EGLNativePixmapType) -> EGLBoolean;
}