示例#1
0
        static public void Initialize(Device device)
        {
            if (m_Initialized)
            {
                throw new Exception("Already initialized!");
            }

            string[] filters = new[] { "*.hlsl", "*.fx" };

            foreach (string f in filters)
            {
                FileSystemWatcher w = new FileSystemWatcher();
                w.Filter = f;
                w.Changed += new FileSystemEventHandler(OnFileChanged);
                w.Renamed += new RenamedEventHandler(OnFileChanged);
                w.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName;
                w.Path = Directory.GetCurrentDirectory() + "\\shaders";
                w.EnableRaisingEvents = true;
                m_Watchers.Add(w);
            }

            m_Initialized = true;
            m_Include = new IncludeFX();

            CultureInfo ci = new CultureInfo("en-US", false);
            string[] filePaths = filters.SelectMany(f => Directory.GetFiles(Directory.GetCurrentDirectory() + "\\shaders", f)).ToArray();


            foreach (string path in filePaths)
            {
                ParseFile(device, path);
            }
        }