コード例 #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;
            }
        }
コード例 #2
0
        private void DeviceContext_CreateContext_DefaultAPI_Core(string api)
        {
            using (Device device = new Device())
            {
                DeviceContext deviceContext = device.Context;
                List <string> availableAPIs = new List <string>(deviceContext.AvailableAPIs);

                if (availableAPIs.Contains(api) == false)
                {
                    Assert.Inconclusive("underlying device is unable to support '" + api + "'");
                }

                if (deviceContext.IsPixelFormatSet == false)
                {
                    deviceContext.ChoosePixelFormat(new DevicePixelFormat(24));
                }

                IntPtr glContext = deviceContext.CreateContext(IntPtr.Zero);
                Assert.AreNotEqual(IntPtr.Zero, glContext);

                try {
                    if (deviceContext.MakeCurrent(glContext) == false)
                    {
                        Assert.Fail("unable to make current");
                    }

                    string         glVersionString = Gl.GetString(StringName.Version);
                    KhronosVersion glVersion       = KhronosVersion.Parse(glVersionString);

                    switch (api)
                    {
                    case KhronosVersion.ApiGlsc2:
                        // SC2 is a special case: based on ES2
                        Assert.AreEqual(KhronosVersion.ApiGles2, glVersion.Api);
                        break;

                    default:
                        Assert.AreEqual(api, glVersion.Api);
                        break;
                    }

                    deviceContext.MakeCurrent(IntPtr.Zero);
                } finally {
                    if (glContext != IntPtr.Zero)
                    {
                        deviceContext.DeleteContext(glContext);
                    }
                }
            }
        }
コード例 #3
0
ファイル: KhronosVersion.cs プロジェクト: ipud2/OpenGL.Net-1
        public void KhronosVersion_Parse1()
        {
            Assert.Throws <ArgumentNullException>(() => KhronosVersion.Parse(null));
            Assert.Throws <ArgumentException>(() => KhronosVersion.Parse("3"));
            Assert.Throws <ArgumentException>(() => KhronosVersion.Parse("4a"));

            KhronosVersion v;

            // Parse x.y
            v = KhronosVersion.Parse("3.2");
            Assert.AreEqual(3, v.Major);
            Assert.AreEqual(2, v.Minor);
            Assert.AreEqual(0, v.Revision);
            Assert.AreEqual(KhronosVersion.ApiGl, v.Api);
            Assert.AreEqual(null, v.Profile);

            // Parse x.y.z
            v = KhronosVersion.Parse("1.2.1");
            Assert.AreEqual(1, v.Major);
            Assert.AreEqual(2, v.Minor);
            Assert.AreEqual(1, v.Revision);
            Assert.AreEqual(KhronosVersion.ApiGl, v.Api);
            Assert.AreEqual(null, v.Profile);

            // Parse x.y.z ES
            v = KhronosVersion.Parse("2.0.17 ES");
            Assert.AreEqual(2, v.Major);
            Assert.AreEqual(0, v.Minor);
            Assert.AreEqual(17, v.Revision);
            Assert.AreEqual(KhronosVersion.ApiGles2, v.Api);
            Assert.AreEqual(null, v.Profile);

            // Parse 1.y.z ES
            v = KhronosVersion.Parse("1.0 ES");
            Assert.AreEqual(1, v.Major);
            Assert.AreEqual(0, v.Minor);
            Assert.AreEqual(0, v.Revision);
            Assert.AreEqual(KhronosVersion.ApiGles1, v.Api);
            Assert.AreEqual(null, v.Profile);

            // Parse x.yz
            v = KhronosVersion.Parse("4.50");
            Assert.AreEqual(4, v.Major);
            Assert.AreEqual(5, v.Minor);
            Assert.AreEqual(0, v.Revision);
            Assert.AreEqual(KhronosVersion.ApiGl, v.Api);
            Assert.AreEqual(null, v.Profile);
        }
コード例 #4
0
        public void KhronosVersion_Parse2()
        {
            KhronosVersion v;

            // Parse x.y
            v = KhronosVersion.Parse("1.4", KhronosVersion.ApiEgl);
            Assert.AreEqual(1, v.Major);
            Assert.AreEqual(4, v.Minor);
            Assert.AreEqual(0, v.Revision);
            Assert.AreEqual(KhronosVersion.ApiEgl, v.Api);
            Assert.AreEqual(null, v.Profile);

            // Parse x.y.z
            v = KhronosVersion.Parse("1.5.14", KhronosVersion.ApiEgl);
            Assert.AreEqual(1, v.Major);
            Assert.AreEqual(5, v.Minor);
            Assert.AreEqual(14, v.Revision);
            Assert.AreEqual(KhronosVersion.ApiEgl, v.Api);
            Assert.AreEqual(null, v.Profile);
        }
