Unfortunately, you misunderstood how glGetUniformLocation (...)
and uniform location assignment in general works.
Locations are only assigned after your shaders are compiled and linked. This is a two-phase operation that effectively identifies only the used inputs and outputs between all stages of a GLSL program (vertex, fragment, geometry, tessellation). Because LightPos
is not used in your vertex shader (or anywhere else for that matter) it is not assigned a location when your program is linked. It simply ceases to exist.
This is where the term active uniform comes from. And glGetUniformLocation (...)
only returns the location of active uniforms.
Name
glGetUniformLocation
— Returns the location of a uniform variable[...]
Description
glGetUniformLocation returns an integer that represents the location of a specific uniform variable within a program object. name must be a null terminated string that contains no white space. name must be an active uniform variable name in program that is not a structure, an array of structures, or a subcomponent of a vector or a matrix. This function returns -1 if name does not correspond to an active uniform variable in program, if name starts with the reserved prefix "gl_", or if name is associated with an atomic counter or a named uniform block.