cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

spectral
Adept II

Default values for struct, float, float3 & float4

Hi,

I would like to know if in a OpenCL kernel I must initialize my structures values, float, float3 & float4 values ?

By example,

struct Color { float r; float g; float b; };

Color col;

col.r = col.g. = col.b = 0.f;

Or there is some better ways to perform this ?

0 Likes
4 Replies
himanshu_gautam
Grandmaster

hi viewon01,

What kind of ways are you expecting?

0 Likes

viewon1,
struct Color { float r, g, b; } col = {0, 0, 0}; should work
0 Likes

Of course,

But is it necessary ? Or we have default values assigned;

By example if I just do this :

Color col;

What is the value of col.x, col.y, col.z ?

Are they undefined ? are they 0 ? Is it the same with float2, float3, float4 ?

0 Likes

If there is no assignment to the value, the value is undefined.
0 Likes