* Keith Whitwell <keithw@vmware.com>
*/
+#include "c99_math.h"
#include "main/glheader.h"
#include "main/imports.h"
#include "main/context.h"
{
GLfloat end = ctx->Fog.End;
GLfloat d, temp;
- const GLfloat z = FABSF(fogcoord);
+ const GLfloat z = fabsf(fogcoord);
switch (ctx->Fog.Mode) {
case GL_LINEAR:
#endif
-/***
- *** FABSF: absolute value of float
- ***/
-#if defined(__gnu_linux__)
-/* C99 functions */
-#define FABSF(x) fabsf(x)
-#else
-#define FABSF(x) ((GLfloat) fabs(x))
-#endif
-
-
/**
* Convert float to int by rounding to nearest integer, away from zero.
*/
*/
+#include "c99_math.h"
#include "main/glheader.h"
#include "main/imports.h"
#include "main/macros.h"
r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0;
/* choose pivot - or die */
- if (FABSF(r3[0])>FABSF(r2[0])) SWAP_ROWS(r3, r2);
- if (FABSF(r2[0])>FABSF(r1[0])) SWAP_ROWS(r2, r1);
- if (FABSF(r1[0])>FABSF(r0[0])) SWAP_ROWS(r1, r0);
+ if (fabsf(r3[0])>fabsf(r2[0])) SWAP_ROWS(r3, r2);
+ if (fabsf(r2[0])>fabsf(r1[0])) SWAP_ROWS(r2, r1);
+ if (fabsf(r1[0])>fabsf(r0[0])) SWAP_ROWS(r1, r0);
if (0.0 == r0[0]) return GL_FALSE;
/* eliminate first variable */
if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; }
/* choose pivot - or die */
- if (FABSF(r3[1])>FABSF(r2[1])) SWAP_ROWS(r3, r2);
- if (FABSF(r2[1])>FABSF(r1[1])) SWAP_ROWS(r2, r1);
+ if (fabsf(r3[1])>fabsf(r2[1])) SWAP_ROWS(r3, r2);
+ if (fabsf(r2[1])>fabsf(r1[1])) SWAP_ROWS(r2, r1);
if (0.0 == r1[1]) return GL_FALSE;
/* eliminate second variable */
s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; }
/* choose pivot - or die */
- if (FABSF(r3[2])>FABSF(r2[2])) SWAP_ROWS(r3, r2);
+ if (fabsf(r3[2])>fabsf(r2[2])) SWAP_ROWS(r3, r2);
if (0.0 == r2[2]) return GL_FALSE;
/* eliminate third variable */
det = pos + neg;
- if (FABSF(det) < 1e-25)
+ if (fabsf(det) < 1e-25)
return GL_FALSE;
det = 1.0F / det;
m[2] *= x; m[6] *= y; m[10] *= z;
m[3] *= x; m[7] *= y; m[11] *= z;
- if (FABSF(x - y) < 1e-8 && FABSF(x - z) < 1e-8)
+ if (fabsf(x - y) < 1e-8 && fabsf(x - z) < 1e-8)
mat->flags |= MAT_FLAG_UNIFORM_SCALE;
else
mat->flags |= MAT_FLAG_GENERAL_SCALE;
}
if (source->Abs) {
- result[0] = FABSF(result[0]);
- result[1] = FABSF(result[1]);
- result[2] = FABSF(result[2]);
- result[3] = FABSF(result[3]);
+ result[0] = fabsf(result[0]);
+ result[1] = fabsf(result[1]);
+ result[2] = fabsf(result[2]);
+ result[3] = fabsf(result[3]);
}
if (source->Negate) {
assert(source->Negate == NEGATE_XYZW);
result[3] = deriv[GET_SWZ(source->Swizzle, 3)];
if (source->Abs) {
- result[0] = FABSF(result[0]);
- result[1] = FABSF(result[1]);
- result[2] = FABSF(result[2]);
- result[3] = FABSF(result[3]);
+ result[0] = fabsf(result[0]);
+ result[1] = fabsf(result[1]);
+ result[2] = fabsf(result[2]);
+ result[3] = fabsf(result[3]);
}
if (source->Negate) {
assert(source->Negate == NEGATE_XYZW);
result[0] = src[GET_SWZ(source->Swizzle, 0)];
if (source->Abs) {
- result[0] = FABSF(result[0]);
+ result[0] = fabsf(result[0]);
}
if (source->Negate) {
result[0] = -result[0];
{
GLfloat a[4], result[4];
fetch_vector4(&inst->SrcReg[0], machine, a);
- result[0] = FABSF(a[0]);
- result[1] = FABSF(a[1]);
- result[2] = FABSF(a[2]);
- result[3] = FABSF(a[3]);
+ result[0] = fabsf(a[0]);
+ result[1] = fabsf(a[1]);
+ result[2] = fabsf(a[2]);
+ result[3] = fabsf(a[3]);
store_vector4(inst, machine, result);
}
break;
{
GLfloat t[4], q[4], abs_t0;
fetch_vector1(&inst->SrcReg[0], machine, t);
- abs_t0 = FABSF(t[0]);
+ abs_t0 = fabsf(t[0]);
if (abs_t0 != 0.0F) {
if (IS_INF_OR_NAN(abs_t0))
{
{
GLfloat a[4], result[4];
fetch_vector1(&inst->SrcReg[0], machine, a);
- a[0] = FABSF(a[0]);
+ a[0] = fabsf(a[0]);
result[0] = result[1] = result[2] = result[3] = INV_SQRTF(a[0]);
store_vector4(inst, machine, result);
if (DEBUG_PROG) {
GLuint i; \
for (i = 0; i < span->end; i++) { \
const GLfloat fogCoord = span->array->attribs[VARYING_SLOT_FOGC][i][0]; \
- const GLfloat c = FABSF(fogCoord); \
+ const GLfloat c = fabsf(fogCoord); \
GLfloat f, oneMinusF; \
FOG_FUNC(f, c); \
f = CLAMP(f, 0.0F, 1.0F); \
GLfloat w = span->attrStart[VARYING_SLOT_POS][3]; \
GLuint i; \
for (i = 0; i < span->end; i++) { \
- const GLfloat c = FABSF(fogCoord) / w; \
+ const GLfloat c = fabsf(fogCoord) / w; \
GLfloat f, oneMinusF; \
FOG_FUNC(f, c); \
f = CLAMP(f, 0.0F, 1.0F); \
* \author Brian Paul
*/
+#include "c99_math.h"
#include "main/glheader.h"
#include "main/colormac.h"
#include "main/format_pack.h"
GLfloat dsdy2 = (s + dsdy) / (q + dqdy) - s * invQ;
GLfloat dtdy2 = (t + dtdy) / (q + dqdy) - t * invQ;
GLfloat maxU, maxV, rho, lambda;
- dsdx2 = FABSF(dsdx2);
- dsdy2 = FABSF(dsdy2);
- dtdx2 = FABSF(dtdx2);
- dtdy2 = FABSF(dtdy2);
+ dsdx2 = fabsf(dsdx2);
+ dsdy2 = fabsf(dsdy2);
+ dtdx2 = fabsf(dtdx2);
+ dtdy2 = fabsf(dtdy2);
maxU = MAX2(dsdx2, dsdy2) * texW;
maxV = MAX2(dtdx2, dtdy2) * texH;
rho = MAX2(maxU, maxV);
*/
+#include "c99_math.h"
#include "main/glheader.h"
#include "main/context.h"
#include "main/colormac.h"
}
break;
case GL_MIRROR_CLAMP_EXT:
- u = FABSF(s);
+ u = fabsf(s);
if (u >= 1.0F)
u = (GLfloat) size;
else
*i1 = *i0 + 1;
break;
case GL_MIRROR_CLAMP_TO_EDGE_EXT:
- u = FABSF(s);
+ u = fabsf(s);
if (u >= 1.0F)
u = (GLfloat) size;
else
{
const GLfloat min = -1.0F / (2.0F * size);
const GLfloat max = 1.0F - min;
- u = FABSF(s);
+ u = fabsf(s);
if (u <= min)
u = min * size;
else if (u >= max)
{
/* s limited to [0,1] */
/* i limited to [0,size-1] */
- const GLfloat u = FABSF(s);
+ const GLfloat u = fabsf(s);
if (u <= 0.0F)
i = 0;
else if (u >= 1.0F)
/* i limited to [0, size-1] */
const GLfloat min = 1.0F / (2.0F * size);
const GLfloat max = 1.0F - min;
- const GLfloat u = FABSF(s);
+ const GLfloat u = fabsf(s);
if (u < min)
i = 0;
else if (u > max)
/* i limited to [0, size-1] */
const GLfloat min = -1.0F / (2.0F * size);
const GLfloat max = 1.0F - min;
- const GLfloat u = FABSF(s);
+ const GLfloat u = fabsf(s);
if (u < min)
i = -1;
else if (u > max)
const GLfloat rx = texcoord[0];
const GLfloat ry = texcoord[1];
const GLfloat rz = texcoord[2];
- const GLfloat arx = FABSF(rx), ary = FABSF(ry), arz = FABSF(rz);
+ const GLfloat arx = fabsf(rx), ary = fabsf(ry), arz = fabsf(rz);
GLuint face;
GLfloat sc, tc, ma;
* Keith Whitwell <keithw@vmware.com>
*/
+#include "c99_math.h"
#include "main/glheader.h"
#include "main/colormac.h"
#include "main/macros.h"
const GLfloat ez = z[0] - z[2];
const GLfloat fz = z[1] - z[2];
const GLfloat oneOverArea = 1.0F / cc;
- const GLfloat dzdx = FABSF((ey * fz - ez * fy) * oneOverArea);
- const GLfloat dzdy = FABSF((ez * fx - ex * fz) * oneOverArea);
+ const GLfloat dzdx = fabsf((ey * fz - ez * fy) * oneOverArea);
+ const GLfloat dzdy = fabsf((ez * fx - ex * fz) * oneOverArea);
offset += MAX2(dzdx, dzdy) * ctx->Polygon.OffsetFactor;
}
/* new Z values */
NOTE should avoid going through array twice */
coord = input->start;
for (i = 0; i < input->count; i++) {
- *coord = FABSF(*coord);
+ *coord = fabsf(*coord);
STRIDE_F(coord, input->stride);
}
}
input->count = VB->EyePtr->count;
coord = VB->EyePtr->start;
for (i = 0 ; i < VB->EyePtr->count; i++) {
- input->data[i][0] = FABSF(coord[2]);
+ input->data[i][0] = fabsf(coord[2]);
STRIDE_F(coord, VB->EyePtr->stride);
}
}
* Brian Paul
*/
+#include "c99_math.h"
#include "main/glheader.h"
#include "main/mtypes.h"
#include "main/dd.h"
GLuint i;
for (i = 0; i < VB->Count; i++) {
- const GLfloat dist = FABSF(*eyeCoord);
+ const GLfloat dist = fabsf(*eyeCoord);
const GLfloat q = p0 + dist * (p1 + dist * p2);
const GLfloat atten = (q != 0.0F) ? INV_SQRTF(q) : 1.0F;
size[i][0] = pointSize * atten; /* clamping done in rasterization */