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
//! Unsafe FFI API.
//!
//! Use these only if higher-level EGLI or EGL abstrations are not enough.

#[allow(unused_imports)]
use libc::{c_char, c_void};

use egl::{EGLBoolean, EGLClientBuffer, EGLConfig, EGLContext, EGLDisplay, EGLenum, EGLint,
          EGLNativeDisplayType, EGLNativePixmapType, EGLNativeWindowType, EGLSurface};

#[cfg(feature = "egl_1_5")]
use egl::{EGLSync, EGLAttrib, EGLImage, EGLTime};

extern "C" {
    pub fn eglChooseConfig(dpy: EGLDisplay,
                           attrib_list: *const EGLint,
                           configs: *mut EGLConfig,
                           config_size: EGLint,
                           num_config: *mut EGLint)
                           -> EGLBoolean;

    pub fn eglCopyBuffers(dpy: EGLDisplay,
                          surface: EGLSurface,
                          target: EGLNativePixmapType)
                          -> EGLBoolean;

    pub fn eglCreateContext(dpy: EGLDisplay,
                            config: EGLConfig,
                            share_context: EGLContext,
                            attrib_list: *const EGLint)
                            -> EGLContext;

    pub fn eglCreatePbufferSurface(dpy: EGLDisplay,
                                   config: EGLConfig,
                                   attrib_list: *const EGLint)
                                   -> EGLSurface;

    pub fn eglCreatePixmapSurface(dpy: EGLDisplay,
                                  config: EGLConfig,
                                  pixmap: EGLNativePixmapType,
                                  attrib_list: *const EGLint)
                                  -> EGLSurface;

    pub fn eglCreateWindowSurface(dpy: EGLDisplay,
                                  config: EGLConfig,
                                  win: EGLNativeWindowType,
                                  attrib_list: *const EGLint)
                                  -> EGLSurface;

    pub fn eglDestroyContext(dpy: EGLDisplay, ctx: EGLContext) -> EGLBoolean;

    pub fn eglDestroySurface(dpy: EGLDisplay, surface: EGLSurface) -> EGLBoolean;

    pub fn eglGetConfigAttrib(dpy: EGLDisplay,
                              config: EGLConfig,
                              attribute: EGLint,
                              value: *mut EGLint)
                              -> EGLBoolean;

    pub fn eglGetConfigs(dpy: EGLDisplay,
                         configs: EGLConfig,
                         config_size: EGLint,
                         num_config: *mut EGLint)
                         -> EGLBoolean;

    pub fn eglGetCurrentDisplay() -> EGLDisplay;

    pub fn eglGetCurrentSurface(readdraw: EGLint) -> EGLSurface;

    pub fn eglGetDisplay(display_id: EGLNativeDisplayType) -> EGLDisplay;

    pub fn eglGetError() -> EGLint;

    pub fn eglGetProcAddress(procname: *const c_char) -> extern "C" fn();

    pub fn eglInitialize(dpy: EGLDisplay, major: *mut EGLint, minor: *mut EGLint) -> EGLBoolean;

    pub fn eglMakeCurrent(dpy: EGLDisplay,
                          draw: EGLSurface,
                          read: EGLSurface,
                          ctx: EGLContext)
                          -> EGLBoolean;

    pub fn eglQueryContext(dpy: EGLDisplay,
                           ctx: EGLContext,
                           attribute: EGLint,
                           value: *mut EGLint)
                           -> EGLBoolean;

    pub fn eglQueryString(dpy: EGLDisplay, name: EGLint) -> *const c_char;

    pub fn eglQuerySurface(dpy: EGLDisplay,
                           surface: EGLSurface,
                           attribute: EGLint,
                           value: *mut EGLint)
                           -> EGLBoolean;

    pub fn eglSwapBuffers(dpy: EGLDisplay, surface: EGLSurface) -> EGLBoolean;

    pub fn eglTerminate(dpy: EGLDisplay) -> EGLBoolean;

    pub fn eglWaitGL() -> EGLBoolean;

    pub fn eglWaitNative(engine: EGLint) -> EGLBoolean;

    // EGL 1.1

    pub fn eglBindTexImage(dpy: EGLDisplay, surface: EGLSurface, buffer: EGLint) -> EGLBoolean;

    pub fn eglReleaseTexImage(dpy: EGLDisplay, surface: EGLSurface, buffer: EGLint) -> EGLBoolean;

    pub fn eglSurfaceAttrib(dpy: EGLDisplay,
                            surface: EGLSurface,
                            attribute: EGLint,
                            value: EGLint)
                            -> EGLBoolean;

    pub fn eglSwapInterval(dpy: EGLDisplay, interval: EGLint) -> EGLBoolean;

    // EGL 1.2

    pub fn eglBindAPI(api: EGLenum) -> EGLBoolean;

    pub fn eglQueryAPI() -> EGLenum;

    pub fn eglCreatePbufferFromClientBuffer(dpy: EGLDisplay,
                                            buftype: EGLenum,
                                            buffer: EGLClientBuffer,
                                            config: EGLConfig,
                                            attrib_list: *const EGLint)
                                            -> EGLSurface;

    pub fn eglReleaseThread() -> EGLBoolean;

    pub fn eglWaitClient() -> EGLBoolean;

    // EGL 1.4

    pub fn eglGetCurrentContext() -> EGLContext;

    // EGL 1.5

    #[cfg(feature = "egl_1_5")]
    pub fn eglCreateSync(dpy: EGLDisplay,
                         _type: EGLenum,
                         attrib_list: *const EGLAttrib)
                         -> EGLSync;

    #[cfg(feature = "egl_1_5")]
    pub fn eglDestroySync(dpy: EGLDisplay, sync: EGLSync) -> EGLBoolean;

    #[cfg(feature = "egl_1_5")]
    pub fn eglClientWaitSync(dpy: EGLDisplay,
                             sync: EGLSync,
                             flags: EGLint,
                             timeout: EGLTime)
                             -> EGLint;

    #[cfg(feature = "egl_1_5")]
    pub fn eglGetSyncAttrib(dpy: EGLDisplay,
                            sync: EGLSync,
                            attribute: EGLint,
                            value: *mut EGLAttrib)
                            -> EGLBoolean;

    #[cfg(feature = "egl_1_5")]
    pub fn eglCreateImage(dpy: EGLDisplay,
                          ctx: EGLContext,
                          target: EGLenum,
                          buffer: EGLClientBuffer,
                          attrib_list: *const EGLAttrib)
                          -> EGLImage;

    #[cfg(feature = "egl_1_5")]
    pub fn eglDestroyImage(dpy: EGLDisplay, image: EGLImage) -> EGLBoolean;

    #[cfg(feature = "egl_1_5")]
    pub fn eglGetPlatformDisplay(platform: EGLenum,
                                 native_display: *mut c_void,
                                 attrib_list: *const EGLAttrib)
                                 -> EGLDisplay;

    #[cfg(feature = "egl_1_5")]
    pub fn eglCreatePlatformWindowSurface(dpy: EGLDisplay,
                                          config: EGLConfig,
                                          native_window: *mut c_void,
                                          attrib_list: *const EGLAttrib)
                                          -> EGLSurface;

    #[cfg(feature = "egl_1_5")]
    pub fn eglCreatePlatformPixmapSurface(dpy: EGLDisplay,
                                          config: EGLConfig,
                                          native_pixmap: *mut c_void,
                                          attrib_list: *const EGLAttrib)
                                          -> EGLSurface;

    #[cfg(feature = "egl_1_5")]
    pub fn eglWaitSync(dpy: EGLDisplay, sync: EGLSync, flags: EGLint) -> EGLBoolean;
}