예제 #1
0
파일: Retro.cs 프로젝트: stuff2600/RAEmus
        public RetroShaderChain(IGL owner, RetroShaderPreset preset, string baseDirectory, bool debug = false)
        {
            Owner       = owner;
            this.Preset = preset;
            Passes      = preset.Passes.ToArray();

            bool ok = true;

            //load up the shaders
            Shaders = new RetroShader[preset.Passes.Count];
            for (int i = 0; i < preset.Passes.Count; i++)
            {
                RetroShaderPreset.ShaderPass pass = preset.Passes[i];

                //acquire content
                string path = Path.Combine(baseDirectory, pass.ShaderPath);
                if (!File.Exists(path))
                {
                    ok = false;
                    break;
                }
                string content = File.ReadAllText(path);

                var shader = new RetroShader(Owner, content, debug);
                Shaders[i] = shader;
                if (!shader.Pipeline.Available)
                {
                    ok = false;
                }
            }

            Available = ok;
        }
예제 #2
0
파일: Retro.cs 프로젝트: adituv/BizHawk
		public RetroShaderChain(IGL owner, RetroShaderPreset preset, string baseDirectory, bool debug = false)
		{
			Owner = owner;
			this.Preset = preset;
			Passes = preset.Passes.ToArray();

			bool ok = true;

			//load up the shaders
			Shaders = new RetroShader[preset.Passes.Count];
			for (int i = 0; i < preset.Passes.Count; i++)
			{
				RetroShaderPreset.ShaderPass pass = preset.Passes[i];

				//acquire content
				string path = Path.Combine(baseDirectory, pass.ShaderPath);
				if (!File.Exists(path))
				{
					ok = false;
					break;
				}
				string content = File.ReadAllText(path);

				var shader = new RetroShader(Owner, content, debug);
				Shaders[i] = shader;
				if (!shader.Pipeline.Available)
					ok = false;
				if (!shader.Available)
					ok = false;
			}

			Available = ok;
		}
예제 #3
0
파일: Retro.cs 프로젝트: xHailFirex/BizHawk
        public RetroShaderChain(IGL owner, RetroShaderPreset preset, string baseDirectory, bool debug = false)
        {
            Owner  = owner;
            Preset = preset;
            Passes = preset.Passes.ToArray();
            Errors = "";

            //load up the shaders
            var shaders = new RetroShader[preset.Passes.Count];

            for (var i = 0; i < preset.Passes.Count; i++)
            {
                //acquire content. we look for it in any reasonable filename so that one preset can bind to multiple shaders
                string content;
                var    path = Path.Combine(baseDirectory, preset.Passes[i].ShaderPath);
                if (!File.Exists(path))
                {
                    if (!Path.HasExtension(path))
                    {
                        path += ".cg";
                    }
                    if (!File.Exists(path))
                    {
                        if (owner.API == "OPENGL")
                        {
                            path = Path.ChangeExtension(path, ".glsl");
                        }
                        else
                        {
                            path = Path.ChangeExtension(path, ".hlsl");
                        }
                    }
                }
                try
                {
                    content = ResolveIncludes(File.ReadAllText(path), Path.GetDirectoryName(path));
                }
                catch (DirectoryNotFoundException e)
                {
                    Errors += $"caught {nameof(DirectoryNotFoundException)}: {e.Message}\n";
                    return;
                }
                catch (FileNotFoundException e)
                {
                    Errors += $"could not read file {e.FileName}\n";
                    return;
                }

                var shader = shaders[i] = new RetroShader(Owner, content, debug);
                if (!shader.Available)
                {
                    Errors += $"===================\r\nPass {i}:\r\n{(shader.Errors??"").Replace("\n","\r\n")}\n";
                    return;
                }
            }

            Shaders   = shaders;
            Available = true;
        }
예제 #4
0
파일: Retro.cs 프로젝트: xy2iii/BizHawk
        public RetroShaderChain(IGL owner, RetroShaderPreset preset, string baseDirectory, bool debug = false)
        {
            Owner       = owner;
            this.Preset = preset;
            Passes      = preset.Passes.ToArray();
            Errors      = "";

            //load up the shaders
            Shaders = new RetroShader[preset.Passes.Count];
            for (var i = 0; i < preset.Passes.Count; i++)
            {
                //acquire content
                var    path = Path.Combine(baseDirectory, preset.Passes[i].ShaderPath);
                string content;
                try
                {
                    content = ResolveIncludes(File.ReadAllText(path), Path.GetDirectoryName(path));
                }
                catch (DirectoryNotFoundException e)
                {
                    Errors += $"caught {nameof(DirectoryNotFoundException)}: {e.Message}\n";
                    return;
                }
                catch (FileNotFoundException e)
                {
                    Errors += $"could not read file {e.FileName}\n";
                    return;
                }

                var shader = Shaders[i] = new RetroShader(Owner, content, debug);
                if (!shader.Available)
                {
                    Errors += $"===================\r\nPass {i}:\r\n{shader.Errors}\n";
                    return;
                }
            }

            Available = true;
        }
예제 #5
0
        public RetroShaderChain(IGL owner, RetroShaderPreset preset, string baseDirectory, bool debug = false)
        {
            Owner       = owner;
            this.Preset = preset;
            Passes      = preset.Passes.ToArray();

            bool ok = true;

            Errors = "";

            //load up the shaders
            Shaders = new RetroShader[preset.Passes.Count];
            for (int i = 0; i < preset.Passes.Count; i++)
            {
                RetroShaderPreset.ShaderPass pass = preset.Passes[i];

                //acquire content
                string path = Path.Combine(baseDirectory, pass.ShaderPath);
                if (!File.Exists(path))
                {
                    ok = false;
                    break;
                }
                string content = ResolveIncludes(File.ReadAllText(path), Path.GetDirectoryName(path));


                var shader = new RetroShader(Owner, content, debug);
                Shaders[i] = shader;
                if (!shader.Available)
                {
                    Errors += string.Format("===================\r\nPass {0}:\r\n{1}", i, shader.Errors);
                    ok      = false;
                }
            }

            Available = ok;
        }
예제 #6
0
파일: Retro.cs 프로젝트: SaxxonPike/BizHawk
		public RetroShaderChain(IGL owner, RetroShaderPreset preset, string baseDirectory, bool debug = false)
		{
			Owner = owner;
			this.Preset = preset;
			Passes = preset.Passes.ToArray();

			bool ok = true;
			Errors = "";

			//load up the shaders
			Shaders = new RetroShader[preset.Passes.Count];
			for (int i = 0; i < preset.Passes.Count; i++)
			{
				RetroShaderPreset.ShaderPass pass = preset.Passes[i];

				//acquire content
				string path = Path.Combine(baseDirectory, pass.ShaderPath);
				if (!File.Exists(path))
				{
					ok = false;
					break;
				}
				string content = ResolveIncludes(File.ReadAllText(path), Path.GetDirectoryName(path));


				var shader = new RetroShader(Owner, content, debug);
				Shaders[i] = shader;
				if (!shader.Available)
				{
					Errors += string.Format("===================\r\nPass {0}:\r\n{1}",i,shader.Errors);
					ok = false;
				}
			}

			Available = ok;
		}