mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-09 10:20:07 +00:00
gtk-demo: Fix build without sincos
We are getting into trouble here if sincos isn't detected but still present in headers. Avoid that. Also fix the other copy of gtkgears.c.
This commit is contained in:
parent
9f64202a60
commit
6cb612ac15
@ -48,14 +48,16 @@
|
|||||||
#define VERTICES_PER_TOOTH 34
|
#define VERTICES_PER_TOOTH 34
|
||||||
#define GEAR_VERTEX_STRIDE 6
|
#define GEAR_VERTEX_STRIDE 6
|
||||||
|
|
||||||
#ifndef HAVE_SINCOS
|
static inline void
|
||||||
static void
|
_sincos (double x, double *_sin, double *_cos)
|
||||||
sincos (double x, double *_sin, double *_cos)
|
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_SINCOS
|
||||||
|
sincos (x, _sin, _cos);
|
||||||
|
#else
|
||||||
*_sin = sin (x);
|
*_sin = sin (x);
|
||||||
*_cos = cos (x);
|
*_cos = cos (x);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Struct describing the vertices in triangle strip
|
* Struct describing the vertices in triangle strip
|
||||||
@ -307,11 +309,11 @@ create_gear (GLfloat inner_radius,
|
|||||||
struct point p[7];
|
struct point p[7];
|
||||||
|
|
||||||
/* Calculate needed sin/cos for various angles */
|
/* Calculate needed sin/cos for various angles */
|
||||||
sincos(i * 2.0 * G_PI / teeth + da * 0, &s[0], &c[0]);
|
_sincos(i * 2.0 * G_PI / teeth + da * 0, &s[0], &c[0]);
|
||||||
sincos(i * 2.0 * M_PI / teeth + da * 1, &s[1], &c[1]);
|
_sincos(i * 2.0 * M_PI / teeth + da * 1, &s[1], &c[1]);
|
||||||
sincos(i * 2.0 * M_PI / teeth + da * 2, &s[2], &c[2]);
|
_sincos(i * 2.0 * M_PI / teeth + da * 2, &s[2], &c[2]);
|
||||||
sincos(i * 2.0 * M_PI / teeth + da * 3, &s[3], &c[3]);
|
_sincos(i * 2.0 * M_PI / teeth + da * 3, &s[3], &c[3]);
|
||||||
sincos(i * 2.0 * M_PI / teeth + da * 4, &s[4], &c[4]);
|
_sincos(i * 2.0 * M_PI / teeth + da * 4, &s[4], &c[4]);
|
||||||
|
|
||||||
GEAR_POINT(p[0], r2, 1);
|
GEAR_POINT(p[0], r2, 1);
|
||||||
GEAR_POINT(p[1], r2, 2);
|
GEAR_POINT(p[1], r2, 2);
|
||||||
@ -520,7 +522,7 @@ void perspective(GLfloat *m, GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloa
|
|||||||
identity(tmp);
|
identity(tmp);
|
||||||
|
|
||||||
deltaZ = zFar - zNear;
|
deltaZ = zFar - zNear;
|
||||||
sincos(radians, &sine, &cosine);
|
_sincos(radians, &sine, &cosine);
|
||||||
|
|
||||||
if ((deltaZ == 0) || (sine == 0) || (aspect == 0))
|
if ((deltaZ == 0) || (sine == 0) || (aspect == 0))
|
||||||
return;
|
return;
|
||||||
|
@ -48,14 +48,16 @@
|
|||||||
#define VERTICES_PER_TOOTH 34
|
#define VERTICES_PER_TOOTH 34
|
||||||
#define GEAR_VERTEX_STRIDE 6
|
#define GEAR_VERTEX_STRIDE 6
|
||||||
|
|
||||||
#ifndef HAVE_SINCOS
|
static inline void
|
||||||
static void
|
_sincos (double x, double *_sin, double *_cos)
|
||||||
sincos (double x, double *_sin, double *_cos)
|
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_SINCOS
|
||||||
|
sincos (x, _sin, _cos);
|
||||||
|
#else
|
||||||
*_sin = sin (x);
|
*_sin = sin (x);
|
||||||
*_cos = cos (x);
|
*_cos = cos (x);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Struct describing the vertices in triangle strip
|
* Struct describing the vertices in triangle strip
|
||||||
@ -306,11 +308,11 @@ create_gear (GLfloat inner_radius,
|
|||||||
struct point p[7];
|
struct point p[7];
|
||||||
|
|
||||||
/* Calculate needed sin/cos for various angles */
|
/* Calculate needed sin/cos for various angles */
|
||||||
sincos(i * 2.0 * G_PI / teeth + da * 0, &s[0], &c[0]);
|
_sincos(i * 2.0 * G_PI / teeth + da * 0, &s[0], &c[0]);
|
||||||
sincos(i * 2.0 * M_PI / teeth + da * 1, &s[1], &c[1]);
|
_sincos(i * 2.0 * M_PI / teeth + da * 1, &s[1], &c[1]);
|
||||||
sincos(i * 2.0 * M_PI / teeth + da * 2, &s[2], &c[2]);
|
_sincos(i * 2.0 * M_PI / teeth + da * 2, &s[2], &c[2]);
|
||||||
sincos(i * 2.0 * M_PI / teeth + da * 3, &s[3], &c[3]);
|
_sincos(i * 2.0 * M_PI / teeth + da * 3, &s[3], &c[3]);
|
||||||
sincos(i * 2.0 * M_PI / teeth + da * 4, &s[4], &c[4]);
|
_sincos(i * 2.0 * M_PI / teeth + da * 4, &s[4], &c[4]);
|
||||||
|
|
||||||
GEAR_POINT(p[0], r2, 1);
|
GEAR_POINT(p[0], r2, 1);
|
||||||
GEAR_POINT(p[1], r2, 2);
|
GEAR_POINT(p[1], r2, 2);
|
||||||
@ -519,7 +521,7 @@ static void perspective(GLfloat *m, GLfloat fovy, GLfloat aspect, GLfloat zNear,
|
|||||||
identity(tmp);
|
identity(tmp);
|
||||||
|
|
||||||
deltaZ = zFar - zNear;
|
deltaZ = zFar - zNear;
|
||||||
sincos(radians, &sine, &cosine);
|
_sincos(radians, &sine, &cosine);
|
||||||
|
|
||||||
if ((deltaZ == 0) || (sine == 0) || (aspect == 0))
|
if ((deltaZ == 0) || (sine == 0) || (aspect == 0))
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user