[SOLVED] glGetUniformLocation invalid_value on Android

Hey,

I’ve tried to get the uniform locations from my fragment shader uniform trhough glGetUniformLocation

in my fragment shader

uniform float u_fl;

.cpp

auto glp = new GLProgram();
glp->autorelease();

if (!glp->initWithFilenames("vertex.vsh", "fragment.fsh")) { DEBUG_BREAK; }

    .....  glp->bind attribs etc.....

    glp->link();
    glp->updateUniforms();

	GLProgramState* glprogramstate = GLProgramState::getOrCreateWithGLProgram(glp);
    setGLProgramState(glprogramstate);

    auto u_loc = glGetUniformLocation(glp->getProgram(), "u_fl");
 //or 
      auto a = glp->getUniformLocation("u_fl");

    ls->setGLProgram(glp);

but it always returns -1 and the errorcode GL_INVALID_VALUE.

It does work on Windows though, does anyone know if I miss anything special from the OpenGL ES version?

Ok I’ve done some more detailed Debugging now, and found the issue inside my shader, it was interesting that it worked on Windows GLSL though. Main reason why i didn’t see this upfront was, because my CCLOG seems to be bugging, because i can’t see any error Output and thought everything is just fine….

To help others who may have same issue would you be willing to post exact change you made?
(or even before/after shader code) Thx.

Yeah the main issue was acutally me just not seeing the Output from CCLOG, therefore I had to manually read the GL Errors, which then where Pretty obvious issues. I’ve wrongly made some variables const and copied a calculation to a global variable which doesn’t work in GLSL or more specificly GLSL ES since it worked fine on Windows.

1 Like