Exemple #1
0
        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);
        }
Exemple #2
0
 public static extern bool QueryContext(EGLDisplay dpy, EGLContext ctx, int attribute, out int value);
Exemple #3
0
 public static extern bool MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
Exemple #4
0
 public static extern bool DestroyContext(EGLDisplay dpy, EGLContext ctx);
Exemple #5
0
 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;
 }
Exemple #6
0
 static extern IntPtr eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, int[] attrib_list);
Exemple #7
0
 public static extern bool QueryContext(EGLDisplay dpy, EGLContext ctx, int attribute, out int value);
Exemple #8
0
 public static extern bool MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
Exemple #9
0
 public static extern bool DestroyContext(EGLDisplay dpy, EGLContext ctx);
Exemple #10
0
 private static extern IntPtr eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context,
                                               int[] attrib_list);