1 {
2 ** Copyright (c) 2007-2009 The Khronos Group Inc.
3 **
4 ** Permission is hereby granted, free of charge, to any person obtaining a
5 ** copy of this software and/or associated documentation files (the
6 ** "Materials"), to deal in the Materials without restriction, including
7 ** without limitation the rights to use, copy, modify, merge, publish,
8 ** distribute, sublicense, and/or sell copies of the Materials, and to
9 ** permit persons to whom the Materials are furnished to do so, subject to
10 ** the following conditions:
11 **
12 ** The above copyright notice and this permission notice shall be included
13 ** in all copies or substantial portions of the Materials.
14 **
15 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
22 }
23 
24 unit egl;
25 
26 interface
27 
28 uses ctypes
29      {$IF DEFINED(WINDOWS)}
30      ,windows
31      {$ELSEIF DEFINED(ANDROID)}
32      {$ELSEIF DEFINED(UNIX)}
33      ,x,xlib,xutil
34      {$ENDIF};
35 
36 const
37   LibName = 'libEGL.so';
38 
39 type
40   EGLBoolean = cuint;
41   EGLenum = cuint;
42   EGLint = cint;
43 
44   PEGLint = ^EGLint;
45 
46 type
47   EGLConfig = Pointer;
48   EGLContext = Pointer;
49   EGLDisplay = Pointer;
50   EGLSurface = Pointer;
51   EGLClientBuffer = Pointer;
52 
53   PEGLConfig = ^EGLConfig;
54 
55 {$IF defined(WINDOWS)}
56   EGLNativeDisplayType = HDC;
57   EGLNativePixmapType = HBITMAP;
58   EGLNativeWindowType = HWINDOW;
59 {$ELSEIF defined(SYMBIAN)}
60   EGLNativeDisplayType = cint;
61   EGLNativePixmapType = Pointer;
62   EGLNativeWindowType = Pointer;
63 {$ELSEIF defined(ANDROID)}
64   EGLNativeDisplayType = Pointer;
65   EGLNativePixmapType = Pointer;
66   EGLNativeWindowType = Pointer;
67 {$ELSEIF defined(UNIX)}
68   EGLNativeDisplayType = PDisplay;
69   EGLNativePixmapType = TPixmap;
70   EGLNativeWindowType = TWindow;
71 {$ENDIF}
72 
73   NativeDisplayType = EGLNativeDisplayType;
74   NativePixmapType = EGLNativePixmapType;
75   NativeWindowType = EGLNativeWindowType;
76 
77   (* EGL Versioning  *)
78 
79 const
80   EGL_VERSION_1_0 = 1;
81   EGL_VERSION_1_1 = 1;
82   EGL_VERSION_1_2 = 1;
83   EGL_VERSION_1_3 = 1;
84   EGL_VERSION_1_4 = 1;
85   (* EGL Enumerants. Bitmasks and other exceptional cases aside, most
86    * enums are assigned unique values starting at 0x3000.
87    *)
88 
89   (* EGL aliases  *)
90 
91   EGL_FALSE = 0;
92   EGL_TRUE = 1;
93   (* Out-of-band handle values  *)
94 
95   EGL_DEFAULT_DISPLAY = EGLNativeDisplayType(0);
96   EGL_NO_CONTEXT = EGLContext(0);
97   EGL_NO_DISPLAY = EGLDisplay(0);
98   EGL_NO_SURFACE = EGLSurface(0);
99   (* Out-of-band attribute value  *)
100 
101   EGL_DONT_CARE = -1;
102   (* Errors / GetError return values  *)
103 
104   EGL_SUCCESS = $3000;
105   EGL_NOT_INITIALIZED = $3001;
106   EGL_BAD_ACCESS = $3002;
107   EGL_BAD_ALLOC = $3003;
108   EGL_BAD_ATTRIBUTE = $3004;
109   EGL_BAD_CONFIG = $3005;
110   EGL_BAD_CONTEXT = $3006;
111   EGL_BAD_CURRENT_SURFACE = $3007;
112   EGL_BAD_DISPLAY = $3008;
113   EGL_BAD_MATCH = $3009;
114   EGL_BAD_NATIVE_PIXMAP = $300A;
115   EGL_BAD_NATIVE_WINDOW = $300B;
116   EGL_BAD_PARAMETER = $300C;
117   EGL_BAD_SURFACE = $300D;
118   EGL_CONTEXT_LOST = $300E;  (* EGL 1.1 - IMG_power_management  *)
119   (* Reserved 0x300F-0x301F for additional errors  *)
120 
121   (* Config attributes  *)
122 
123   EGL_BUFFER_SIZE = $3020;
124   EGL_ALPHA_SIZE = $3021;
125   EGL_BLUE_SIZE = $3022;
126   EGL_GREEN_SIZE = $3023;
127   EGL_RED_SIZE = $3024;
128   EGL_DEPTH_SIZE = $3025;
129   EGL_STENCIL_SIZE = $3026;
130   EGL_CONFIG_CAVEAT = $3027;
131   EGL_CONFIG_ID = $3028;
132   EGL_LEVEL = $3029;
133   EGL_MAX_PBUFFER_HEIGHT = $302A;
134   EGL_MAX_PBUFFER_PIXELS = $302B;
135   EGL_MAX_PBUFFER_WIDTH = $302C;
136   EGL_NATIVE_RENDERABLE = $302D;
137   EGL_NATIVE_VISUAL_ID = $302E;
138   EGL_NATIVE_VISUAL_TYPE = $302F;
139   EGL_SAMPLES = $3031;
140   EGL_SAMPLE_BUFFERS = $3032;
141   EGL_SURFACE_TYPE = $3033;
142   EGL_TRANSPARENT_TYPE = $3034;
143   EGL_TRANSPARENT_BLUE_VALUE = $3035;
144   EGL_TRANSPARENT_GREEN_VALUE = $3036;
145   EGL_TRANSPARENT_RED_VALUE = $3037;
146   EGL_NONE = $3038;  (* Attrib list terminator  *)
147   EGL_BIND_TO_TEXTURE_RGB = $3039;
148   EGL_BIND_TO_TEXTURE_RGBA = $303A;
149   EGL_MIN_SWAP_INTERVAL = $303B;
150   EGL_MAX_SWAP_INTERVAL = $303C;
151   EGL_LUMINANCE_SIZE = $303D;
152   EGL_ALPHA_MASK_SIZE = $303E;
153   EGL_COLOR_BUFFER_TYPE = $303F;
154   EGL_RENDERABLE_TYPE = $3040;
155   EGL_MATCH_NATIVE_PIXMAP = $3041;  (* Pseudo-attribute (not queryable)  *)
156   EGL_CONFORMANT = $3042;
157   (* Reserved 0x3041-0x304F for additional config attributes  *)
158 
159   (* Config attribute values  *)
160 
161   EGL_SLOW_CONFIG = $3050;  (* EGL_CONFIG_CAVEAT value  *)
162   EGL_NON_CONFORMANT_CONFIG = $3051;  (* EGL_CONFIG_CAVEAT value  *)
163   EGL_TRANSPARENT_RGB = $3052;  (* EGL_TRANSPARENT_TYPE value  *)
164   EGL_RGB_BUFFER = $308E;  (* EGL_COLOR_BUFFER_TYPE value  *)
165   EGL_LUMINANCE_BUFFER = $308F;  (* EGL_COLOR_BUFFER_TYPE value  *)
166   (* More config attribute values, for EGL_TEXTURE_FORMAT  *)
167 
168   EGL_NO_TEXTURE = $305C;
169   EGL_TEXTURE_RGB = $305D;
170   EGL_TEXTURE_RGBA = $305E;
171   EGL_TEXTURE_2D = $305F;
172   (* Config attribute mask bits  *)
173 
174   EGL_PBUFFER_BIT = $0001;  (* EGL_SURFACE_TYPE mask bits  *)
175   EGL_PIXMAP_BIT = $0002;  (* EGL_SURFACE_TYPE mask bits  *)
176   EGL_WINDOW_BIT = $0004;  (* EGL_SURFACE_TYPE mask bits  *)
177   EGL_VG_COLORSPACE_LINEAR_BIT = $0020;  (* EGL_SURFACE_TYPE mask bits  *)
178   EGL_VG_ALPHA_FORMAT_PRE_BIT = $0040;  (* EGL_SURFACE_TYPE mask bits  *)
179   EGL_MULTISAMPLE_RESOLVE_BOX_BIT = $0200;  (* EGL_SURFACE_TYPE mask bits  *)
180   EGL_SWAP_BEHAVIOR_PRESERVED_BIT = $0400;  (* EGL_SURFACE_TYPE mask bits  *)
181   EGL_OPENGL_ES_BIT = $0001;  (* EGL_RENDERABLE_TYPE mask bits  *)
182   EGL_OPENVG_BIT = $0002;  (* EGL_RENDERABLE_TYPE mask bits  *)
183   EGL_OPENGL_ES2_BIT = $0004;  (* EGL_RENDERABLE_TYPE mask bits  *)
184   EGL_OPENGL_BIT = $0008;  (* EGL_RENDERABLE_TYPE mask bits  *)
185   (* QueryString targets  *)
186 
187   EGL_VENDOR = $3053;
188   EGL_VERSION = $3054;
189   EGL_EXTENSIONS = $3055;
190   EGL_CLIENT_APIS = $308D;
191   (* QuerySurface / SurfaceAttrib / CreatePbufferSurface targets  *)
192 
193   EGL_HEIGHT = $3056;
194   EGL_WIDTH = $3057;
195   EGL_LARGEST_PBUFFER = $3058;
196   EGL_TEXTURE_FORMAT = $3080;
197   EGL_TEXTURE_TARGET = $3081;
198   EGL_MIPMAP_TEXTURE = $3082;
199   EGL_MIPMAP_LEVEL = $3083;
200   EGL_RENDER_BUFFER = $3086;
201   EGL_VG_COLORSPACE = $3087;
202   EGL_VG_ALPHA_FORMAT = $3088;
203   EGL_HORIZONTAL_RESOLUTION = $3090;
204   EGL_VERTICAL_RESOLUTION = $3091;
205   EGL_PIXEL_ASPECT_RATIO = $3092;
206   EGL_SWAP_BEHAVIOR = $3093;
207   EGL_MULTISAMPLE_RESOLVE = $3099;
208   (* EGL_RENDER_BUFFER values / BindTexImage / ReleaseTexImage buffer targets  *)
209 
210   EGL_BACK_BUFFER = $3084;
211   EGL_SINGLE_BUFFER = $3085;
212   (* OpenVG color spaces  *)
213 
214   EGL_VG_COLORSPACE_sRGB = $3089;  (* EGL_VG_COLORSPACE value  *)
215   EGL_VG_COLORSPACE_LINEAR = $308A;  (* EGL_VG_COLORSPACE value  *)
216   (* OpenVG alpha formats  *)
217 
218   EGL_VG_ALPHA_FORMAT_NONPRE = $308B;  (* EGL_ALPHA_FORMAT value  *)
219   EGL_VG_ALPHA_FORMAT_PRE = $308C;  (* EGL_ALPHA_FORMAT value  *)
220   (* Constant scale factor by which fractional display resolutions &
221  * aspect ratio are scaled when queried as integer values.
222   *)
223 
224   EGL_DISPLAY_SCALING = 10000;
225   (* Unknown display resolution/aspect ratio  *)
226 
227   EGL_UNKNOWN = -1;
228   (* Back buffer swap behaviors  *)
229 
230   EGL_BUFFER_PRESERVED = $3094;  (* EGL_SWAP_BEHAVIOR value  *)
231   EGL_BUFFER_DESTROYED = $3095;  (* EGL_SWAP_BEHAVIOR value  *)
232   (* CreatePbufferFromClientBuffer buffer types  *)
233 
234   EGL_OPENVG_IMAGE = $3096;
235   (* QueryContext targets  *)
236 
237   EGL_CONTEXT_CLIENT_TYPE = $3097;
238   (* CreateContext attributes  *)
239 
240   EGL_CONTEXT_CLIENT_VERSION = $3098;
241   (* Multisample resolution behaviors  *)
242 
243   EGL_MULTISAMPLE_RESOLVE_DEFAULT = $309A;  (* EGL_MULTISAMPLE_RESOLVE value  *)
244   EGL_MULTISAMPLE_RESOLVE_BOX = $309B;  (* EGL_MULTISAMPLE_RESOLVE value  *)
245   (* BindAPI/QueryAPI targets  *)
246 
247   EGL_OPENGL_ES_API = $30A0;
248   EGL_OPENVG_API = $30A1;
249   EGL_OPENGL_API = $30A2;
250   (* GetCurrentSurface targets  *)
251 
252   EGL_DRAW = $3059;
253   EGL_READ = $305A;
254   (* WaitNative engines  *)
255 
256   EGL_CORE_NATIVE_ENGINE = $305B;
257   (* EGL 1.2 tokens renamed for consistency in EGL 1.3  *)
258 
259   EGL_COLORSPACE = EGL_VG_COLORSPACE;
260   EGL_ALPHA_FORMAT = EGL_VG_ALPHA_FORMAT;
261   EGL_COLORSPACE_sRGB = EGL_VG_COLORSPACE_sRGB;
262   EGL_COLORSPACE_LINEAR = EGL_VG_COLORSPACE_LINEAR;
263   EGL_ALPHA_FORMAT_NONPRE = EGL_VG_ALPHA_FORMAT_NONPRE;
264   EGL_ALPHA_FORMAT_PRE = EGL_VG_ALPHA_FORMAT_PRE;
265   (* EGL extensions must request enum blocks from the Khronos
266  * API Registrar, who maintains the enumerant registry. Submit
267  * a bug in Khronos Bugzilla against task "Registry".
268   *)
269 
270 
271   (* EGL Functions  *)
272 
eglGetErrornull273 function eglGetError: EGLint; cdecl; external LibName;
274 
eglGetDisplaynull275 function eglGetDisplay(display_id: EGLNativeDisplayType): EGLDisplay; cdecl; external LibName;
eglInitializenull276 function eglInitialize(dpy: EGLDisplay; major, minor: PEGLint): EGLBoolean; cdecl; external LibName;
eglTerminatenull277 function eglTerminate(dpy: EGLDisplay): EGLBoolean; cdecl; external LibName;
278 
eglQueryStringnull279 function eglQueryString(dpy: EGLDisplay; name_: EGLint): Pchar; cdecl; external LibName;
280 
eglGetConfigsnull281 function eglGetConfigs(dpy: EGLDisplay; configs: PEGLConfig; config_size: EGLint; num_config: PEGLint): EGLBoolean; cdecl; external LibName;
eglChooseConfignull282 function eglChooseConfig(dpy: EGLDisplay; attrib_list: PEGLint; configs: PEGLConfig; config_size: EGLint; num_config: PEGLint): EGLBoolean; cdecl; external LibName;
eglGetConfigAttribnull283 function eglGetConfigAttrib(dpy: EGLDisplay; config: EGLConfig; attribute: EGLint; value: PEGLint): EGLBoolean; cdecl; external LibName;
eglCreateWindowSurfacenull284 function eglCreateWindowSurface(dpy: EGLDisplay; config: EGLConfig; win: EGLNativeWindowType; attrib_list: PEGLint): EGLSurface; cdecl; external LibName;
eglCreatePbufferSurfacenull285 function eglCreatePbufferSurface(dpy: EGLDisplay; config: EGLConfig; attrib_list: PEGLint): EGLSurface; cdecl; external LibName;
eglCreatePixmapSurfacenull286 function eglCreatePixmapSurface(dpy: EGLDisplay; config: EGLConfig; pixmap: EGLNativePixmapType; attrib_list: PEGLint): EGLSurface; cdecl; external LibName;
eglDestroySurfacenull287 function eglDestroySurface(dpy: EGLDisplay; surface: EGLSurface): EGLBoolean; cdecl; external LibName;
eglQuerySurfacenull288 function eglQuerySurface(dpy: EGLDisplay; surface: EGLSurface; attribute: EGLint; value: PEGLint): EGLBoolean; cdecl; external LibName;
eglBindAPInull289 function eglBindAPI(api: EGLenum): EGLBoolean; cdecl; external LibName;
eglQueryAPInull290 function eglQueryAPI: EGLenum; cdecl; external LibName;
eglWaitClientnull291 function eglWaitClient: EGLBoolean; cdecl; external LibName;
eglReleaseThreadnull292 function eglReleaseThread: EGLBoolean; cdecl; external LibName;
eglCreatePbufferFromClientBuffernull293 function eglCreatePbufferFromClientBuffer(dpy: EGLDisplay; buftype: EGLenum; buffer: EGLClientBuffer; config: EGLConfig; attrib_list: PEGLint): EGLSurface; cdecl; external LibName;
eglSurfaceAttribnull294 function eglSurfaceAttrib(dpy: EGLDisplay; surface: EGLSurface; attribute, value: EGLint): EGLBoolean; cdecl; external LibName;
eglBindTexImagenull295 function eglBindTexImage(dpy: EGLDisplay; surface: EGLSurface; buffer: EGLint): EGLBoolean; cdecl; external LibName;
eglReleaseTexImagenull296 function eglReleaseTexImage(dpy: EGLDisplay; surface: EGLSurface; buffer: EGLint): EGLBoolean; cdecl; external LibName;
297 
eglSwapIntervalnull298 function eglSwapInterval(dpy: EGLDisplay; interval: EGLint): EGLBoolean; cdecl; external LibName;
299 
eglCreateContextnull300 function eglCreateContext(dpy: EGLDisplay; config: EGLConfig; share_context: EGLContext; attrib_list: PEGLint): EGLContext; cdecl; external LibName;
eglDestroyContextnull301 function eglDestroyContext(dpy: EGLDisplay; ctx: EGLContext): EGLBoolean; cdecl; external LibName;
eglMakeCurrentnull302 function eglMakeCurrent(dpy: EGLDisplay; draw, read_: EGLSurface; ctx: EGLContext): EGLBoolean; cdecl; external LibName;
eglGetCurrentContextnull303 function eglGetCurrentContext: EGLContext; cdecl; external LibName;
eglGetCurrentSurfacenull304 function eglGetCurrentSurface(readdraw: EGLint): EGLSurface; cdecl; external LibName;
eglGetCurrentDisplaynull305 function eglGetCurrentDisplay: EGLDisplay; cdecl; external LibName;
eglQueryContextnull306 function eglQueryContext(dpy: EGLDisplay; ctx: EGLContext; attribute: EGLint; value: PEGLint): EGLBoolean; cdecl; external LibName;
eglWaitGLnull307 function eglWaitGL: EGLBoolean; cdecl; external LibName;
eglWaitNativenull308 function eglWaitNative(engine: EGLint): EGLBoolean; cdecl; external LibName;
eglSwapBuffersnull309 function eglSwapBuffers(dpy: EGLDisplay; surface: EGLSurface): EGLBoolean; cdecl; external LibName;
eglCopyBuffersnull310 function eglCopyBuffers(dpy: EGLDisplay; surface: EGLSurface; target: EGLNativePixmapType): EGLBoolean; cdecl; external LibName;
311 
312 (* This is a generic function pointer type, whose name indicates it must
313  * be cast to the proper type *and calling convention* before use.
314   *)
315 
316 type
317   __eglMustCastToProperFunctionPointerType = procedure; cdecl;
318 
eglGetProcAddressnull319 function eglGetProcAddress(procname: Pchar): __eglMustCastToProperFunctionPointerType; cdecl; external LibName;
320 
321 implementation
322 
323 end.
324