00001 #region License
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #endregion
00027
00028 using System;
00029 using System.Runtime.InteropServices;
00030 using System.Collections.Generic;
00031 using System.Text;
00032 using OpenTK.Graphics;
00033
00034 namespace OpenTK.Platform.Egl
00035 {
00036 using EGLNativeDisplayType = IntPtr;
00037 using EGLNativePixmapType = IntPtr;
00038 using EGLConfig = IntPtr;
00039 using EGLContext = IntPtr;
00040 using EGLDisplay = IntPtr;
00041 using EGLSurface = IntPtr;
00042 using EGLClientBuffer = IntPtr;
00043
00044 static partial class Egl
00045 {
00046 public const int VERSION_1_0 = 1;
00047 public const int VERSION_1_1 = 1;
00048 public const int VERSION_1_2 = 1;
00049 public const int VERSION_1_3 = 1;
00050 public const int VERSION_1_4 = 1;
00051 public const int FALSE = 0;
00052 public const int TRUE = 1;
00053 public const int DONT_CARE = -1;
00054 public const int SUCCESS = 12288;
00055 public const int NOT_INITIALIZED = 12289;
00056 public const int BAD_ACCESS = 12290;
00057 public const int BAD_ALLOC = 12291;
00058 public const int BAD_ATTRIBUTE = 12292;
00059 public const int BAD_CONFIG = 12293;
00060 public const int BAD_CONTEXT = 12294;
00061 public const int BAD_CURRENT_SURFACE = 12295;
00062 public const int BAD_DISPLAY = 12296;
00063 public const int BAD_MATCH = 12297;
00064 public const int BAD_NATIVE_PIXMAP = 12298;
00065 public const int BAD_NATIVE_WINDOW = 12299;
00066 public const int BAD_PARAMETER = 12300;
00067 public const int BAD_SURFACE = 12301;
00068 public const int CONTEXT_LOST = 12302;
00069 public const int BUFFER_SIZE = 12320;
00070 public const int ALPHA_SIZE = 12321;
00071 public const int BLUE_SIZE = 12322;
00072 public const int GREEN_SIZE = 12323;
00073 public const int RED_SIZE = 12324;
00074 public const int DEPTH_SIZE = 12325;
00075 public const int STENCIL_SIZE = 12326;
00076 public const int CONFIG_CAVEAT = 12327;
00077 public const int CONFIG_ID = 12328;
00078 public const int LEVEL = 12329;
00079 public const int MAX_PBUFFER_HEIGHT = 12330;
00080 public const int MAX_PBUFFER_PIXELS = 12331;
00081 public const int MAX_PBUFFER_WIDTH = 12332;
00082 public const int NATIVE_RENDERABLE = 12333;
00083 public const int NATIVE_VISUAL_ID = 12334;
00084 public const int NATIVE_VISUAL_TYPE = 12335;
00085 public const int PRESERVED_RESOURCES = 12336;
00086 public const int SAMPLES = 12337;
00087 public const int SAMPLE_BUFFERS = 12338;
00088 public const int SURFACE_TYPE = 12339;
00089 public const int TRANSPARENT_TYPE = 12340;
00090 public const int TRANSPARENT_BLUE_VALUE = 12341;
00091 public const int TRANSPARENT_GREEN_VALUE = 12342;
00092 public const int TRANSPARENT_RED_VALUE = 12343;
00093 public const int NONE = 12344;
00094 public const int BIND_TO_TEXTURE_RGB = 12345;
00095 public const int BIND_TO_TEXTURE_RGBA = 12346;
00096 public const int MIN_SWAP_INTERVAL = 12347;
00097 public const int MAX_SWAP_INTERVAL = 12348;
00098 public const int LUMINANCE_SIZE = 12349;
00099 public const int ALPHA_MASK_SIZE = 12350;
00100 public const int COLOR_BUFFER_TYPE = 12351;
00101 public const int RENDERABLE_TYPE = 12352;
00102 public const int MATCH_NATIVE_PIXMAP = 12353;
00103 public const int CONFORMANT = 12354;
00104 public const int SLOW_CONFIG = 12368;
00105 public const int NON_CONFORMANT_CONFIG = 12369;
00106 public const int TRANSPARENT_RGB = 12370;
00107 public const int RGB_BUFFER = 12430;
00108 public const int LUMINANCE_BUFFER = 12431;
00109 public const int NO_TEXTURE = 12380;
00110 public const int TEXTURE_RGB = 12381;
00111 public const int TEXTURE_RGBA = 12382;
00112 public const int TEXTURE_2D = 12383;
00113 public const int PBUFFER_BIT = 1;
00114 public const int PIXMAP_BIT = 2;
00115 public const int WINDOW_BIT = 4;
00116 public const int VG_COLORSPACE_LINEAR_BIT = 32;
00117 public const int VG_ALPHA_FORMAT_PRE_BIT = 64;
00118 public const int MULTISAMPLE_RESOLVE_BOX_BIT = 512;
00119 public const int SWAP_BEHAVIOR_PRESERVED_BIT = 1024;
00120 public const int OPENGL_ES_BIT = 1;
00121 public const int OPENVG_BIT = 2;
00122 public const int OPENGL_ES2_BIT = 4;
00123 public const int OPENGL_BIT = 8;
00124 public const int VENDOR = 12371;
00125 public const int VERSION = 12372;
00126 public const int EXTENSIONS = 12373;
00127 public const int CLIENT_APIS = 12429;
00128 public const int HEIGHT = 12374;
00129 public const int WIDTH = 12375;
00130 public const int LARGEST_PBUFFER = 12376;
00131 public const int TEXTURE_FORMAT = 12416;
00132 public const int TEXTURE_TARGET = 12417;
00133 public const int MIPMAP_TEXTURE = 12418;
00134 public const int MIPMAP_LEVEL = 12419;
00135 public const int RENDER_BUFFER = 12422;
00136 public const int VG_COLORSPACE = 12423;
00137 public const int VG_ALPHA_FORMAT = 12424;
00138 public const int HORIZONTAL_RESOLUTION = 12432;
00139 public const int VERTICAL_RESOLUTION = 12433;
00140 public const int PIXEL_ASPECT_RATIO = 12434;
00141 public const int SWAP_BEHAVIOR = 12435;
00142 public const int MULTISAMPLE_RESOLVE = 12441;
00143 public const int BACK_BUFFER = 12420;
00144 public const int SINGLE_BUFFER = 12421;
00145 public const int VG_COLORSPACE_sRGB = 12425;
00146 public const int VG_COLORSPACE_LINEAR = 12426;
00147 public const int VG_ALPHA_FORMAT_NONPRE = 12427;
00148 public const int VG_ALPHA_FORMAT_PRE = 12428;
00149 public const int DISPLAY_SCALING = 10000;
00150 public const int UNKNOWN = -1;
00151 public const int BUFFER_PRESERVED = 12436;
00152 public const int BUFFER_DESTROYED = 12437;
00153 public const int OPENVG_IMAGE = 12438;
00154 public const int CONTEXT_CLIENT_TYPE = 12439;
00155 public const int CONTEXT_CLIENT_VERSION = 12440;
00156 public const int MULTISAMPLE_RESOLVE_DEFAULT = 12442;
00157 public const int MULTISAMPLE_RESOLVE_BOX = 12443;
00158 public const int OPENGL_ES_API = 12448;
00159 public const int OPENVG_API = 12449;
00160 public const int OPENGL_API = 12450;
00161 public const int DRAW = 12377;
00162 public const int READ = 12378;
00163 public const int CORE_NATIVE_ENGINE = 12379;
00164 public const int COLORSPACE = VG_COLORSPACE;
00165 public const int ALPHA_FORMAT = VG_ALPHA_FORMAT;
00166 public const int COLORSPACE_sRGB = VG_COLORSPACE_sRGB;
00167 public const int COLORSPACE_LINEAR = VG_COLORSPACE_LINEAR;
00168 public const int ALPHA_FORMAT_NONPRE = VG_ALPHA_FORMAT_NONPRE;
00169 public const int ALPHA_FORMAT_PRE = VG_ALPHA_FORMAT_PRE;
00170
00171 [DllImportAttribute("libEGL.dll", EntryPoint = "eglGetError")]
00172 public static extern int GetError();
00173
00174 [DllImportAttribute("libEGL.dll", EntryPoint = "eglGetDisplay")]
00175 public static extern EGLDisplay GetDisplay(EGLNativeDisplayType display_id);
00176
00177 [DllImportAttribute("libEGL.dll", EntryPoint = "eglInitialize")]
00178
00179 public static extern bool Initialize(EGLDisplay dpy, out int major, out int minor);
00180
00181 [DllImportAttribute("libEGL.dll", EntryPoint = "eglTerminate")]
00182
00183 public static extern bool Terminate(EGLDisplay dpy);
00184
00185 [DllImportAttribute("libEGL.dll", EntryPoint = "eglQueryString")]
00186 public static extern IntPtr QueryString(EGLDisplay dpy, int name);
00187
00188 [DllImportAttribute("libEGL.dll", EntryPoint = "eglGetConfigs")]
00189 [return: MarshalAsAttribute(UnmanagedType.I1)]
00190 public static extern bool GetConfigs(EGLDisplay dpy, EGLConfig[] configs, int config_size, out int num_config);
00191
00192 [DllImportAttribute("libEGL.dll", EntryPoint = "eglChooseConfig")]
00193 [return: MarshalAsAttribute(UnmanagedType.I1)]
00194 public static extern bool ChooseConfig(EGLDisplay dpy, int[] attrib_list, [In, Out] EGLConfig[] configs, int config_size, out int num_config);
00195
00196 [DllImportAttribute("libEGL.dll", EntryPoint = "eglGetConfigAttrib")]
00197 [return: MarshalAsAttribute(UnmanagedType.I1)]
00198 public static extern bool GetConfigAttrib(EGLDisplay dpy, EGLConfig config, int attribute, out int value);
00199
00200 [DllImportAttribute("libEGL.dll", EntryPoint = "eglCreateWindowSurface")]
00201 public static extern EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, IntPtr win, int[] attrib_list);
00202
00203 [DllImportAttribute("libEGL.dll", EntryPoint = "eglCreatePbufferSurface")]
00204 public static extern EGLSurface CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, int[] attrib_list);
00205
00206 [DllImportAttribute("libEGL.dll", EntryPoint = "eglCreatePixmapSurface")]
00207 public static extern EGLSurface CreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, int[] attrib_list);
00208
00209 [DllImportAttribute("libEGL.dll", EntryPoint = "eglDestroySurface")]
00210 [return: MarshalAsAttribute(UnmanagedType.I1)]
00211 public static extern bool DestroySurface(EGLDisplay dpy, EGLSurface surface);
00212
00213 [DllImportAttribute("libEGL.dll", EntryPoint = "eglQuerySurface")]
00214 [return: MarshalAsAttribute(UnmanagedType.I1)]
00215 public static extern bool QuerySurface(EGLDisplay dpy, EGLSurface surface, int attribute, out int value);
00216
00217 [DllImportAttribute("libEGL.dll", EntryPoint = "eglBindAPI")]
00218 [return: MarshalAsAttribute(UnmanagedType.I1)]
00219 public static extern bool BindAPI(int api);
00220
00221 [DllImportAttribute("libEGL.dll", EntryPoint = "eglQueryAPI")]
00222 public static extern int QueryAPI();
00223
00224 [DllImportAttribute("libEGL.dll", EntryPoint = "eglWaitClient")]
00225 [return: MarshalAsAttribute(UnmanagedType.I1)]
00226 public static extern bool WaitClient();
00227
00228 [DllImportAttribute("libEGL.dll", EntryPoint = "eglReleaseThread")]
00229 [return: MarshalAsAttribute(UnmanagedType.I1)]
00230 public static extern bool ReleaseThread();
00231
00232 [DllImportAttribute("libEGL.dll", EntryPoint = "eglCreatePbufferFromClientBuffer")]
00233 public static extern EGLSurface CreatePbufferFromClientBuffer(EGLDisplay dpy, int buftype, EGLClientBuffer buffer, EGLConfig config, int[] attrib_list);
00234
00235 [DllImportAttribute("libEGL.dll", EntryPoint = "eglSurfaceAttrib")]
00236 [return: MarshalAsAttribute(UnmanagedType.I1)]
00237 public static extern bool SurfaceAttrib(EGLDisplay dpy, EGLSurface surface, int attribute, int value);
00238
00239 [DllImportAttribute("libEGL.dll", EntryPoint = "eglBindTexImage")]
00240 [return: MarshalAsAttribute(UnmanagedType.I1)]
00241 public static extern bool BindTexImage(EGLDisplay dpy, EGLSurface surface, int buffer);
00242
00243 [DllImportAttribute("libEGL.dll", EntryPoint = "eglReleaseTexImage")]
00244 [return: MarshalAsAttribute(UnmanagedType.I1)]
00245 public static extern bool ReleaseTexImage(EGLDisplay dpy, EGLSurface surface, int buffer);
00246
00247 [DllImportAttribute("libEGL.dll", EntryPoint = "eglSwapInterval")]
00248 [return: MarshalAsAttribute(UnmanagedType.I1)]
00249 public static extern bool SwapInterval(EGLDisplay dpy, int interval);
00250
00251 [DllImportAttribute("libEGL.dll", EntryPoint = "eglCreateContext")]
00252 static extern IntPtr eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, int[] attrib_list);
00253
00254 public static EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, int[] attrib_list)
00255 {
00256 IntPtr ptr = eglCreateContext(dpy, config, share_context, attrib_list);
00257 if (ptr == IntPtr.Zero)
00258 throw new GraphicsContextException(String.Format("Failed to create EGL context, error: {0}.", Egl.GetError()));
00259 return ptr;
00260 }
00261
00262 [DllImportAttribute("libEGL.dll", EntryPoint = "eglDestroyContext")]
00263 [return: MarshalAsAttribute(UnmanagedType.I1)]
00264 public static extern bool DestroyContext(EGLDisplay dpy, EGLContext ctx);
00265
00266 [DllImportAttribute("libEGL.dll", EntryPoint = "eglMakeCurrent")]
00267 [return: MarshalAsAttribute(UnmanagedType.I1)]
00268 public static extern bool MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
00269
00270 [DllImportAttribute("libEGL.dll", EntryPoint = "eglGetCurrentContext")]
00271 public static extern EGLContext GetCurrentContext();
00272
00273 [DllImportAttribute("libEGL.dll", EntryPoint = "eglGetCurrentSurface")]
00274 public static extern EGLSurface GetCurrentSurface(int readdraw);
00275
00276 [DllImportAttribute("libEGL.dll", EntryPoint = "eglGetCurrentDisplay")]
00277 public static extern EGLDisplay GetCurrentDisplay();
00278
00279 [DllImportAttribute("libEGL.dll", EntryPoint = "eglQueryContext")]
00280 [return: MarshalAsAttribute(UnmanagedType.I1)]
00281 public static extern bool QueryContext(EGLDisplay dpy, EGLContext ctx, int attribute, out int value);
00282
00283 [DllImportAttribute("libEGL.dll", EntryPoint = "eglWaitGL")]
00284 [return: MarshalAsAttribute(UnmanagedType.I1)]
00285 public static extern bool WaitGL();
00286
00287 [DllImportAttribute("libEGL.dll", EntryPoint = "eglWaitNative")]
00288 [return: MarshalAsAttribute(UnmanagedType.I1)]
00289 public static extern bool WaitNative(int engine);
00290
00291 [DllImportAttribute("libEGL.dll", EntryPoint = "eglSwapBuffers")]
00292 [return: MarshalAsAttribute(UnmanagedType.I1)]
00293 public static extern bool SwapBuffers(EGLDisplay dpy, EGLSurface surface);
00294
00295 [DllImportAttribute("libEGL.dll", EntryPoint = "eglCopyBuffers")]
00296 [return: MarshalAsAttribute(UnmanagedType.I1)]
00297 public static extern bool CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
00298
00299 [DllImportAttribute("libEGL.dll", EntryPoint = "eglCopyBuffers")]
00300 public static extern IntPtr GetProcAddress(string funcname);
00301
00302
00303 public static bool IsSupported
00304 {
00305 get
00306 {
00307 try { GetCurrentContext(); }
00308 catch (Exception) { return false; }
00309 return true;
00310 }
00311 }
00312
00313 }
00314 #pragma warning restore 0169
00315 }