An Embarrassing Mistake
I do hate typo and any syntax that cannot be checked by IDE…
The embarrassment started with a stupid typo of an uniform name in shader. I was trying to reimplement an OpenGL shadow-mapping tutorial but got the main texture covered on my object in a weird way, I didn’t even use any mainTexture
stuff in my fragment shader’s main()
!?
Even more stupidly, I posted it on a Discord community for help! Someone did hint that 4294967295 of GLuint
might stand for -1 but they didn’t notice there was a typo neither and started to complain the weird behaviors of shader compiler. (embarrassing!)
After a long time of rolling the code up and down, eventually I caught the missing ‘t’ from shadowTexure
and everything turned to normal after the fixing.
The “common mistakes” page on OpenGL Wiki notes that -1 is returned by glGetUniformLocation
when a uniform is not using because “the driver will optimize your uniform out”. Indeed in my code mainTexture
was bound to a valid texture object but hadn’t been used in my shader yet so 4294967295, and shadowTexure
didn’t even have a definition in fragment shader so of course 4294967295.
By the way, thanks to the marvelous debugging feature of ReSharper to show the value of local variables inline in the editor, without it I may waste more time on finding out the typo…
(No it’s not an AD, I swear.)