tgjones / HlslTools

A Visual Studio extension that provides enhanced support for editing High Level Shading Language (HLSL) files
http://timjones.io/blog/archive/2016/04/25/hlsl-tools-for-visual-studio-v1.0-released
Other
565 stars 97 forks source link

#224 #231 Macro VariadicArgument operator improves with stringification. #264

Open TIMONz1535 opened 5 months ago

TIMONz1535 commented 5 months ago

Based on @Jasonchan35 pull request.

#define CTR(...) = {__VA_ARGS__}
#define CTR3(x, ...) = float3(x, __VA_ARGS__)
float x CTR(0.0f);
float3 y CTR(1.0f, 2.0f, 3.0f);
float3 z CTR3(4.0f, 5.0f, 6.0f);
#define CTR_WTF(__VA_ARGS__) = float(__VA_ARGS__)
float3 w CTR_WTF(0.0f);
#define STRING(x, ...) #__VA_ARGS__
string Bar = STRING(7, Pass, 8);

produces

float x = {0.0f};
float3 y = {1.0f, 2.0f, 3.0f};
float3 z = float3(4.0f, 5.0f, 6.0f);

float3 w = float(0.0f);

string Bar = "Pass, 8";