Ejemplo n.º 1
0
        public void KhronosApi_Extensions()
        {
            TestExtensions extensions = new TestExtensions();

            Assert.Throws <ArgumentNullException>(() => extensions.HasExtensions(null));
            Assert.Throws <ArgumentNullException>(() => extensions.Query(Gl.Version_100, (string)null));
            Assert.Throws <ArgumentNullException>(() => extensions.Query(Gl.Version_100, (string[])null));

            Assert.DoesNotThrow(() => extensions.Query(Gl.Version_100, ""));
            Assert.DoesNotThrow(() => extensions.Query(null, ""));
            Assert.DoesNotThrow(() => extensions.Query(null, "   "));

            // Defaults to false
            Assert.IsFalse(extensions.HasExtensions("GL_EXT_1"));
            Assert.IsFalse(extensions.Ext1);
            Assert.IsFalse(extensions.HasExtensions("GL_EXT_2"));
            Assert.IsFalse(extensions.Ext2);
            Assert.IsFalse(extensions.HasExtensions("GL_EXT_3"));
            Assert.IsFalse(extensions.Ext3);
            Assert.IsFalse(extensions.Ext);
            Assert.IsFalse(extensions.Core1);
            Assert.IsFalse(extensions.Core2);
            Assert.IsFalse(extensions.Core3);

            // Filter by API
            extensions.Query(Gl.Version_100, "GL_EXT_1 GL_EXT_2 GL_EXT_3");
            Assert.IsTrue(extensions.HasExtensions("GL_EXT_1"));
            Assert.IsTrue(extensions.Ext1);
            Assert.IsTrue(extensions.HasExtensions("GL_EXT_2"));                                                // Extension listed as supported!
            Assert.IsFalse(extensions.Ext2);                                                                    // ...but field is filtered by API ('gl' in this case) (*)
            Assert.IsTrue(extensions.HasExtensions("GL_EXT_3"));
            Assert.IsTrue(extensions.Ext3);
            Assert.IsTrue(extensions.Ext);
            Assert.IsFalse(extensions.Core1);
            Assert.IsFalse(extensions.Core2);
            Assert.IsFalse(extensions.Core3);

            // (*) This should happen when the extensions string is coherent with the GL context version

            extensions.Query(Gl.Version_200_ES, "GL_EXT_1 GL_EXT_2 GL_EXT_3");
            Assert.IsTrue(extensions.HasExtensions("GL_EXT_1"));
            Assert.IsFalse(extensions.Ext1);
            Assert.IsTrue(extensions.HasExtensions("GL_EXT_2"));
            Assert.IsTrue(extensions.Ext2);
            Assert.IsTrue(extensions.HasExtensions("GL_EXT_3"));
            Assert.IsTrue(extensions.Ext3);
            Assert.IsTrue(extensions.Ext);
            Assert.IsFalse(extensions.Core1);
            Assert.IsFalse(extensions.Core2);
            Assert.IsFalse(extensions.Core3);

            extensions.Query(Gl.Version_100, "GL_EXT_2");
            Assert.IsFalse(extensions.HasExtensions("GL_EXT_1"));
            Assert.IsFalse(extensions.Ext1);
            Assert.IsTrue(extensions.HasExtensions("GL_EXT_2"));
            Assert.IsFalse(extensions.Ext2);
            Assert.IsFalse(extensions.HasExtensions("GL_EXT_3"));
            Assert.IsFalse(extensions.Ext3);
            Assert.IsFalse(extensions.Ext);
            Assert.IsFalse(extensions.Core1);
            Assert.IsFalse(extensions.Core2);
            Assert.IsFalse(extensions.Core3);

            // Filter by version
            extensions.Query(Gl.Version_320, "");
            Assert.IsFalse(extensions.HasExtensions("GL_EXT_1"));
            Assert.IsFalse(extensions.Ext1);
            Assert.IsFalse(extensions.HasExtensions("GL_EXT_2"));
            Assert.IsFalse(extensions.Ext2);
            Assert.IsFalse(extensions.HasExtensions("GL_EXT_3"));
            Assert.IsFalse(extensions.Ext3);
            Assert.IsFalse(extensions.Ext);
            Assert.IsTrue(extensions.Core1);
            Assert.IsFalse(extensions.Core2);
            Assert.IsTrue(extensions.Core3);

            extensions.Query(Gl.Version_320_ES, "");
            Assert.IsFalse(extensions.HasExtensions("GL_EXT_1"));
            Assert.IsFalse(extensions.Ext1);
            Assert.IsFalse(extensions.HasExtensions("GL_EXT_2"));
            Assert.IsFalse(extensions.Ext2);
            Assert.IsFalse(extensions.HasExtensions("GL_EXT_3"));
            Assert.IsFalse(extensions.Ext3);
            Assert.IsFalse(extensions.Ext);
            Assert.IsFalse(extensions.Core1);
            Assert.IsTrue(extensions.Core2);
            Assert.IsTrue(extensions.Core3);

            // Duplicated extension are managed nicely
            Assert.DoesNotThrow(() => extensions.Query(null, "GL_EXT_3 GL_EXT_3 GL_EXT_3"));

            // Mixed attributes
            extensions.Query(Gl.Version_100, "");
            Assert.IsFalse(extensions.Mixed);

            extensions.Query(Gl.Version_320, "");
            Assert.IsTrue(extensions.Mixed);

            extensions.Query(Gl.Version_100, "GL_EXT_3");
            Assert.IsTrue(extensions.Mixed);
        }