We were already defining sqrtf where we don't have the C99 version.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
#define DEG2RAD (M_PI/180.0)
-/***
- *** SQRTF: single-precision square root
- ***/
-#define SQRTF(X) (float) sqrt((float) (X))
-
-
-/***
- *** INV_SQRTF: single-precision inverse square root
- ***/
-#define INV_SQRTF(X) (1.0F / SQRTF(X))
-
-
/**
* \name Work-arounds for platforms that lack C99 math functions
*/
/*@}*/
+
+/** single-precision inverse square root */
+static inline float
+INV_SQRTF(float x)
+{
+ /* XXX we could try Quake's fast inverse square root function here */
+ return 1.0F / sqrtf(x);
+}
+
+
/***
*** LOG2: Log base 2 of float
***/
if (ctx->_NeedEyeCoords)
ctx->_ModelViewInvScale = (GLfloat) INV_SQRTF(f);
else
- ctx->_ModelViewInvScale = (GLfloat) SQRTF(f);
+ ctx->_ModelViewInvScale = (GLfloat) sqrtf(f);
}
}
static inline GLfloat
LEN_3FV(const GLfloat v[3])
{
- return SQRTF(LEN_SQUARED_3FV(v));
+ return sqrtf(LEN_SQUARED_3FV(v));
}
static inline GLfloat
LEN_2FV(const GLfloat v[2])
{
- return SQRTF(LEN_SQUARED_2FV(v));
+ return sqrtf(LEN_SQUARED_2FV(v));
}
}
if (!optimized) {
- const GLfloat mag = SQRTF(x * x + y * y + z * z);
+ const GLfloat mag = sqrtf(x * x + y * y + z * z);
if (mag <= 1.0e-4) {
/* no rotation, leave mat as-is */
line.y1 = v1->attrib[FRAG_ATTRIB_WPOS][1];
line.dx = line.x1 - line.x0;
line.dy = line.y1 - line.y0;
- line.len = SQRTF(line.dx * line.dx + line.dy * line.dy);
+ line.len = sqrtf(line.dx * line.dx + line.dy * line.dy);
line.halfWidth = 0.5F * CLAMP(ctx->Line.Width,
ctx->Const.MinLineWidthAA,
ctx->Const.MaxLineWidthAA);
GLfloat dvdx = texH * ((t + dtdx) / (q + dqdx) - t * invQ);
GLfloat dudy = texW * ((s + dsdy) / (q + dqdy) - s * invQ);
GLfloat dvdy = texH * ((t + dtdy) / (q + dqdy) - t * invQ);
- GLfloat x = SQRTF(dudx * dudx + dvdx * dvdx);
- GLfloat y = SQRTF(dudy * dudy + dvdy * dvdy);
+ GLfloat x = sqrtf(dudx * dudx + dvdx * dvdx);
+ GLfloat y = sqrtf(dudy * dudy + dvdy * dvdy);
GLfloat rho = MAX2(x, y);
GLfloat lambda = LOG2(rho);
return lambda;
/* Calculate the per anisotropic sample offsets in s,t space. */
if (Px2 > Py2) {
- numSamples = ceil(SQRTF(Px2));
+ numSamples = ceil(sqrtf(Px2));
ds = ux / ((GLfloat) img->Width2);
dt = vx / ((GLfloat) img->Height2);
}
else {
- numSamples = ceil(SQRTF(Py2));
+ numSamples = ceil(sqrtf(Py2));
ds = uy / ((GLfloat) img->Width2);
dt = vy / ((GLfloat) img->Height2);
}
ctx->Current.RasterDistance = ctx->Current.Attrib[VERT_ATTRIB_FOG][0];
else
ctx->Current.RasterDistance =
- SQRTF( eye[0]*eye[0] + eye[1]*eye[1] + eye[2]*eye[2] );
+ sqrtf( eye[0]*eye[0] + eye[1]*eye[1] + eye[2]*eye[2] );
/* compute transformed normal vector (for lighting or texgen) */
if (ctx->_NeedEyeCoords) {