}
+/**
+ * When we sample the border color, it must be interpreted according to
+ * the base texture format. Ex: if the texture base format it GL_ALPHA,
+ * we return (0,0,0,BorderAlpha).
+ */
+static INLINE void
+get_border_color(const struct gl_texture_object *tObj,
+ const struct gl_texture_image *img,
+ GLfloat rgba[4])
+{
+ switch (img->TexFormat->BaseFormat) {
+ case GL_RGB:
+ rgba[0] = tObj->BorderColor[0];
+ rgba[1] = tObj->BorderColor[1];
+ rgba[2] = tObj->BorderColor[2];
+ rgba[3] = 1.0F;
+ break;
+ case GL_ALPHA:
+ rgba[0] = rgba[1] = rgba[2] = 0.0;
+ rgba[3] = tObj->BorderColor[3];
+ break;
+ case GL_LUMINANCE:
+ rgba[0] = rgba[1] = rgba[2] = tObj->BorderColor[0];
+ rgba[3] = 1.0;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ rgba[0] = rgba[1] = rgba[2] = tObj->BorderColor[0];
+ rgba[3] = tObj->BorderColor[3];
+ break;
+ case GL_INTENSITY:
+ rgba[0] = rgba[1] = rgba[2] = rgba[3] = tObj->BorderColor[0];
+ break;
+ default:
+ COPY_4V(rgba, tObj->BorderColor);
+ }
+}
+
+
/**********************************************************************/
/* 1-D Texture Sampling Functions */
/**********************************************************************/
i += img->Border;
if (i < 0 || i >= (GLint) img->Width) {
/* Need this test for GL_CLAMP_TO_BORDER mode */
- COPY_4V(rgba, tObj->BorderColor);
+ get_border_color(tObj, img, rgba);
}
else {
img->FetchTexelf(img, i, 0, 0, rgba);
/* fetch texel colors */
if (useBorderColor & I0BIT) {
- COPY_4V(t0, tObj->BorderColor);
+ get_border_color(tObj, img, t0);
}
else {
img->FetchTexelf(img, i0, 0, 0, t0);
}
if (useBorderColor & I1BIT) {
- COPY_4V(t1, tObj->BorderColor);
+ get_border_color(tObj, img, t1);
}
else {
img->FetchTexelf(img, i1, 0, 0, t1);
if (i < 0 || i >= (GLint) img->Width || j < 0 || j >= (GLint) img->Height) {
/* Need this test for GL_CLAMP_TO_BORDER mode */
- COPY_4V(rgba, tObj->BorderColor);
+ get_border_color(tObj, img, rgba);
}
else {
img->FetchTexelf(img, i, j, 0, rgba);
/* fetch four texel colors */
if (useBorderColor & (I0BIT | J0BIT)) {
- COPY_4V(t00, tObj->BorderColor);
+ get_border_color(tObj, img, t00);
}
else {
img->FetchTexelf(img, i0, j0, 0, t00);
}
if (useBorderColor & (I1BIT | J0BIT)) {
- COPY_4V(t10, tObj->BorderColor);
+ get_border_color(tObj, img, t10);
}
else {
img->FetchTexelf(img, i1, j0, 0, t10);
}
if (useBorderColor & (I0BIT | J1BIT)) {
- COPY_4V(t01, tObj->BorderColor);
+ get_border_color(tObj, img, t01);
}
else {
img->FetchTexelf(img, i0, j1, 0, t01);
}
if (useBorderColor & (I1BIT | J1BIT)) {
- COPY_4V(t11, tObj->BorderColor);
+ get_border_color(tObj, img, t11);
}
else {
img->FetchTexelf(img, i1, j1, 0, t11);
j < 0 || j >= (GLint) img->Height ||
k < 0 || k >= (GLint) img->Depth) {
/* Need this test for GL_CLAMP_TO_BORDER mode */
- COPY_4V(rgba, tObj->BorderColor);
+ get_border_color(tObj, img, rgba);
}
else {
img->FetchTexelf(img, i, j, k, rgba);
/* Fetch texels */
if (useBorderColor & (I0BIT | J0BIT | K0BIT)) {
- COPY_4V(t000, tObj->BorderColor);
+ get_border_color(tObj, img, t000);
}
else {
img->FetchTexelf(img, i0, j0, k0, t000);
}
if (useBorderColor & (I1BIT | J0BIT | K0BIT)) {
- COPY_4V(t100, tObj->BorderColor);
+ get_border_color(tObj, img, t100);
}
else {
img->FetchTexelf(img, i1, j0, k0, t100);
}
if (useBorderColor & (I0BIT | J1BIT | K0BIT)) {
- COPY_4V(t010, tObj->BorderColor);
+ get_border_color(tObj, img, t010);
}
else {
img->FetchTexelf(img, i0, j1, k0, t010);
}
if (useBorderColor & (I1BIT | J1BIT | K0BIT)) {
- COPY_4V(t110, tObj->BorderColor);
+ get_border_color(tObj, img, t110);
}
else {
img->FetchTexelf(img, i1, j1, k0, t110);
}
if (useBorderColor & (I0BIT | J0BIT | K1BIT)) {
- COPY_4V(t001, tObj->BorderColor);
+ get_border_color(tObj, img, t001);
}
else {
img->FetchTexelf(img, i0, j0, k1, t001);
}
if (useBorderColor & (I1BIT | J0BIT | K1BIT)) {
- COPY_4V(t101, tObj->BorderColor);
+ get_border_color(tObj, img, t101);
}
else {
img->FetchTexelf(img, i1, j0, k1, t101);
}
if (useBorderColor & (I0BIT | J1BIT | K1BIT)) {
- COPY_4V(t011, tObj->BorderColor);
+ get_border_color(tObj, img, t011);
}
else {
img->FetchTexelf(img, i0, j1, k1, t011);
}
if (useBorderColor & (I1BIT | J1BIT | K1BIT)) {
- COPY_4V(t111, tObj->BorderColor);
+ get_border_color(tObj, img, t111);
}
else {
img->FetchTexelf(img, i1, j1, k1, t111);
col = clamp_rect_coord_nearest(tObj->WrapS, texcoords[i][0], width);
row = clamp_rect_coord_nearest(tObj->WrapT, texcoords[i][1], height);
if (col < 0 || col >= width || row < 0 || row >= height)
- COPY_4V(rgba[i], tObj->BorderColor);
+ get_border_color(tObj, img, rgba[i]);
else
img->FetchTexelf(img, col, row, 0, rgba[i]);
}
/* get four texel samples */
if (useBorderColor & (I0BIT | J0BIT))
- COPY_4V(t00, tObj->BorderColor);
+ get_border_color(tObj, img, t00);
else
img->FetchTexelf(img, i0, j0, 0, t00);
if (useBorderColor & (I1BIT | J0BIT))
- COPY_4V(t10, tObj->BorderColor);
+ get_border_color(tObj, img, t10);
else
img->FetchTexelf(img, i1, j0, 0, t10);
if (useBorderColor & (I0BIT | J1BIT))
- COPY_4V(t01, tObj->BorderColor);
+ get_border_color(tObj, img, t01);
else
img->FetchTexelf(img, i0, j1, 0, t01);
if (useBorderColor & (I1BIT | J1BIT))
- COPY_4V(t11, tObj->BorderColor);
+ get_border_color(tObj, img, t11);
else
img->FetchTexelf(img, i1, j1, 0, t11);
j < 0 || j >= (GLint) img->Height ||
array < 0 || array >= (GLint) img->Depth) {
/* Need this test for GL_CLAMP_TO_BORDER mode */
- COPY_4V(rgba, tObj->BorderColor);
+ get_border_color(tObj, img, rgba);
}
else {
img->FetchTexelf(img, i, j, array, rgba);
/* Fetch texels */
if (useBorderColor & (I0BIT | J0BIT)) {
- COPY_4V(t00, tObj->BorderColor);
+ get_border_color(tObj, img, t00);
}
else {
img->FetchTexelf(img, i0, j0, array, t00);
}
if (useBorderColor & (I1BIT | J0BIT)) {
- COPY_4V(t10, tObj->BorderColor);
+ get_border_color(tObj, img, t10);
}
else {
img->FetchTexelf(img, i1, j0, array, t10);
}
if (useBorderColor & (I0BIT | J1BIT)) {
- COPY_4V(t01, tObj->BorderColor);
+ get_border_color(tObj, img, t01);
}
else {
img->FetchTexelf(img, i0, j1, array, t01);
}
if (useBorderColor & (I1BIT | J1BIT)) {
- COPY_4V(t11, tObj->BorderColor);
+ get_border_color(tObj, img, t11);
}
else {
img->FetchTexelf(img, i1, j1, array, t11);
if (i < 0 || i >= (GLint) img->Width ||
array < 0 || array >= (GLint) img->Height) {
/* Need this test for GL_CLAMP_TO_BORDER mode */
- COPY_4V(rgba, tObj->BorderColor);
+ get_border_color(tObj, img, rgba);
}
else {
img->FetchTexelf(img, i, array, 0, rgba);
/* Fetch texels */
if (useBorderColor & (I0BIT | K0BIT)) {
- COPY_4V(t0, tObj->BorderColor);
+ get_border_color(tObj, img, t0);
}
else {
img->FetchTexelf(img, i0, array, 0, t0);
}
if (useBorderColor & (I1BIT | K0BIT)) {
- COPY_4V(t1, tObj->BorderColor);
+ get_border_color(tObj, img, t1);
}
else {
img->FetchTexelf(img, i1, array, 0, t1);