From c7a219ec6f6047b691a9bb32e55ec4a889ba2814 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 21 Oct 2002 15:52:34 +0000 Subject: GL_ATI_texture_mirror_once extension (Ian Romanick) --- src/mesa/swrast/s_texture.c | 52 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c index db2e9e0df9..6929a3cf3a 100644 --- a/src/mesa/swrast/s_texture.c +++ b/src/mesa/swrast/s_texture.c @@ -1,4 +1,4 @@ -/* $Id: s_texture.c,v 1.71 2002/10/18 17:02:01 kschultz Exp $ */ +/* $Id: s_texture.c,v 1.72 2002/10/21 15:52:35 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -97,7 +97,31 @@ U = 1.0F - (S - (GLfloat) flr); /* flr is odd */ \ else \ U = S - (GLfloat) flr; /* flr is even */ \ - U = (U * SIZE) - 0.5F; \ + U = (U * SIZE) - 0.5; \ + I0 = IFLOOR(U); \ + I1 = I0 + 1; \ + if (I0 < 0) \ + I0 = 0; \ + if (I1 >= (GLint) SIZE) \ + I1 = SIZE - 1; \ + } \ + else if (wrapMode == GL_MIRROR_CLAMP_ATI) { \ + U = fabs(S); \ + if (U >= 1.0F) \ + U = (GLfloat) SIZE; \ + else \ + U *= SIZE; \ + U -= 0.5F; \ + I0 = IFLOOR(U); \ + I1 = I0 + 1; \ + } \ + else if (wrapMode == GL_MIRROR_CLAMP_TO_EDGE_ATI) { \ + U = fabs(S); \ + if (U >= 1.0F) \ + U = (GLfloat) SIZE; \ + else \ + U *= SIZE; \ + U -= 0.5F; \ I0 = IFLOOR(U); \ I1 = I0 + 1; \ if (I0 < 0) \ @@ -171,6 +195,30 @@ else \ I = IFLOOR(u * SIZE); \ } \ + else if (wrapMode == GL_MIRROR_CLAMP_ATI) { \ + /* s limited to [0,1] */ \ + /* i limited to [0,size-1] */ \ + const GLfloat u = fabs(S); \ + if (u <= 0.0F) \ + I = 0; \ + else if (u >= 1.0F) \ + I = SIZE - 1; \ + else \ + I = IFLOOR(u * SIZE); \ + } \ + else if (wrapMode == GL_MIRROR_CLAMP_TO_EDGE_ATI) { \ + /* s limited to [min,max] */ \ + /* i limited to [0, size-1] */ \ + const GLfloat min = 1.0F / (2.0F * SIZE); \ + const GLfloat max = 1.0F - min; \ + const GLfloat u = fabs(S); \ + if (u < min) \ + I = 0; \ + else if (u > max) \ + I = SIZE - 1; \ + else \ + I = IFLOOR(u * SIZE); \ + } \ else { \ ASSERT(wrapMode == GL_CLAMP); \ /* s limited to [0,1] */ \ -- cgit v1.2.3