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;
}
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.
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.