I know this question sounds stupid but, what's the syntax to make a list in HLSL ?
I found how to make an array (Type name[x]) but not how to make a list. :/
Asked
Active
Viewed 2,940 times
3 Answers
3
I don't think you can. You can make an array and keep track of a count in another variable though.
float3 points[12];
int pointCount;
Then in XNA you can set the array and then the count:
List<Vector3> vectors = new List<Vector3>();
vectors.Add(new Vector3(12, -13, 14));
effect.Parameters["points"].SetValue(vectors.ToArray());
effect.Parameters["pointCount"].SetValue(vectors.Count);

Jason Goemaat
- 28,692
- 15
- 86
- 113
-3
You can use ListOf<> to make a list. Hope it will helps you.

Sai Kalyan Kumar Akshinthala
- 11,704
- 8
- 43
- 67
-
Well it helps a little bit but this doesn't tell me how to use it. Like this ?: ListOf
myList; myList.Add(Type) ? – darky89 Feb 25 '11 at 11:36 -
1As far as I can tell "ListOf" is not part of HLSL. – Andrew Russell Feb 26 '11 at 09:00
-3
Here's the MSDN Documentation on Lists in .NET.
Usage:
List<Type> listVariable = new List<Type>();
Example:
List<string> myList = new List<string>();
Additionally, you can use a Hashtable if you want to refer to the items in the list by a (unique) string.
Hashtable myHash = new Hashtable();
// Add item.
myHash.Add("item1", new HLSLShader());
// Remove item.
myHash.Remove("item1");

FreeAsInBeer
- 12,937
- 5
- 50
- 82