コード例 #5
0
        public void TestParse1()
        {
            KhronosVersion v;

            // Parse x.y
            v = KhronosVersion.Parse("3.2");
            Assert.AreEqual(3, v.Major);
            Assert.AreEqual(2, v.Minor);
            Assert.AreEqual(0, v.Revision);
            Assert.AreEqual(KhronosVersion.ApiGl, v.Api);
            Assert.AreEqual(null, v.Profile);

            // Parse x.y.z
            v = KhronosVersion.Parse("1.2.1");
            Assert.AreEqual(1, v.Major);
            Assert.AreEqual(2, v.Minor);
            Assert.AreEqual(1, v.Revision);
            Assert.AreEqual(KhronosVersion.ApiGl, v.Api);
            Assert.AreEqual(null, v.Profile);
        }
コード例 #6
0
        public new void FixtureSetUp()
        {
            try {
                // Create context
                _Context = CreateContext();

                // 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
                switch (Environment.OSVersion.Platform)
                {
                case PlatformID.Win32Windows:
                case PlatformID.Win32NT:
                    _WglExtensions.Query((WindowsDeviceContext)_DeviceContext);
                    break;

                case PlatformID.Unix:
                    _GlxExtensions.Query((XServerDeviceContext)_DeviceContext);
                    break;
                }
            } catch {
                // Release resources manually
                FixtureTearDown();

                throw;
            }
        }
コード例 #7
0
ファイル: KhronosVersion.cs プロジェクト: ipud2/OpenGL.Net-1
        public void KhronosVersion_Parse2()
        {
            Assert.Throws <ArgumentNullException>(() => KhronosVersion.Parse(null, KhronosVersion.ApiEgl));

            KhronosVersion v;

            // Parse x.y
            v = KhronosVersion.Parse("1.4", KhronosVersion.ApiEgl);
            Assert.AreEqual(1, v.Major);
            Assert.AreEqual(4, v.Minor);
            Assert.AreEqual(0, v.Revision);
            Assert.AreEqual(KhronosVersion.ApiEgl, v.Api);
            Assert.AreEqual(null, v.Profile);

            // Parse x.y.z
            v = KhronosVersion.Parse("1.5.14", KhronosVersion.ApiEgl);
            Assert.AreEqual(1, v.Major);
            Assert.AreEqual(5, v.Minor);
            Assert.AreEqual(14, v.Revision);
            Assert.AreEqual(KhronosVersion.ApiEgl, v.Api);
            Assert.AreEqual(null, v.Profile);
        }
コード例 #8
0
        public void KhronosVersion_Parse1()
        {
            KhronosVersion v;

            // Parse x.y
            v = KhronosVersion.Parse("3.2");
            Assert.AreEqual(3, v.Major);
            Assert.AreEqual(2, v.Minor);
            Assert.AreEqual(0, v.Revision);
            Assert.AreEqual(KhronosVersion.ApiGl, v.Api);
            Assert.AreEqual(null, v.Profile);

            // Parse x.y.z
            v = KhronosVersion.Parse("1.2.1");
            Assert.AreEqual(1, v.Major);
            Assert.AreEqual(2, v.Minor);
            Assert.AreEqual(1, v.Revision);
            Assert.AreEqual(KhronosVersion.ApiGl, v.Api);
            Assert.AreEqual(null, v.Profile);

            // Parse x.y.z ES
            v = KhronosVersion.Parse("2.0.17 ES");
            Assert.AreEqual(2, v.Major);
            Assert.AreEqual(0, v.Minor);
            Assert.AreEqual(17, v.Revision);
            Assert.AreEqual(KhronosVersion.ApiGles2, v.Api);
            Assert.AreEqual(null, v.Profile);

            // Parse x.y.z ES
            v = KhronosVersion.Parse("4.50");
            Assert.AreEqual(4, v.Major);
            Assert.AreEqual(5, v.Minor);
            Assert.AreEqual(0, v.Revision);
            Assert.AreEqual(KhronosVersion.ApiGl, v.Api);
            Assert.AreEqual(null, v.Profile);
        }
コード例 #9
0
 public void KhronosVersion_Parse2_ArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => KhronosVersion.Parse(null, KhronosVersion.ApiEgl));
 }
コード例 #10
0
 public void KhronosVersion_Parse1_ArgumentException(string pattern)
 {
     Assert.Throws <ArgumentException>(() => KhronosVersion.Parse(pattern));
 }
コード例 #11
0
 public void TestParse1_ArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => KhronosVersion.Parse(null));
 }
コード例 #12
0
 public void TestParse2_ArgumentNullException()
 {
     KhronosVersion.Parse(null, KhronosVersion.ApiEgl);
 }
コード例 #13
0
 public void TestParse1_ArgumentException(string pattern)
 {
     KhronosVersion.Parse(pattern);
 }
コード例 #14
0
 public void TestParse1_ArgumentNullException()
 {
     KhronosVersion.Parse(null);
 }