Hi all,
I get a link error with this subrountine
Code :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)
Code :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
Code :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



