Passing custom type (struct) uniform from Qt to GLSL using QGLShaderProgram
I defined a struct for light parameters which contains two vectors. The struct is defined in both C++ and GLSL in an analogous way (note: QVector3D encapsulates 3 float s, not double s): C++ host program: struct LightParameters { QVector3D pos; QVector3D intensity; }; Fragment Shader: struct LightParameters { vec3 pos; vec3 intensity; }; In the fragment shader, I also define the following uniforms. The numbers of lights is limited to 8, so the uniform array has a constant size (but only numLights are actually used): const int maxLights = 8; uniform int numLights; uniform LightParameters lights