I have uniform defined in my shader like below
// FragmentShader.glsl
#define MAX_NUM_LIGHTS 5
struct DirectionalLight
{
vec3 direction;
vec3 color;
vec3 ambient;
float strength;
};
layout (std140) uniform StaticDirectionalLights
{
int SL_numDirectionalLight;
DirectionalLight[MAX_NUM_LIGHTS] SL_DirectionalLights;
};
and i have corresponding C++ structs as
#define MAX_NUM_LIGHTS 5
struct R3D_DirectionalLight
{
Vec3 direction;
float padding1;
Vec3 color;
float padding2;
Vec3 ambient;
float padding3;
float strength;
Vec3 padding4;
};
struct R3D_DirectionalLights
{
int numDirectionalLights;
char padding1[sizeof(Vec4) - sizeof(int)] = {0};
R3D_DirectionalLight directionalLights[MAX_NUM_LIGHTS];
};
when i copy my C++ struct to glsl uniform using glBufferSubData, SL_numDirectionalLight doesn't reflect correct value. is there any problem in my C++ struct memory layout which is not complying to std140 rule?