Esempio n. 1
0
        /// <summary>
        /// Get the OpenGL context current on the calling thread.
        /// </summary>
        /// <returns>
        /// It returns the handle of the OpenGL context current on the calling thread. It may return <see cref="IntPtr.Zero"/>
        /// indicating that no OpenGL context is current.
        /// </returns>
        public static IntPtr GetCurrentContext()
        {
            if (Egl.IsRequired == false)
            {
                switch (Platform.CurrentPlatformId)
                {
                case Platform.Id.WindowsNT:
                    return(Wgl.GetCurrentContext());

                case Platform.Id.Linux:
                    return(Glx.GetCurrentContext());

                case Platform.Id.MacOS:
                    if (Glx.IsRequired)
                    {
                        return(Glx.GetCurrentContext());
                    }
                    else
                    {
                        throw new NotSupportedException("platform MacOS not supported without Glx.IsRequired=true");
                    }

                default:
                    throw new NotSupportedException(String.Format("platform {0} not supported", Platform.CurrentPlatformId));
                }
            }
            else
            {
                return(Egl.GetCurrentContext());
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Get the OpenGL context current on the calling thread.
        /// </summary>
        /// <returns>
        /// It returns the handle of the OpenGL context current on the calling thread. It may return <see cref="IntPtr.Zero"/>
        /// indicating that no OpenGL context is current.
        /// </returns>
        public static IntPtr GetCurrentContext()
        {
#if !MONODROID
            if (!Egl.IsRequired)
            {
                switch (Platform.CurrentPlatformId)
                {
                case Platform.Id.WindowsNT:
                    return(Wgl.GetCurrentContext());

                case Platform.Id.Linux:
                    return(Glx.GetCurrentContext());

                case Platform.Id.MacOS:
                    if (Glx.IsRequired)
                    {
                        return(Glx.GetCurrentContext());
                    }
                    else
                    {
                        throw new NotSupportedException("platform MacOS not supported without Glx.IsRequired=true");
                    }

                default:
                    throw new NotSupportedException($"platform {Platform.CurrentPlatformId} not supported");
                }
            }
            else
#endif
            return(Egl.GetCurrentContext());
        }