Esempio n. 1
0
		/// <summary>
		/// Static constructor.
		/// </summary>
		static GetProcAddress()
		{
			PlatformID pId = Environment.OSVersion.Platform;

			// Determine GetOpenGLProcAddress implementation
			if ((pId == PlatformID.Win32NT) || (pId == PlatformID.Win32S) || (pId == PlatformID.Win32Windows) || (pId == PlatformID.WinCE)) {
				sGetProcAddress = new GetProcAddressWindows();
			} else if ((pId == PlatformID.Unix) || (pId == (PlatformID)4)) {
				string pIdString = DetectUnixKernel();

				// Distinguish between Unix and Mac OS X kernels.
				switch (pIdString) {
				case "Unix":
				case "Linux":
					sGetProcAddress = new GetProcAddressX11();
					break;
				case "Darwin":
					sGetProcAddress = new GetProcAddressOSX();
					break;
				default:
					throw new PlatformNotSupportedException(pIdString + ": unknown Unix platform - cannot load extensions");
				}
			} else {
				throw new PlatformNotSupportedException("extension loading is only supported under Mac OS X, Unix/X11 and Windows");
			}
		}
Esempio n. 2
0
        /// <summary>
        /// Static constructor.
        /// </summary>
        static GetProcAddress()
        {
            PlatformID pId = Environment.OSVersion.Platform;

            // Determine GetOpenGLProcAddress implementation
            if ((pId == PlatformID.Win32NT) || (pId == PlatformID.Win32S) || (pId == PlatformID.Win32Windows) || (pId == PlatformID.WinCE))
            {
                _GetProcAddress = new GetProcAddressWindows();
            }
            else if ((pId == PlatformID.Unix) || (pId == (PlatformID)4))
            {
                string pIdString = DetectUnixKernel();

                // Distinguish between Unix and Mac OS X kernels.
                switch (pIdString)
                {
                case "Unix":
                case "Linux":
                    _GetProcAddress = new GetProcAddressX11();
                    break;

                case "Darwin":
                    _GetProcAddress = new GetProcAddressOSX();
                    break;
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Static constructor.
        /// </summary>
        static GetProcAddress()
        {
            switch (Environment.OSVersion.Platform)
            {
            case PlatformID.Win32NT:
            case PlatformID.Win32Windows:
            case PlatformID.Win32S:
            case PlatformID.WinCE:
                _GetProcAddress = new GetProcAddressWindows();
                break;

            case PlatformID.Unix:
                string unixName = DetectUnixKernel();

                // Distinguish between Unix and Mac OS X kernels.
                switch (unixName)
                {
                case "Unix":
                case "Linux":
                    _GetProcAddress = new GetProcAddressX11();
                    break;

                case "Darwin":
                    _GetProcAddress = new GetProcAddressOSX();
                    break;

                case null:
                    throw new NotSupportedException(String.Format("Unix platform not detected"));

                default:
                    throw new NotSupportedException(String.Format("Unix platform {0} not supported", unixName));
                }
                break;

            case PlatformID.MacOSX:
                _GetProcAddress = new GetProcAddressOSX();
                break;

            default:
                throw new NotSupportedException(String.Format("platform {0} not supported", Environment.OSVersion.Platform));
            }
        }
Esempio n. 4
0
		/// <summary>
		/// Static constructor.
		/// </summary>
		static GetProcAddress()
		{
			PlatformID pId = Environment.OSVersion.Platform;

			// Determine GetOpenGLProcAddress implementation
			if ((pId == PlatformID.Win32NT) || (pId == PlatformID.Win32S) || (pId == PlatformID.Win32Windows) || (pId == PlatformID.WinCE)) {
				_GetProcAddress = new GetProcAddressWindows();
			} else if ((pId == PlatformID.Unix) || (pId == (PlatformID)4)) {
				string pIdString = DetectUnixKernel();

				// Distinguish between Unix and Mac OS X kernels.
				switch (pIdString) {
				case "Unix":
				case "Linux":
					_GetProcAddress = new GetProcAddressX11();
					break;
				case "Darwin":
					_GetProcAddress = new GetProcAddressOSX();
					break;
				}
			}
		}
Esempio n. 5
0
        /// <summary>
        /// Initialize OpenGL namespace static environment. This method shall be called before any other classes methods.
        /// </summary>
        public static void Initialize()
        {
            if (_Initialized == true)
            {
                return;                 // Already initialized
            }
            _Initialized = true;

            // Before linking procedures, append ANGLE directory in path
            string assemblyPath = Path.GetDirectoryName(Assembly.GetAssembly(typeof(Egl)).Location);
            string anglePath    = null;

            switch (Platform.CurrentPlatformId)
            {
            case Platform.Id.WindowsNT:
#if DEBUG
                if (IntPtr.Size == 8)
                {
                    anglePath = Path.Combine(assemblyPath, @"ANGLE\winrt10d\x64");
                }
                else
                {
                    anglePath = Path.Combine(assemblyPath, @"ANGLE\winrt10d\x86");
                }
#else
                if (IntPtr.Size == 8)
                {
                    anglePath = Path.Combine(assemblyPath, @"ANGLE\winrt10\x64");
                }
                else
                {
                    anglePath = Path.Combine(assemblyPath, @"ANGLE\winrt10\x86");
                }
#endif
                break;

            case Platform.Id.Linux:
                // Note: on RPi libEGL.so depends on libGLESv2.so, so it's required to pre-load the shared library
                GetProcAddressX11.GetLibraryHandle("libGLESv2.so", false);
                break;
            }

            // Include ANGLE path, if any
            if (anglePath != null && Directory.Exists(anglePath))
            {
                OpenGL.GetProcAddress.GetProcAddressOS.AddLibraryDirectory(Path.Combine(assemblyPath, anglePath));
            }

            // Load procedures
            string platformLibrary = GetPlatformLibrary();
            try {
                LogComment("Querying EGL from {0}", platformLibrary);
                BindAPI <Egl>(platformLibrary, OpenGL.GetProcAddress.GetProcAddressOS);
                LogComment("EGL availability: {0}", IsAvailable);
            } catch (Exception exception) {
                /* Fail-safe (it may fail due Egl access) */
                LogComment("EGL not available:\n{0}", exception.ToString());
            }

            if (IsAvailable == false)
            {
                return;
            }

#if DEBUG
            string envEglInit = Environment.GetEnvironmentVariable("EGL_INIT");

            if (envEglInit != null && envEglInit == "NO")
            {
                return;
            }
#endif

            // Platform initialization
            EglEventArgs args = new EglEventArgs();

            RaiseEglInitializing(args);

            // Get EGL information
            IntPtr eglDisplay = Egl.GetDisplay(args.Display);

            try {
                if (Initialize(eglDisplay, null, null) == false)
                {
                    throw new InvalidOperationException("unable to initialize EGL");
                }

                // Query EGL version
                string eglVersionString = QueryString(eglDisplay, VERSION);
                _CurrentVersion = KhronosVersion.Parse(eglVersionString, KhronosVersion.ApiEgl);
                // Query EGL vendor
                _Vendor = QueryString(eglDisplay, VENDOR);
                // Client APIs
                if (_CurrentVersion >= Version_120)
                {
                    string clientApisString = QueryString(eglDisplay, CLIENT_APIS);
                    _AvailableApis = System.Text.RegularExpressions.Regex.Split(clientApisString, " ");
                }
            } finally {
                Terminate(eglDisplay);
            }
        }