Ejemplo n.º 1
0
        public new void FixtureSetUp()
        {
            try {
                // Create compatibility profile context
                if ((_Context = _DeviceContext.CreateContext(IntPtr.Zero)) == IntPtr.Zero)
                {
                    throw new InvalidOperationException("unable to create compatibility profile OpenGL context");
                }

                // Make OpenGL context current
                if (_DeviceContext.MakeCurrent(_Context) == false)
                {
                    throw new InvalidOperationException("unable to make current the OpenGL context");
                }

                // Get OpenGL version
                if ((_VersionString = Gl.GetString(StringName.Version)) == null)
                {
                    throw new InvalidOperationException("unable to get the OpenGL version");
                }
                // Extract OpenGL version numbers
                _Version = KhronosVersion.Parse(_VersionString);
                // Get OpenGL extensions
                _GlExtensions.Query();
                // Get OpenGL window system extensions
                // Windows OpenGL extensions
                DeviceContextWGL windowsDeviceContext = _DeviceContext as DeviceContextWGL;
                if (windowsDeviceContext != null)
                {
                    _WglExtensions.Query(windowsDeviceContext);
                }
                // GLX OpenGL extensions
                DeviceContextGLX xserverDeviceContext = _DeviceContext as DeviceContextGLX;
                if (xserverDeviceContext != null)
                {
                    _GlxExtensions.Query(xserverDeviceContext);
                }
                // EGL OpenGL extensions
                DeviceContextEGL nativeDeviceContext = _DeviceContext as DeviceContextEGL;
                if (nativeDeviceContext != null)
                {
                    _EglExtensions.Query(nativeDeviceContext);
                }
            } catch (Exception exception) {
                Console.WriteLine("Unable to initialize Fixture for OpenGL: " + exception.ToString());

                // Release resources manually
                FixtureTearDown();
                throw;
            }
        }