예제 #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);
        }
예제 #2
0
 public void CreateWindowSurface(EGLConfig config)
 {
     Surface = Egl.CreateWindowSurface(Display, config, Handle, null);
     int error = Egl.GetError();
     if (error != Egl.SUCCESS)
         throw new GraphicsContextException(String.Format("[Error] Failed to create EGL window surface, error {0}.", error));
 }
예제 #3
0
        public static EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, IntPtr win, int[] attrib_list)
        {
            IntPtr ptr = eglCreateWindowSurface(dpy, config, win, attrib_list);

            EGLSurface ret = new EGLSurface(ptr);

            return(ret);
        }
예제 #4
0
        public void CreateWindowSurface(EGLConfig config)
        {
            Surface = Egl.CreateWindowSurface(Display, config, Handle, null);
            int error = Egl.GetError();

            if (error != Egl.SUCCESS)
            {
                throw new GraphicsContextException(String.Format("[Error] Failed to create EGL window surface, error {0}.", error));
            }
        }
        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);
        }
예제 #6
0
        public GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil, int samples, ColorFormat accum, int buffers, bool stereo)
        {
            EGLConfig[] configs = new EGLConfig[1];
            int[] attribList = new int[] 
            { 
                //Egl.SURFACE_TYPE, Egl.WINDOW_BIT,

                Egl.RED_SIZE, color.Red, 
                Egl.GREEN_SIZE, color.Green, 
                Egl.BLUE_SIZE, color.Blue,
                Egl.ALPHA_SIZE, color.Alpha,

                Egl.DEPTH_SIZE, depth > 0 ? depth : 0,
                Egl.STENCIL_SIZE, stencil > 0 ? stencil : 0,

                //Egl.SAMPLE_BUFFERS, samples > 0 ? 1 : 0,
                Egl.SAMPLES, samples > 0 ? samples : 0,

                Egl.NONE,
            };

            // Todo: what if we don't wish to use the default display?
            EGLDisplay display = Egl.GetDisplay(EGLNativeDisplayType.Default);
            int major, minor;
            if (!Egl.Initialize(display, out major, out minor))
                throw new GraphicsModeException(String.Format("Failed to initialize display connection, error {0}", Egl.GetError()));

            int num_configs;
            if (!Egl.GetConfigs(display, null, 0, out num_configs))
            {
                throw new GraphicsModeException(String.Format("Failed to retrieve GraphicsMode configurations, error {0}", Egl.GetError()));
            }

            if (!Egl.ChooseConfig(display, attribList, configs, configs.Length, out num_configs))
            {
                throw new GraphicsModeException(String.Format("Failed to retrieve GraphicsMode, error {0}", Egl.GetError()));
            }

            // See what we really got
            EGLConfig active_config = configs[0];
            int r, g, b, a;
            Egl.GetConfigAttrib(display, active_config, Egl.RED_SIZE, out r);
            Egl.GetConfigAttrib(display, active_config, Egl.GREEN_SIZE, out g);
            Egl.GetConfigAttrib(display, active_config, Egl.BLUE_SIZE, out b);
            Egl.GetConfigAttrib(display, active_config, Egl.ALPHA_SIZE, out a);
            int d, s;
            Egl.GetConfigAttrib(display, active_config, Egl.DEPTH_SIZE, out d);
            Egl.GetConfigAttrib(display, active_config, Egl.STENCIL_SIZE, out s);
            int sample_buffers;
            Egl.GetConfigAttrib(display, active_config, Egl.SAMPLES, out sample_buffers);
            Egl.GetConfigAttrib(display, active_config, Egl.SAMPLES, out samples);

            return new GraphicsMode(active_config.Handle.Value, new ColorFormat(r, g, b, a), d, s, sample_buffers > 0 ? samples : 0, 0, 2, false);
        }
예제 #7
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);
        }
예제 #8
0
파일: Egl.cs 프로젝트: White-Wolf/Minesharp
 public static extern bool GetConfigAttrib(EGLDisplay dpy, EGLConfig config, int attribute, out int value);
예제 #9
0
파일: Egl.cs 프로젝트: White-Wolf/Minesharp
 public static extern bool GetConfigs(EGLDisplay dpy, EGLConfig[] configs, int config_size, out int num_config);
예제 #10
0
파일: Egl.cs 프로젝트: hobum-kwon/opentk
 public static extern EGLSurface CreatePlatformPixmapSurfaceEXT(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType native_pixmap, int[] attrib_list);
 static extern IntPtr eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, int[] attrib_list);
 public static extern EGLSurface CreatePbufferFromClientBuffer(EGLDisplay dpy, int buftype, EGLClientBuffer buffer, EGLConfig config, int[] attrib_list);
 public static extern EGLSurface CreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, int[] attrib_list);
 public static extern EGLSurface CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, int[] attrib_list);
