Aggregate Initialisation

Started by
1 comment, last by JohnBolton 18 years, 1 month ago
My gut says no, but I hope it's wrong. I have this:
SVertexAttribute k[3] = 
	{
		{ 0, 32, FLOAT3, false, POSITION, 0 },
		{ 12, 32, FLOAT3, false, NORMAL, 0 },
		{ 24, 32, FLOAT2, false, TEXTURE, 0 }
	};
 
SStreamDescriptor s =
	{ 
		3,
		k
	};
I want something akin to this:
SStreamDescriptor s =
	{ 
		3,
		{
			{ 0, 32, FLOAT3, false, POSITION, 0 },
			{ 12, 32, FLOAT3, false, NORMAL, 0 },
			{ 24, 32, FLOAT2, false, TEXTURE, 0 }
		}
	};
Where:
struct SStreamDescriptor
{
	size_t AttributeCount;
	SVertexAttribute * Attributes;
};
 
struct SVertexAttribute
{
	// it is POD, with enums, if it matters
};
Possible at all?
[ search: google ][ programming: msdn | boost | opengl ][ languages: nihongo ]
Advertisement
Probably not as you want it to.

If Attributes inside SStreamDescriptor was an array, then it would probably work, but then you'd have to specify the size beforehand.
Since the Attributes member variable is pointer, your initialization should work just fine (but the second example shouldn't compile). If Attributes were an array, it wouldn't compile (but the second one would).
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!

This topic is closed to new replies.

Advertisement