Convert floating point Z values to integer Z values with pixel transfer's Z scale and bias.
Definition at line 410 of file s_copypix.c.
Referenced by copy_depth_pixels().
{
const GLuint depthMax = ctx->DrawBuffer->_DepthMax;
GLuint i;
if (depthMax <= 0xffffff &&
ctx->Pixel.DepthScale == 1.0 &&
ctx->Pixel.DepthBias == 0.0) {
const GLfloat depthMaxF = ctx->DrawBuffer->_DepthMaxF;
for (i = 0; i < width; i++) {
z[i] = (GLuint) (depth[i] * depthMaxF);
}
}
else {
const GLdouble depthMaxF = ctx->DrawBuffer->_DepthMaxF;
for (i = 0; i < width; i++) {
GLdouble d = depth[i] * ctx->Pixel.DepthScale + ctx->Pixel.DepthBias;
d = CLAMP(d, 0.0, 1.0) * depthMaxF;
if (d >= depthMaxF)
z[i] = depthMax;
else
z[i] = (GLuint) d;
}
}
}