bool vsync = true; // Default vsync value is defined as 1 (true) in EGL. #endregion #region Constructors public EglContext(GraphicsMode mode, EglWindowInfo window, IGraphicsContext sharedContext, int major, int minor, GraphicsContextFlags flags) { if (mode == null) throw new ArgumentNullException("mode"); if (window == null) throw new ArgumentNullException("window"); EglContext shared = (EglContext)sharedContext; int dummy_major, dummy_minor; if (!Egl.Initialize(window.Display, out dummy_major, out dummy_minor)) throw new GraphicsContextException(String.Format("Failed to initialize EGL, error {0}.", Egl.GetError())); WindowInfo = window; Mode = new EglGraphicsMode().SelectGraphicsMode(mode.ColorFormat, mode.Depth, mode.Stencil, mode.Samples, mode.AccumulatorFormat, mode.Buffers, mode.Stereo); if (!Mode.Index.HasValue) throw new GraphicsModeException("Invalid or unsupported GraphicsMode."); EGLConfig config = new EGLConfig(mode.Index.Value); if (window.Surface.Handle == EGLSurface.None.Handle) window.CreateWindowSurface(config); int[] attrib_list = new int[] { Egl.CONTEXT_CLIENT_VERSION, major, Egl.NONE }; HandleAsEGLContext = Egl.CreateContext(window.Display, config, shared != null ? shared.HandleAsEGLContext : EGLContext.None, attrib_list); MakeCurrent(window); }
public static extern bool QueryContext(EGLDisplay dpy, EGLContext ctx, int attribute, out int value);
public static extern bool MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
public static extern bool DestroyContext(EGLDisplay dpy, EGLContext ctx);
public static EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, int[] attrib_list) { IntPtr ptr = eglCreateContext(dpy, config, share_context, attrib_list); if (ptr == IntPtr.Zero) throw new GraphicsContextException(String.Format("Failed to create EGL context, error: {0}.", Egl.GetError())); return ptr; }
static extern IntPtr eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, int[] attrib_list);
private static extern IntPtr eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, int[] attrib_list);