public static EglConfig[] GetConfigs(EglDisplay display) { var configAddrs = new IntPtr[64]; if (eglGetConfigs(display.Address, configAddrs, configAddrs.Length, out var numConfigs)) { var configs = new EglConfig[numConfigs]; for (var i = 0; i < configs.Length; i++) { var address = configAddrs[i]; if (_configs.ContainsKey(address)) { configs[i] = _configs[address]; } else { configs[i] = new EglConfig(display, configAddrs[i]); _configs[address] = configs[i]; } } return(configs); } else { throw new EglException("Unable to get all EGL configurations"); } }
internal EglSurface(EglDisplay display, IntPtr address, IntPtr handle) { Handle = handle; Display = display; Address = address; // Use EGL_MULTISAMPLE_RESOLVE_BOX // EGL.SetSurfaceAttribute( display, this, 0x3099, 0x309B ); }
public static EglSurface CreateWindowSurface(EglDisplay display, EglContext context, IntPtr handle) { var surfaceAddress = eglCreateWindowSurface(display.Address, context.Config.Address, handle, null); if (surfaceAddress == NO_SURFACE) { throw new EglException("Unable to create EGL window surface"); } var surface = new EglSurface(display, surfaceAddress, handle); return(_surfaces[surfaceAddress] = surface); }
public static bool DestroySurface(EglDisplay display, EglSurface surface) { if (eglDestroySurface(display.Address, surface.Address)) { _surfaces.Remove(surface.Address); surface.Address = IntPtr.Zero; return(true); } else { return(false); } }
public static bool DestroyContext(EglDisplay display, EglContext context) { if (eglDestroyContext(display.Address, context.Address)) { _contexts.Remove(context.Address); context.Address = IntPtr.Zero; return(true); } else { return(false); } }
public static EglContext CreateContext(EglDisplay display, EglConfig config, int contextVersion = 3, EglContext shareContext = null) { var attribs = new[] { EGL_CONTEXT_CLIENT_VERSION, contextVersion, EGL_NONE }; var contextAddress = eglCreateContext(display.Address, config.Address, shareContext?.Address ?? IntPtr.Zero, attribs); if (contextAddress == NO_CONTEXT) { throw new EglException("Unable to create EGL context"); } var context = new EglContext(config, contextAddress); return(_contexts[contextAddress] = context); }
public static bool Initialize(EglDisplay display, out int major, out int minor) { int maj, min; var b = eglInitialize(display.Address, &maj, &min); if (!b) { throw new EglException("Unable to initialize display"); } // major = maj; minor = min; return(b); }
public static EglConfig[] ChooseConfigs(EglDisplay display, EglConfigAttributes attr) { var attribs = new[] { (int)EglConfigAttribute.RedSize, attr.RedBits, (int)EglConfigAttribute.GreenSize, attr.GreenBits, (int)EglConfigAttribute.BlueSize, attr.BlueBits, (int)EglConfigAttribute.AlphaSize, attr.AlphaBits, // (int)EglConfigAttribute.DepthSize, attr.DepthBits, (int)EglConfigAttribute.StencilSize, attr.StencilBits, // (int)EglConfigAttribute.Samples, attr.Samples, // (int)EglConfigAttribute.RenderableType, (int)attr.RenderableType, // (int)EglConfigAttribute.SurfaceType, (int)attr.SurfaceType, EGL_NONE }; var configAddrs = new IntPtr[64]; if (eglChooseConfig(display.Address, attribs, configAddrs, configAddrs.Length, out var numConfigs)) { var configs = new EglConfig[numConfigs]; for (var i = 0; i < numConfigs; i++) { var address = configAddrs[i]; if (_configs.ContainsKey(address)) { configs[i] = _configs[address]; } else { configs[i] = new EglConfig(display, address); _configs[address] = configs[i]; } } return(configs); } else { throw new EglException("Unable to choose EGL configurations"); } }
public static void MakeCurrent(EglDisplay display, EglSurface drawSurface, EglSurface readSurface, EglContext context) { if (eglMakeCurrent(display.Address, drawSurface?.Address ?? NO_SURFACE, readSurface?.Address ?? NO_SURFACE, context?.Address ?? NO_CONTEXT)) { var thread = Thread.CurrentThread; // _threadContexts[thread] = context; _threadDrawSurfaces[thread] = drawSurface; _threadReadSurfaces[thread] = readSurface; _threadDisplays[thread] = display; } else { // throw new EglException($"Unable make surface + context current"); } }
public static EglSurface CreatePbufferSurface(EglDisplay display, EglContext context, int width, int height) { fixed(int *attr_ptr = new int[] { EGL_WIDTH, width, EGL_HEIGHT, height, EGL_NONE }) { var surfaceAddress = eglCreatePbufferSurface(display.Address, context.Config.Address, attr_ptr); if (surfaceAddress == NO_SURFACE) { throw new EglException("Unable to create EGL pbuffer surface"); } var surface = new EglSurface(display, surfaceAddress, IntPtr.Zero); return(_surfaces[surfaceAddress] = surface); } }
internal EglConfig(EglDisplay display, IntPtr address) { Address = address; Display = display; // Attributes = new EglConfigAttributes { // RedBits = GetAttribute(EglConfigAttribute.RedSize), BlueBits = GetAttribute(EglConfigAttribute.BlueSize), GreenBits = GetAttribute(EglConfigAttribute.GreenSize), AlphaBits = GetAttribute(EglConfigAttribute.AlphaSize), // DepthBits = GetAttribute(EglConfigAttribute.DepthSize), StencilBits = GetAttribute(EglConfigAttribute.StencilSize), // Samples = GetAttribute(EglConfigAttribute.Samples), // RenderableType = (EglRenderableType)GetAttribute(EglConfigAttribute.RenderableType), }; }
public static EglDisplay GetDisplay(IntPtr native_display) { if (_displays.ContainsKey(native_display)) { return(_displays[native_display]); } else { // Try EGL Default Display var displayAddress = eglGetDisplay(native_display); // Throw exception if we haven't acquired a display. if (displayAddress == NO_DISPLAY) { throw new EglException("Unable to get EGL display"); } // Create display var display = new EglDisplay(displayAddress); _displays[native_display] = display; return(display); } }
public static bool Terminate(EglDisplay display) { return(eglTerminate(display.Address)); }
public static bool Initialize(EglDisplay display) { return(eglInitialize(display.Address, (int *)0, (int *)0)); }
internal static bool QuerySurface(EglDisplay display, EglSurface surface, EglSurfaceQuery name, out int result) { return(eglQuerySurface(display.Address, surface.Address, name, out result)); }
internal static string QueryString(EglDisplay display, EglStringQuery name) { return(new string(eglQueryString(display.Address, name))); }
internal static bool GetConfigAttrib(EglDisplay display, EglConfig config, EglConfigAttribute attribute, out int value) { return(eglGetConfigAttrib(display.Address, config.Address, attribute, out value)); }
internal static bool SetSurfaceAttribute(EglDisplay display, EglSurface surface, int name, int value) { return(eglSurfaceAttrib(display.Address, surface.Address, name, value)); }
internal static bool SwapInterval(EglDisplay display, int interval) { return(eglSwapInterval(display.Address, interval)); }
internal static bool SwapBuffers(EglDisplay display, EglSurface surface) { return(eglSwapBuffers(display.Address, surface.Address)); }
public static EglConfig ChooseConfig(EglDisplay display, EglConfigAttributes attr) { return(ChooseConfigs(display, attr).FirstOrDefault()); }
public static void MakeCurrent(EglDisplay display, EglSurface surface, EglContext context) { MakeCurrent(display, surface, surface, context); }