Esempio n. 1
0
        public SourceDom(SourceShader shader, string baseNamespace, CodeDomProvider provider)
        {
            this.codeProvider  = provider;
            this.directives    = new CompileDirectives(provider);
            this.source        = shader;
            this.baseNamespace = baseNamespace;

            string namespaceName = baseNamespace;

            if (!shader.UseParentNamespace)
            {
                namespaceName += "." + Common.ToUpper(Path.GetFileNameWithoutExtension(source.FileName));
            }
            this.outputNamespace = namespaceName;

            HlslTechnique[] techniques = shader.GetAllTechniques();

            if (shader.DefinePlatform)
            {
                //create a copy for each platform
                //xbox first

                this.rootPcNamespace   = new CodeNamespace(namespaceName);
                this.rootXboxNamespace = new CodeNamespace(namespaceName);

                for (int i = 0; i < techniques.Length; i++)
                {
                    //build the PC shaders
                    if ((techniques[i].Platform & Platform.Windows) == Platform.Windows)
                    {
                        ShaderDom dom = new ShaderDom(source, techniques[i].Name, Platform.Windows, directives);
                        this.rootPcNamespace.Types.Add(dom.CodeTypeDeclaration);
                    }
                }

                for (int i = 0; i < techniques.Length; i++)
                {
                    //build the xbox shaders
                    if ((techniques[i].Platform & Platform.Xbox) == Platform.Xbox)
                    {
                        ShaderDom dom = new ShaderDom(source, techniques[i].Name, Platform.Xbox, directives);
                        this.rootXboxNamespace.Types.Add(dom.CodeTypeDeclaration);
                    }
                }
            }
            else
            {
                this.rootNamespace = new CodeNamespace(namespaceName);

                for (int i = 0; i < techniques.Length; i++)
                {
                    //build the combined pc / xbox shaders
                    if ((techniques[i].Platform & Platform.Both) == Platform.Both)
                    {
                        ShaderDom dom = new ShaderDom(source, techniques[i].Name, Platform.Both, directives);
                        this.rootNamespace.Types.Add(dom.CodeTypeDeclaration);
                    }
                }
            }
        }
Esempio n. 2
0
		public SourceDom(SourceShader shader, string baseNamespace, CodeDomProvider provider)
		{
			this.codeProvider = provider;
			this.directives = new CompileDirectives(provider);
			this.source = shader;
			this.baseNamespace = baseNamespace;
			
			string namespaceName = baseNamespace;
			if (!shader.UseParentNamespace)
				namespaceName += "." + Common.ToUpper(Path.GetFileNameWithoutExtension(source.FileName));
			this.outputNamespace = namespaceName;

			HlslTechnique[] techniques = shader.GetAllTechniques();

			if (shader.DefinePlatform)
			{
				//create a copy for each platform
				//xbox first

				this.rootPcNamespace = new CodeNamespace(namespaceName);
				this.rootXboxNamespace = new CodeNamespace(namespaceName);
				
				for (int i = 0; i < techniques.Length; i++)
				{
					//build the PC shaders
					if ((techniques[i].Platform & Platform.Windows) == Platform.Windows)
					{
						ShaderDom dom = new ShaderDom(source, techniques[i].Name, Platform.Windows, directives);
						this.rootPcNamespace.Types.Add(dom.CodeTypeDeclaration);
					}
				}

				for (int i = 0; i < techniques.Length; i++)
				{
					//build the xbox shaders
					if ((techniques[i].Platform & Platform.Xbox) == Platform.Xbox)
					{
						ShaderDom dom = new ShaderDom(source, techniques[i].Name, Platform.Xbox, directives);
						this.rootXboxNamespace.Types.Add(dom.CodeTypeDeclaration);
					}
				}
			}
			else
			{
				this.rootNamespace = new CodeNamespace(namespaceName);

				for (int i = 0; i < techniques.Length; i++)
				{
					//build the combined pc / xbox shaders
					if ((techniques[i].Platform & Platform.Both) == Platform.Both)
					{
						ShaderDom dom = new ShaderDom(source, techniques[i].Name, Platform.Both, directives);
						this.rootNamespace.Types.Add(dom.CodeTypeDeclaration);
					}
				}
			}
		}