问题
Am using OpenGL ES30 with Xamarin/C#.
My issue is that no matter what I do, when I call:
OpenTK.Graphics.ES30.GL.GetUniformLocation(progID, "varName");
It ALWAYS returns ZERO. (not -1).
The following statements all return 0:
int RRRRRRRR = GL.GetUniformLocation(Terrain3D.TileShader.Id, "NOTVALIDNAME");
RRRRRRRR = GL.GetUniformLocation(-1, "ALSONOTVALID");
RRRRRRRR = GL.GetUniformLocation(-1, "BOGUSZZZZ");
RRRRRRRR = GL.GetUniformLocation(-1, "");
These are all bogus values (even for Program ID in all but 1st case), yet they all return ZERO(0) rather than -1. I call them before GL.UseProgram() or after, with valid or invalid arguments -- and all I get back is a the same 0(ZERO), no matter what.
I searched google for any issues that resemble this and found nothing.
It looks to me like my OpenTK ES30 DLL's are hosed in some fashion. This is maddening.
I'm gonna try hooking up to other OpenTK versions. Any help from others would be a god send.
EDIT: Found the Fix!
From the AndroidGameView constructor, I needed to call:
ContextRenderingApi = OpenTK.Graphics.GLVersion.ES3;
Without this, the API defaults to ES1, even though I'm using the ES3.GL for everything.
来源:https://stackoverflow.com/questions/45574726/opengl-gl-getuniformlocation-always-returns-zero-0