Jump to content
  • Advertisement
Sign in to follow this  
_goat

Aggregate Initialisation

This topic is 4479 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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.

Share this post


Link to post
Share on other sites
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!