int k = config_get_d(CONFIG_TEXTURES);
int W = w;
int H = h;
- int max;
+
+ GLint max;
void *q = NULL;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max);
- while (w / k > max || h / k > max)
+ while (w / k > (int) max || h / k > (int) max)
k *= 2;
if (k > 1)
#define SOL_VERSION 6
#define LARGE 1.0e+5f
+#define SMALL 1.0e-3f
/*---------------------------------------------------------------------------*/
float c = v_dot(p, p) - r * r;
float d = b * b - 4.0f * a * c;
- if (a == 0.0f) return LARGE;
- if (d < 0.0f) return LARGE;
+ if (fabsf(a) < SMALL) return LARGE;
- if (d == 0.0f)
- return -b * 0.5f / a;
+ if (d < 0.0f) return LARGE;
+ else if (d == 0.0f) return -b * 0.5f / a;
else
{
float t0 = 0.5f * (-b - fsqrtf(d)) / a;
/*---------------------------------------------------------------------------*/
-#define color_cmp(a, b) ((a)[0] == (b)[0] && \
- (a)[1] == (b)[1] && \
- (a)[2] == (b)[2] && \
- (a)[3] == (b)[3])
+#define tobyte(f) ((GLubyte) (f * 255.0f))
+
+#define color_cmp(a, b) (tobyte((a)[0]) == tobyte((b)[0]) && \
+ tobyte((a)[1]) == tobyte((b)[1]) && \
+ tobyte((a)[2]) == tobyte((b)[2]) && \
+ tobyte((a)[3]) == tobyte((b)[3]))
static struct s_mtrl default_mtrl =
{
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mp->s);
if (!color_cmp(mp->e, mq->e))
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, mp->e);
- if (mp->h[0] != mq->h[0])
+ if (tobyte(mp->h[0]) != tobyte(mq->h[0]))
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mp->h);
/* Bind the texture. */
const struct s_bill *rp,
const struct s_mtrl *mp, float t)
{
- float T = rp->t ? (fmodf(t, rp->t) - rp->t / 2) : 0.0f;
+ float T = (rp->t > 0.0f) ? (fmodf(t, rp->t) - rp->t / 2) : 0.0f;
float w = rp->w[0] + rp->w[1] * T + rp->w[2] * T * T;
float h = rp->h[0] + rp->h[1] * T + rp->h[2] * T * T;