예제 #15
0
파일: Egl.cs 프로젝트: hobum-kwon/opentk
 public static extern EGLSurface CreatePlatformWindowSurfaceEXT(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType native_window, int[] attrib_list);
예제 #16
0
파일: Egl.cs 프로젝트: White-Wolf/Minesharp
 static extern IntPtr eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, int[] attrib_list);
예제 #17
0
파일: Egl.cs 프로젝트: White-Wolf/Minesharp
 public static extern EGLSurface CreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, int[] attrib_list);
예제 #18
0
파일: Egl.cs 프로젝트: White-Wolf/Minesharp
 public static extern  EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, IntPtr win, int[] attrib_list);
예제 #19
0
        public GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil, int samples, ColorFormat accum, int buffers, bool stereo)
        {
            EGLConfig[] configs    = new EGLConfig[1];
            int[]       attribList = new int[]
            {
                //Egl.SURFACE_TYPE, Egl.WINDOW_BIT,

                Egl.RED_SIZE, color.Red,
                Egl.GREEN_SIZE, color.Green,
                Egl.BLUE_SIZE, color.Blue,
                Egl.ALPHA_SIZE, color.Alpha,

                Egl.DEPTH_SIZE, depth > 0 ? depth : 0,
                Egl.STENCIL_SIZE, stencil > 0 ? stencil : 0,

                //Egl.SAMPLE_BUFFERS, samples > 0 ? 1 : 0,
                Egl.SAMPLES, samples > 0 ? samples : 0,

                Egl.NONE,
            };

            // Todo: what if we don't wish to use the default display?
            EGLDisplay display = Egl.GetDisplay(EGLNativeDisplayType.Default);
            int        major, minor;

            if (!Egl.Initialize(display, out major, out minor))
            {
                throw new GraphicsModeException(String.Format("Failed to initialize display connection, error {0}", Egl.GetError()));
            }

            int num_configs;

            if (!Egl.GetConfigs(display, null, 0, out num_configs))
            {
                throw new GraphicsModeException(String.Format("Failed to retrieve GraphicsMode configurations, error {0}", Egl.GetError()));
            }

            if (!Egl.ChooseConfig(display, attribList, configs, configs.Length, out num_configs))
            {
                throw new GraphicsModeException(String.Format("Failed to retrieve GraphicsMode, error {0}", Egl.GetError()));
            }

            // See what we really got
            EGLConfig active_config = configs[0];
            int       r, g, b, a;

            Egl.GetConfigAttrib(display, active_config, Egl.RED_SIZE, out r);
            Egl.GetConfigAttrib(display, active_config, Egl.GREEN_SIZE, out g);
            Egl.GetConfigAttrib(display, active_config, Egl.BLUE_SIZE, out b);
            Egl.GetConfigAttrib(display, active_config, Egl.ALPHA_SIZE, out a);
            int d, s;

            Egl.GetConfigAttrib(display, active_config, Egl.DEPTH_SIZE, out d);
            Egl.GetConfigAttrib(display, active_config, Egl.STENCIL_SIZE, out s);
            int sample_buffers;

            Egl.GetConfigAttrib(display, active_config, Egl.SAMPLES, out sample_buffers);
            Egl.GetConfigAttrib(display, active_config, Egl.SAMPLES, out samples);

            return(new GraphicsMode(active_config.Handle.Value, new ColorFormat(r, g, b, a), d, s, sample_buffers > 0 ? samples : 0, 0, 2, false));
        }
예제 #20
0
파일: Egl.cs 프로젝트: RockyTV/opentk
 public static extern EGLSurface CreatePlatformPixmapSurfaceEXT(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType native_pixmap, int[] attrib_list);
예제 #21
0
파일: Egl.cs 프로젝트: RockyTV/opentk
 public static extern EGLSurface CreatePlatformWindowSurfaceEXT(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType native_window, int[] attrib_list);
예제 #22
0
파일: Egl.cs 프로젝트: White-Wolf/Minesharp
 public static extern EGLSurface CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, int[] attrib_list);
예제 #23
0
 public static EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, IntPtr win, int[] attrib_list)
 {
     IntPtr ptr = eglCreateWindowSurface(dpy, config,  win, attrib_list);
     EGLSurface ret = new EGLSurface(ptr);
     return ret;
 }
예제 #24
0
파일: Egl.cs 프로젝트: White-Wolf/Minesharp
 public static extern EGLSurface CreatePbufferFromClientBuffer(EGLDisplay dpy, int buftype, EGLClientBuffer buffer, EGLConfig config, int[] attrib_list);
 public static extern bool GetConfigAttrib(EGLDisplay dpy, EGLConfig config, int attribute, out int value);
예제 #26
0
파일: Egl.cs 프로젝트: White-Wolf/Minesharp
 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;
 }
 public static extern EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, IntPtr win, int[] attrib_list);