예제 #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);
		}
예제 #2
0
		public string GetNextSemantic(VariableDeclarationNode variable)
		{
			if (!string.IsNullOrEmpty(variable.Semantic))
				return variable.Semantic;
			return _semanticPrefix + _currentIndex++;
		}
예제 #3
0
		internal string GetVariableDeclaration(StitchedFragmentSymbol stitchedFragment, VariableDeclarationNode variable)
		{
			return GetVariableDeclaration(variable, stitchedFragment.UniqueName + "_");
		}
예제 #4
0
		private static string GetVertexPassThroughCode(StitchedFragmentSymbol stitchedFragment, VariableDeclarationNode variable)
		{
			return string.Format("\toutput.{0}.{1} = input.{1};", stitchedFragment.UniqueName, variable.Name);
		}