Ejemplo n.º 1
0
        static void Main()
        {
            // UI initialization (before accessing GraphicsContext and others)
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

#if DEBUG
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException);
#endif

            // Check requirements
            StringBuilder missingReq = new StringBuilder();

            if (!GraphicsContext.CurrentCaps.GlExtensions.VertexShader_ARB)
            {
                missingReq.Append("- GL_ARB_vertex_shader\n");
            }

            if (missingReq.Length > 0)
            {
                MessageBox.Show(
                    String.Format("Unable to run sample. The following required extensions are not implemented:\n {0}", missingReq.ToString()),
                    "Error...", MessageBoxButtons.OK, MessageBoxIcon.Error
                    );

                return;
            }

            // Load shaders library
            ShadersLibrary.Merge("HelloNewton.Shaders.ShadersLibrary.xml");

            // Run UI
            Application.Run(new SampleForm());
        }
Ejemplo n.º 2
0
        public void ShadersLibrary_SaveTo()
        {
            ShadersLibrary shadersLibrary = new ShadersLibrary();

            shadersLibrary.Includes = new List <ShadersLibrary.Include>();
            shadersLibrary.Includes.Add(
                new ShadersLibrary.Include()
            {
                Path = "/Absolute/Path/To/Include", Resource = "Some.Resource.Identifier"
            }
                );

            shadersLibrary.Objects = new List <ShadersLibrary.Object>();
            shadersLibrary.Objects.Add(
                new ShadersLibrary.Object()
            {
                Resource  = "Some.Object.Resource",
                TestStage = "VertexShader"
            }
                );
            shadersLibrary.Objects[0].Symbols = new ShadersLibrary.SymbolList();
            shadersLibrary.Objects[0].Symbols.Add("DEFINE_SYMBOL");

            shadersLibrary.Programs = new List <ShadersLibrary.Program>();
            shadersLibrary.Programs.Add(new ShadersLibrary.Program()
            {
                Id = "TestProgram",
            });
            shadersLibrary.Programs[0].Objects = new List <ShadersLibrary.Object>();
            shadersLibrary.Programs[0].Objects.Add(new ShadersLibrary.Object()
            {
                Resource = "Some.Object.Resource",
                Stage    = ShaderType.VertexShader,
            });
            shadersLibrary.Programs[0].Attributes = new List <ShadersLibrary.Attribute>();
            shadersLibrary.Programs[0].Attributes.Add(new ShadersLibrary.Attribute()
            {
                Name     = "test_Attribute",
                Location = -1,
                Semantic = "Position"
            });

            byte[] shaderLibraryBytes;

            using (MemoryStream memoryStream = new MemoryStream()) {
                shadersLibrary.Save(memoryStream);
                shaderLibraryBytes = memoryStream.ToArray();
            }

            string shaderLibraryText = Encoding.UTF8.GetString(shaderLibraryBytes);
        }