Bit wise operation giving link error

the following shader code


  uint layerseed = gl_PrimitiveID * 32;
  gl_SampleMask[0] = int((layerseed) << 12); 

generates a link error


  uint layerseed = gl_PrimitiveID * 32;
  gl_SampleMask[0] = (int(layerseed) << 12); 

does not.

I checked for link errors with this code


  glGetProgramiv( c_ProgramID, GL_LINK_STATUS, &linked);
  if (!linked)
  {
    int l, l1;
    glGetProgramiv( c_ProgramID, GL_INFO_LOG_LENGTH, &l);
    GLchar* compilerSpew = new GLchar[l+1];
    glGetShaderInfoLog(c_ProgramID, l, &l1, compilerSpew);
  }

the length of the error string is 86; but the error string is junk.

Can anyone explain why the glsl code is wrong and how I get a sensible error message

You have use glGetShaderInfoLog.
You should use glGetProgramInfoLog.

It’s likely not happy with the int / uint implicit conversion in the bit shift operation. The ‘12’ is an int, not a uint. Try 12U instead, or just use your second code sample.

Thanks malexander the 12U solved my problem.

Thanks V-man I didn’t realise there was a glGetProgramInfoLog

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.