Help with Link error

Hi all,
I get a link error with this subrountine


vec4 aoit_UnpackColour(uint p_Colour)
{    
  vec4 colour;
  const float norm = 1.0f / 255.0f;
  colour.x = float(p_Colour & 0xFF) * norm;
  colour.y = ((p_Colour >> 8) & 0xFF) * norm;
  colour.z = ((p_Colour >> 16) & 0xFF) * norm;
  colour.w = ((p_Colour >> 24) & 0xFF) * norm;
  
  return colour;    
}

but I get no link error when I include more code ( note I have not removed the code using the bit operation but I assume the compile is removing them because if I remove any assignment operator like colour.y = … I get the link error again)


vec4 aoit_UnpackColour(uint p_Colour)
{    
  vec4 colour;
  const float norm = 1.0f / 255.0f;
  colour.x = float(p_Colour & 0xFF) * norm;
  colour.y = ((p_Colour >> 8) & 0xFF) * norm;
  colour.z = ((p_Colour >> 16) & 0xFF) * norm;
  colour.w = ((p_Colour >> 24) & 0xFF) * norm;
  // 
  //  link fails with shift operator, so am using divide instead
  float a = floor(p_Colour / (256 * 256 * 256));   
  colour.w = a * norm;

  float b = floor( (p_Colour - a * 256 * 256 * 256) / (256 * 256));
  colour.z = b * norm;

  float g = floor( (p_Colour - a * 256 * 256 * 256 - b * 256 * 256) / (256));
  colour.y = g * norm;
  
  return colour;    
}


I am compiling in a nVidia geForce 580.

As an aside the pack rountine is fine


uint aoit_PackColour(vec4 p_Colour)
{
  uint colour;
  colour = uint(p_Colour.x * 255.0f) & 0xFF;              // r
  colour |= (uint(p_Colour.y * 255.0f) & 0xFF) << 8;      // g
  colour |= (uint(p_Colour.z * 255.0f) & 0xFF) << 16;     // b
  colour |= (uint(p_Colour.z * 255.0f) & 0xFF) << 24;     // a

  return colour;
}

Thanks

Care to share WHICH linker error you get?

Sure GL_INVALID_OPERATION. Not a lot of help :slight_smile:

That is not a linker error. That’s an OpenGL error. Retrieve the program info log to get info on program compilation and linkage and post it here. http://www.opengl.org/sdk/docs/man4/xhtml/glGetProgramInfoLog.xml

If he’s getting INVALID_OPERATION, it’s not a linker error. He needs to check to see if he’s compiling and linking successfully.

True, but if I’m not mistaken it also doesn’t say anything about the compilation process - at least according to the API reference:

GL_INVALID_OPERATION is generated if program is not a program object.

GL_INVALID_OPERATION is generated if program is the currently active program object and transform feedback mode is active.

It could very well be an error set by some earlier command.

tonyo_au: Please check if any of the above conditions are true in your case. If yes, correct your mistake and try again. If not, please call glGetError() immediately before glLinkProgram() and immediately after and see if the error persists. This way you can be sure that glLinkProgram() fails. If not, the error is generated by some other command before glLinkProgram().

Edit: After you’ve done the above steps and the program still fails to execute properly, please get back with the program log as suggested previously.

Thanks for the input guys,

The link if failing, but you are right the INVALID_OPERATION is not coming from that - it is coming from the glGetShaderInfoLog! I wasn’t catching until the next glGetError.

The log info is “!!!..”


  CHECKOPENGL_WORRY;
  glLinkProgram( c_ProgramID );
  CHECKOPENGL_WORRY;
  glGetProgramiv( c_ProgramID, GL_LINK_STATUS, &linked);
  CHECKOPENGL_WORRY;
  if (!linked)
  {
    int l, l1; 
    glGetProgramiv( c_ProgramID, GL_INFO_LOG_LENGTH, &l);
    CHECKOPENGL_WORRY;
    GLchar* compilerSpew = new GLchar[l+1];
    glGetShaderInfoLog(c_ProgramID, l, &l1, compilerSpew);
    CHECKOPENGL_WORRY; // *********************** this detects error
    OutputDebugStringA(compilerSpew);
    Util_Warning(_T("we failed to link program"));
    delete [] compilerSpew;
    return ( c_IsLinked = false );
   }

I have narrowed the shader problem to the “>>” shift operator. If I remove that, the shader compiles and links with no problem.

I am going to shift the code to an ATI machine to see what happens on it.

Again, thanks for your help

I haven’t solved this problem yet, but found these 2 functions to replace the code

packUnorm4x6 and unpackUnorm4x8

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