Sign in to follow this  
_goat

Aggregate Initialisation

Recommended Posts

_goat    804
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?

Share this post


Link to post
Share on other sites
mossmoss    326
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.

Share this post


Link to post
Share on other sites
JohnBolton    1372
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).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this