summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2004-09-13 14:53:02 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2004-09-13 14:53:02 +0000
commit114246eb86c3f0571d5596e01e2586f955ccfb24 (patch)
treef4469d23a4f72126b8fe06e023b66fcef9a29719 /src
parentb66f674410dfb48c0da66374da99bfc3c3b13205 (diff)
tweak texcoord for sampling texture rectangles (Dave Reveman)
Diffstat (limited to 'src')
-rw-r--r--src/mesa/swrast/s_texture.c35
1 files changed, 13 insertions, 22 deletions
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index 834c72c50b..4cb84d12f5 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -2155,56 +2155,47 @@ sample_linear_rect(GLcontext *ctx, GLuint texUnit,
/* NOTE: we DO NOT use [0, 1] texture coordinates! */
if (tObj->WrapS == GL_CLAMP) {
- /* clamping to width-1 looks wrong, but it's really correct */
- fcol = CLAMP(texcoords[i][0], 0.0F, width_minus_1);
+ /* Not exactly what the spec says, but it matches NVIDIA output */
+ fcol = CLAMP(texcoords[i][0] - 0.5F, 0.0, width_minus_1);
i0 = IFLOOR(fcol);
i1 = i0 + 1;
}
else if (tObj->WrapS == GL_CLAMP_TO_EDGE) {
fcol = CLAMP(texcoords[i][0], 0.5F, width - 0.5F);
+ fcol -= 0.5F;
i0 = IFLOOR(fcol);
i1 = i0 + 1;
if (i1 > width_minus_1)
i1 = width_minus_1;
}
- else { /* GL_CLAMP_TO_BORDER */
-#if 0
- /* literal reading of GL_NV_texture_rectangle spec */
+ else {
+ ASSERT(tObj->WrapS == GL_CLAMP_TO_BORDER);
fcol = CLAMP(texcoords[i][0], -0.5F, width + 0.5F);
+ fcol -= 0.5F;
i0 = IFLOOR(fcol);
i1 = i0 + 1;
-#else
- /* Note: this produces results that matches NVIDIA, but it's not
- * exactly what the GL_NV_texture_rectangle specifies!
- */
- fcol = texcoords[i][0];
- i0 = IFLOOR(fcol);
- i1 = i0 + 1;
-#endif
-
}
+
if (tObj->WrapT == GL_CLAMP) {
- frow = CLAMP(texcoords[i][1], 0.0F, height_minus_1);
+ /* Not exactly what the spec says, but it matches NVIDIA output */
+ frow = CLAMP(texcoords[i][1] - 0.5F, 0.0, width_minus_1);
j0 = IFLOOR(frow);
j1 = j0 + 1;
}
else if (tObj->WrapT == GL_CLAMP_TO_EDGE) {
frow = CLAMP(texcoords[i][1], 0.5F, height - 0.5F);
+ frow -= 0.5F;
j0 = IFLOOR(frow);
j1 = j0 + 1;
if (j1 > height_minus_1)
j1 = height_minus_1;
}
- else { /* GL_CLAMP_TO_BORDER */
-#if 0
+ else {
+ ASSERT(tObj->WrapT == GL_CLAMP_TO_BORDER);
frow = CLAMP(texcoords[i][1], -0.5F, height + 0.5F);
+ frow -= 0.5F;
j0 = IFLOOR(frow);
j1 = j0 + 1;
-#else
- frow = texcoords[i][1];
- j0 = IFLOOR(frow);
- j1 = j0 + 1;
-#endif
}
/* compute integer rows/columns */