Ejemplo n.º 1
0
		public static string GetVariableDeclaration(VariableDeclarationNode variable, string prefix = "")
		{
			string arrayStuff = (variable.IsArray && variable.ArraySize != null) ? "[" + variable.ArraySize + "]" : string.Empty;
			string semantic = (!string.IsNullOrEmpty(variable.Semantic)) ? " : " + variable.Semantic : string.Empty;

			string initialValue;
			if (!string.IsNullOrEmpty(variable.InitialValue))
			{
				string variableInitialValue = variable.InitialValue;
				if (variableInitialValue.StartsWith("sampler_state"))
					variableInitialValue = Regex.Replace(variableInitialValue, @"(Texture=\()([\w]+)(\);)", "$1" + prefix + "$2$3");
				initialValue = " = " + variableInitialValue;
			}
			else
				initialValue = string.Empty;

			return string.Format("{0} {1}{2}{3}{4}{5};",
				Token.GetString(variable.DataType), prefix,
				variable.Name, arrayStuff, semantic, initialValue);
		}
Ejemplo n.º 2
0
		public string GetNextSemantic(VariableDeclarationNode variable)
		{
			if (!string.IsNullOrEmpty(variable.Semantic))
				return variable.Semantic;
			return _semanticPrefix + _currentIndex++;
		}
Ejemplo n.º 3
0
		internal string GetVariableDeclaration(StitchedFragmentSymbol stitchedFragment, VariableDeclarationNode variable)
		{
			return GetVariableDeclaration(variable, stitchedFragment.UniqueName + "_");
		}
Ejemplo n.º 4
0
		private static string GetVertexPassThroughCode(StitchedFragmentSymbol stitchedFragment, VariableDeclarationNode variable)
		{
			return string.Format("\toutput.{0}.{1} = input.{1};", stitchedFragment.UniqueName, variable.Name);
		}