From bef661607b45a0e6208e4275075ae35cfecc7a26 Mon Sep 17 00:00:00 2001 From: Greg Ercolano Date: Mon, 15 Feb 2021 15:56:47 -0800 Subject: Solve all 'fractals' warnings in VS2017/Win32 for issue #109. --- test/fracviewer.cxx | 99 +++++++++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 49 deletions(-) diff --git a/test/fracviewer.cxx b/test/fracviewer.cxx index 2e8d9cdcb..6330678f5 100644 --- a/test/fracviewer.cxx +++ b/test/fracviewer.cxx @@ -39,18 +39,18 @@ /***************************************************************/ /* Initial polar movement settings */ -#define INIT_POLAR_AZ 0.0 -#define INIT_POLAR_EL 30.0 -#define INIT_DIST 4.0 -#define INIT_AZ_SPIN 0.5 -#define INIT_EL_SPIN 0.0 +#define INIT_POLAR_AZ 0.0f +#define INIT_POLAR_EL 30.0f +#define INIT_DIST 4.0f +#define INIT_AZ_SPIN 0.5f +#define INIT_EL_SPIN 0.0f /* Initial flying movement settings */ -#define INIT_EX 0.0 -#define INIT_EY -2.0 -#define INIT_EZ -2.0 -#define INIT_MOVE 0.01 -#define MINMOVE 0.001 +#define INIT_EX 0.0f +#define INIT_EY -2.0f +#define INIT_EZ -2.0f +#define INIT_MOVE 0.01f +#define MINMOVE 0.001f /* Start in this mode */ #define INIT_MODE POLAR @@ -58,30 +58,30 @@ /* Controls: */ /* map 0-9 to an EyeMove value when number key is hit in FLYING mode */ -#define SPEEDFUNCTION(x) ((x)*(x)*0.001) +#define SPEEDFUNCTION(x) ((x)*(x)*0.001f) /* Multiply EyeMove by (1+-MOVEFRACTION) when +/- hit in FLYING mode */ -#define MOVEFRACTION 0.25 +#define MOVEFRACTION 0.25f /* What to multiply number of pixels mouse moved by to get rotation amount */ -#define EL_SENS 0.5 -#define AZ_SENS 0.5 +#define EL_SENS 0.5f +#define AZ_SENS 0.5f /* What to multiply number of pixels mouse moved by for movement amounts */ -#define DIST_SENS 0.01 -#define E_SENS 0.01 +#define DIST_SENS 0.01f +#define E_SENS 0.01f /* Minimum spin to allow in polar (lower forced to zero) */ -#define MIN_AZSPIN 0.1 -#define MIN_ELSPIN 0.1 +#define MIN_AZSPIN 0.1f +#define MIN_ELSPIN 0.1f /* Factors used in computing dAz and dEl (which determine AzSpin, ElSpin) */ -#define SLOW_DAZ 0.90 -#define SLOW_DEL 0.90 -#define PREV_DAZ 0.80 -#define PREV_DEL 0.80 -#define CUR_DAZ 0.20 -#define CUR_DEL 0.20 +#define SLOW_DAZ 0.90f +#define SLOW_DEL 0.90f +#define PREV_DAZ 0.80f +#define PREV_DEL 0.80f +#define CUR_DAZ 0.20f +#define CUR_DEL 0.20f /***************************************************************/ /************************** GLOBALS ****************************/ @@ -182,9 +182,9 @@ void FlyLookFrom(GLfloat x, GLfloat y, GLfloat z, GLfloat az, GLfloat el) { float lookat[3], perp[3], up[3]; - lookat[0] = sin(TORAD(az))*cos(TORAD(el)); - lookat[1] = sin(TORAD(el)); - lookat[2] = -cos(TORAD(az))*cos(TORAD(el)); + lookat[0] = GLfloat(sin(TORAD(az))*cos(TORAD(el))); + lookat[1] = GLfloat(sin(TORAD(el))); + lookat[2] = GLfloat(-cos(TORAD(az))*cos(TORAD(el))); normalize(lookat); perp[0] = lookat[2]; perp[1] = 0; @@ -219,10 +219,10 @@ void agvViewTransform(void) int ConstrainEl(void) { if (EyeEl <= -90) { - EyeEl = -89.99; + EyeEl = -89.99f; return 1; } else if (EyeEl >= 90) { - EyeEl = 89.99; + EyeEl = 89.99f; return 1; } return 0; @@ -235,9 +235,9 @@ void agvMove(void) { switch (MoveMode) { case FLYING: - Ex += EyeMove*sin(TORAD(EyeAz))*cos(TORAD(EyeEl)); - Ey += EyeMove*sin(TORAD(EyeEl)); - Ez -= EyeMove*cos(TORAD(EyeAz))*cos(TORAD(EyeEl)); + Ex += GLfloat(EyeMove*sin(TORAD(EyeAz))*cos(TORAD(EyeEl))); + Ey += GLfloat(EyeMove*sin(TORAD(EyeEl))); + Ez -= GLfloat(EyeMove*cos(TORAD(EyeAz))*cos(TORAD(EyeEl))); break; case POLAR: @@ -247,7 +247,7 @@ void agvMove(void) ElSpin = -ElSpin; /* look better when you are kept from going */ /* upside down while spinning - Isn't great */ if (fabs(ElSpin) > fabs(AzSpin)) - AzSpin = fabs(ElSpin) * ((AzSpin > 0) ? 1 : -1); + AzSpin = fabs(ElSpin) * (AzSpin > 0.0f) ? 1.0f : -1.0f; } break; } @@ -305,9 +305,9 @@ void agvSwitchMoveMode(int move) switch (move) { case FLYING: if (MoveMode == FLYING) return; - Ex = -EyeDist*sin(TORAD(EyeAz))*cos(TORAD(EyeEl)); - Ey = EyeDist*sin(TORAD(EyeEl)); - Ez = EyeDist*(cos(TORAD(EyeAz))*cos(TORAD(EyeEl))); + Ex = GLfloat(-EyeDist*sin(TORAD(EyeAz))*cos(TORAD(EyeEl))); + Ey = GLfloat( EyeDist*sin(TORAD(EyeEl))); + Ez = GLfloat( EyeDist*(cos(TORAD(EyeAz))*cos(TORAD(EyeEl)))); EyeEl = -EyeEl; EyeMove = INIT_MOVE; break; @@ -347,9 +347,9 @@ void agvHandleButton(int button, int state, int x, int y) EyeMove = 0; EyeDist = downDist + deltay; - Ex = downEx - E_SENS*deltay*sin(TORAD(EyeAz))*cos(TORAD(EyeEl)); - Ey = downEy - E_SENS*deltay*sin(TORAD(EyeEl)); - Ez = downEz + E_SENS*deltay*cos(TORAD(EyeAz))*cos(TORAD(EyeEl)); + Ex = GLfloat(downEx - E_SENS*deltay*sin(TORAD(EyeAz))*cos(TORAD(EyeEl))); + Ey = GLfloat(downEy - E_SENS*deltay*sin(TORAD(EyeEl))); + Ez = GLfloat(downEz + E_SENS*deltay*cos(TORAD(EyeAz))*cos(TORAD(EyeEl))); EyeMove = downEyeMove; glutPostRedisplay(); @@ -413,19 +413,19 @@ void agvHandleMotion(int x, int y) switch (downb) { case GLUT_LEFT_BUTTON: - EyeEl = downEl + EL_SENS * deltay; + EyeEl = GLfloat(downEl + EL_SENS * deltay); ConstrainEl(); - EyeAz = downAz + AZ_SENS * deltax; - dAz = PREV_DAZ*dAz + CUR_DAZ*(lastAz - EyeAz); - dEl = PREV_DEL*dEl + CUR_DEL*(lastEl - EyeEl); + EyeAz = GLfloat(downAz + AZ_SENS * deltax); + dAz = GLfloat(PREV_DAZ*dAz + CUR_DAZ*(lastAz - EyeAz)); + dEl = GLfloat(PREV_DEL*dEl + CUR_DEL*(lastEl - EyeEl)); lastAz = EyeAz; lastEl = EyeEl; break; case GLUT_MIDDLE_BUTTON: - EyeDist = downDist + DIST_SENS*deltay; - Ex = downEx - E_SENS*deltay*sin(TORAD(EyeAz))*cos(TORAD(EyeEl)); - Ey = downEy - E_SENS*deltay*sin(TORAD(EyeEl)); - Ez = downEz + E_SENS*deltay*cos(TORAD(EyeAz))*cos(TORAD(EyeEl)); + EyeDist = GLfloat(downDist + DIST_SENS*deltay); + Ex = GLfloat(downEx - E_SENS*deltay*sin(TORAD(EyeAz))*cos(TORAD(EyeEl))); + Ey = GLfloat(downEy - E_SENS*deltay*sin(TORAD(EyeEl))); + Ez = GLfloat(downEz + E_SENS*deltay*cos(TORAD(EyeAz))*cos(TORAD(EyeEl))); break; } glutPostRedisplay(); @@ -479,7 +479,7 @@ void agvHandleKeys(unsigned char key, int, int) { /* normalizes v */ static void normalize(GLfloat v[3]) { - GLfloat d = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); + GLfloat d = sqrtf(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); if (d == 0) fprintf(stderr, "Zero length vector in normalize\n"); @@ -507,6 +507,7 @@ void agvMakeAxesList(int displaylistnum) { int i,j; GLfloat axes_ambuse[] = { 0.5, 0.0, 0.0, 1.0 }; + GLfloat trans = -10; glNewList(displaylistnum, GL_COMPILE); glPushAttrib(GL_LIGHTING_BIT); glMatrixMode(GL_MODELVIEW); @@ -518,7 +519,7 @@ void agvMakeAxesList(int displaylistnum) glEnd(); for (i = 0; i < 3; i++) { glPushMatrix(); - glTranslatef(-10*(i==0), -10*(i==1), -10*(i==2)); + glTranslatef(trans*(i==0), trans*(i==1), trans*(i==2)); for (j = 0; j < 21; j++) { // glutSolidCube(0.1); glTranslatef(i==0, i==1, i==2); -- cgit v1.2.3