示例#1
0
        public void MixedAttributes()
        {
            var glsl = @"
in uint a;
in int b;
in float c;
in vec2 d;
in vec3 e;
in vec4 f;
in uvec2 g;
in uvec3 h;
in uvec4 i;
in ivec2 j;
in ivec3 k;
in ivec4 l;";

            CollectionAssert.AreEqual(new List <ShaderAttribute>
            {
                new ShaderAttribute("a", AttributeType.UnsignedInt),
                new ShaderAttribute("b", AttributeType.Int),
                new ShaderAttribute("c", AttributeType.Float),
                new ShaderAttribute("d", AttributeType.Vec2),
                new ShaderAttribute("e", AttributeType.Vec3),
                new ShaderAttribute("f", AttributeType.Vec4),
                new ShaderAttribute("g", AttributeType.UVec2),
                new ShaderAttribute("h", AttributeType.UVec3),
                new ShaderAttribute("i", AttributeType.UVec4),
                new ShaderAttribute("j", AttributeType.IVec2),
                new ShaderAttribute("k", AttributeType.IVec3),
                new ShaderAttribute("l", AttributeType.IVec4),
            }, GlslParsing.GetAttributes(glsl));
        }
示例#2
0
        public void SingleUniform()
        {
            var glsl = "uniform float float1;";

            CollectionAssert.AreEqual(new List <ShaderUniform>
            {
                new ShaderUniform("float1", UniformType.Float),
            }, GlslParsing.GetUniforms(glsl));
        }
示例#3
0
        public void SingleAttribute()
        {
            var glsl = "in float float1;";

            CollectionAssert.AreEqual(new List <ShaderAttribute>
            {
                new ShaderAttribute("float1", AttributeType.Float),
            }, GlslParsing.GetAttributes(glsl));
        }
示例#4
0
        public void MatrixUniforms()
        {
            var glsl = @"
uniform mat3 var1;
uniform mat4 var2;";

            CollectionAssert.AreEqual(new List <ShaderUniform>
            {
                new ShaderUniform("var1", UniformType.Mat3),
                new ShaderUniform("var2", UniformType.Mat4),
            }, GlslParsing.GetUniforms(glsl));
        }
示例#5
0
        public void IVecUniforms()
        {
            var glsl = @"
uniform ivec2 var1;
uniform ivec3 var2;
uniform ivec4 var3;";

            CollectionAssert.AreEqual(new List <ShaderUniform>
            {
                new ShaderUniform("var1", UniformType.IVec2),
                new ShaderUniform("var2", UniformType.IVec3),
                new ShaderUniform("var3", UniformType.IVec4),
            }, GlslParsing.GetUniforms(glsl));
        }
示例#6
0
        public void UniformBlock()
        {
            var glsl = @"
uniform MaterialParams
{
    vec4 CustomVector[64];
    ivec4 CustomBoolean[20];
    vec4 CustomFloat[20];
    vec4 vec4Param;
};";

            // Uniform blocks will have to be handled separately.
            CollectionAssert.AreEqual(new List <ShaderUniform>(), GlslParsing.GetUniforms(glsl));
        }
示例#7
0
        public void MixedUniforms()
        {
            var glsl = @"
uniform sampler2D texture1;
uniform float float1;
uniform int int1;
uniform vec2 vector1;
uniform vec3 vector2;
uniform vec4 vector4;
uniform samplerCube cubeMap1;";

            CollectionAssert.AreEqual(new List <ShaderUniform>
            {
                new ShaderUniform("texture1", UniformType.Sampler2D),
                new ShaderUniform("float1", UniformType.Float),
                new ShaderUniform("int1", UniformType.Int),
                new ShaderUniform("vector1", UniformType.Vec2),
                new ShaderUniform("vector2", UniformType.Vec3),
                new ShaderUniform("vector4", UniformType.Vec4),
                new ShaderUniform("cubeMap1", UniformType.SamplerCube)
            }, GlslParsing.GetUniforms(glsl));
        }
示例#8
0
        public void MissingSemicolon()
        {
            var glsl = "uniform float float1";

            CollectionAssert.AreEqual(new List <ShaderUniform>(), GlslParsing.GetUniforms(glsl));
        }
示例#9
0
        public void EmptySource()
        {
            var glsl = "";

            CollectionAssert.AreEqual(new List <ShaderUniform>(), GlslParsing.GetUniforms(glsl));
        }
示例#10
0
        public void MissingTypeDescription()
        {
            var glsl = "in a";

            CollectionAssert.AreEqual(new List <ShaderAttribute>(), GlslParsing.GetAttributes(glsl));
        }
示例#11
0
        public void MissingSemicolon()
        {
            var glsl = "in vec3 a";

            CollectionAssert.AreEqual(new List <ShaderAttribute>(), GlslParsing.GetAttributes(glsl));
        }
示例#12
0
        public void EmptySource()
        {
            var glsl = "";

            CollectionAssert.AreEqual(new List <ShaderAttribute>(), GlslParsing.GetAttributes(glsl));
        }