public SelectGraphicsMode ( |
||
color | ||
depth | int | |
stencil | int | |
samples | int | |
accum | ||
buffers | int | |
stereo | bool | |
return | OpenTK.Graphics.GraphicsMode |
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; Egl.BindAPI(0x30A0); //bind EGL_OPENGL_ES_API var eglGfxMode = new EglGraphicsMode(); eglGfxMode.window = window; Mode = eglGfxMode.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."); IntPtr config = Mode.Index.Value; if (window.Surface == IntPtr.Zero) window.CreateWindowSurface(config); int[] attrib_list = new int[] { //key,value Egl.CONTEXT_CLIENT_VERSION, major, Egl.NONE }; HandleAsEGLContext = Egl.CreateContext(window.Display, config, shared != null ? shared.HandleAsEGLContext : IntPtr.Zero, attrib_list); MakeCurrent(window); }
bool vsync = true; // Default vsync value is defined as 1 (true) in EGL. 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; //old version EglContext shared = sharedContext as EglContext; 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; Egl.BindAPI(0x30A0); //bind EGL_OPENGL_ES_API var eglGfxMode = new EglGraphicsMode(); eglGfxMode.window = window; Mode = eglGfxMode.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."); } IntPtr config = Mode.Index.Value; if (window.Surface == IntPtr.Zero) { window.CreateWindowSurface(config); } int[] attrib_list = new int[] { //key,value Egl.CONTEXT_CLIENT_VERSION, major, Egl.NONE }; HandleAsEGLContext = Egl.CreateContext(window.Display, config, shared != null ? shared.HandleAsEGLContext : IntPtr.Zero, attrib_list); MakeCurrent(window); }