Example #1
0
 public void TestStruct()
 {
     int expected = 1;
     IGLSLTypeLookup lookup = new OpenTKTypeLookup ();
     lookup.Initialize ();
     IGLSLUniformExtractor test = new GLSLUniformExtractor (lookup);
     test.Initialize ();
     int actual = test.Extract ("layout (std140, location = 1) struct LightProperties\n{\n\tvec3 direction;\n\tvec4 ambientColor;\n\tvec4 diffuseColor;\n\tvec4 specularColor;\n};");
     Assert.AreEqual (expected, actual);
     Assert.AreEqual (1, test.Blocks.Count);
 }
Example #2
0
 public void TestCase()
 {
     int expected = 1;
     IGLSLTypeLookup lookup = new OpenTKTypeLookup ();
     lookup.Initialize ();
     IGLSLUniformExtractor test = new GLSLUniformExtractor (lookup);
     test.Initialize ();
     int actual = test.Extract ("layout(std140) uniform UBOData {\n\tvec3 firstValue;\n\tfloat thirdValue;\n\tvec4 secondValue;\n};");
     Assert.AreEqual (expected, actual);
     Assert.AreEqual (1, test.Blocks.Count);
 }
Example #3
0
 public void TestAttributes()
 {
     int expected = 1;
     IGLSLTypeLookup lookup = new OpenTKTypeLookup ();
     lookup.Initialize ();
     IGLSLUniformExtractor test = new GLSLUniformExtractor (lookup);
     test.Initialize ();
     int actual = test.Extract ("layout (location = 1) in vec3 v_normal;");
     Assert.AreEqual (expected, actual);
     Assert.AreEqual (1, test.Attributes.Count);
 }
Example #4
0
        public static void Main(string[] args)
        {
            //var compiler = new Parser (new GLSLGrammar());

            //Debug.WriteLine(ParserDataPrinter.PrintStateList(compiler.Language));

            var lookup = new OpenTKTypeLookup ();
            lookup.Initialize ();
            var test = new GLSLUniformExtractor (lookup);
            test.Initialize ();
            test.DebugCode ("void main() { float in_position = 1.0; }");
        }
Example #5
0
        public static int Main(string[] args)
        {
            //			try
            //			{
                if (args.Length < 2)
                {
                    Console.WriteLine("Invalid arguments");
                    Console.WriteLine("{0} {1} {n}... ");
                    Console.WriteLine("{0} = output file");
                    Console.WriteLine("{1} = glsl shader file 1");
                    Console.WriteLine("{n} = glsl shader file n");
                    return 1;
                }

                foreach(var arg in args)
                {
                    Console.WriteLine(arg);
                }

                IGLSLTypeLookup lookup = new OpenTKTypeLookup ();
                lookup.Initialize ();
                var extractor = new GLSLUniformExtractor (lookup);
                extractor.Initialize ();

                var debug = new InfoSinkBase (SinkType.StdOut);
                var info = new InfoSinkBase (SinkType.StdOut);
                var infoSink = new InfoSink (info, debug);
                var preprocessor = InitialisePreprocessor (infoSink);

                for (int i = 1; i < args.Length; ++i)
                {
                    var fileName = args[i];
                    using (var fs = File.Open(fileName, FileMode.Open))
                    {
                        var stage = Standalone.FindLanguage(fileName);
                        string result;
                        preprocessor.Run(fs, stage, out result);

                        int actual = extractor.Extract (result);
                        Console.WriteLine("{0} - no of blocks extracted : {1}", fileName, actual);
                    }
                }

                GLSLAssembly output = new GLSLAssembly ();
                output.OutputAssembly = System.IO.Path.GetFileName(args[0]);
                output.Version = "1.0.0.1";
                output.Namespace = "";
                output.Path = System.IO.Path.GetPathRoot(args[0]);
                output.ReferencedAssemblies = new string[]{"OpenTK.dll"};

                IGLSLStructGenerator generator = new GLSLStructGenerator(extractor);
                using (var provider = new CSharpCodeProvider ())
                {
                    //generator.SaveAsAssembly (provider, output);
                    var options = new CodeGeneratorOptions();
                    options.BlankLinesBetweenMembers = true;
                    generator.SaveAsCode(provider, output, extractor, options);
                }

                return 0;
            //			}
            //			catch (Exception ex)
            //			{
            //				Debug.WriteLine (ex.Message);
            //				return 1;
            //			}
            //	Test();
        }
Example #6
0
 public void Initialize01()
 {
     IGLSLTypeLookup lookup = new OpenTKTypeLookup ();
     IGLSLUniformExtractor test = new GLSLUniformExtractor (lookup);
     test.Initialize ();
 }