Avoid -Wdouble-promotion warnings
This commit is contained in:
@@ -150,7 +150,7 @@ TestGLContext::TestGLContext(wxGLCanvas *canvas)
|
||||
// set viewing projection
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-0.5f, 0.5f, -0.5f, 0.5f, 1.0f, 3.0f);
|
||||
glFrustum(-0.5, 0.5, -0.5, 0.5, 1, 3);
|
||||
|
||||
// create the textures to use for cube sides: they will be reused by all
|
||||
// canvases (which is probably not critical in the case of simple textures
|
||||
@@ -362,13 +362,13 @@ void TestGLCanvas::OnPaint(wxPaintEvent& WXUNUSED(event))
|
||||
glDrawBuffer( GL_BACK_LEFT );
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-0.47f, 0.53f, -0.5f, 0.5f, 1.0f, 3.0f);
|
||||
glFrustum(-0.47, 0.53, -0.5, 0.5, 1, 3);
|
||||
canvas.DrawRotatedCube(m_xangle, m_yangle);
|
||||
CheckGLError();
|
||||
glDrawBuffer( GL_BACK_RIGHT );
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-0.53f, 0.47f, -0.5f, 0.5f, 1.0f, 3.0f);
|
||||
glFrustum(-0.53, 0.47, -0.5, 0.5, 1, 3);
|
||||
canvas.DrawRotatedCube(m_xangle, m_yangle);
|
||||
CheckGLError();
|
||||
}
|
||||
|
@@ -293,19 +293,19 @@ void TestGLCanvas::OnChar(wxKeyEvent& event)
|
||||
return;
|
||||
|
||||
case WXK_LEFT:
|
||||
m_yrot -= 15.0;
|
||||
m_yrot -= 15;
|
||||
break;
|
||||
|
||||
case WXK_RIGHT:
|
||||
m_yrot += 15.0;
|
||||
m_yrot += 15;
|
||||
break;
|
||||
|
||||
case WXK_UP:
|
||||
m_xrot += 15.0;
|
||||
m_xrot += 15;
|
||||
break;
|
||||
|
||||
case WXK_DOWN:
|
||||
m_xrot -= 15.0;
|
||||
m_xrot -= 15;
|
||||
break;
|
||||
|
||||
case 's': case 'S':
|
||||
@@ -349,8 +349,8 @@ void TestGLCanvas::OnMouseEvent(wxMouseEvent& event)
|
||||
}
|
||||
else
|
||||
{
|
||||
m_yrot += (event.GetX() - last_x)*1.0;
|
||||
m_xrot += (event.GetY() - last_y)*1.0;
|
||||
m_yrot += event.GetX() - last_x;
|
||||
m_xrot += event.GetY() - last_y;
|
||||
Refresh(false);
|
||||
}
|
||||
last_x = event.GetX();
|
||||
|
@@ -247,10 +247,10 @@ void TestGLCanvas::OnMouse(wxMouseEvent& event)
|
||||
/* drag in progress, simulate trackball */
|
||||
float spin_quat[4];
|
||||
trackball(spin_quat,
|
||||
(2.0*m_gldata.beginx - sz.x) / sz.x,
|
||||
(sz.y - 2.0*m_gldata.beginy) / sz.y,
|
||||
(2.0*event.GetX() - sz.x) / sz.x,
|
||||
(sz.y - 2.0*event.GetY()) / sz.y);
|
||||
(2 * m_gldata.beginx - sz.x) / sz.x,
|
||||
(sz.y - 2 * m_gldata.beginy) / sz.y,
|
||||
(2 * event.GetX() - sz.x) / sz.x,
|
||||
(sz.y - 2 * event.GetY()) / sz.y);
|
||||
|
||||
add_quats(spin_quat, m_gldata.quat, m_gldata.quat);
|
||||
|
||||
@@ -315,7 +315,7 @@ void TestGLCanvas::ResetProjectionMode()
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(45.0f, (GLfloat)ClientSize.x/ClientSize.y, 1.0, 100.0);
|
||||
gluPerspective(45, double(ClientSize.x) / ClientSize.y, 1, 100);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
@@ -113,7 +113,7 @@ vcross(const float *v1, const float *v2, float *cross)
|
||||
float
|
||||
vlength(const float *v)
|
||||
{
|
||||
return (float) sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
|
||||
return (float) sqrt((double)(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -192,9 +192,9 @@ trackball(float q[4], float p1x, float p1y, float p2x, float p2y)
|
||||
/*
|
||||
* Avoid problems with out-of-control values...
|
||||
*/
|
||||
if (t > 1.0) t = 1.0;
|
||||
if (t < -1.0) t = -1.0;
|
||||
phi = 2.0f * (float) asin(t);
|
||||
if (t > 1) t = 1;
|
||||
if (t < -1) t = -1;
|
||||
phi = 2 * (float) asin((double)t);
|
||||
|
||||
axis_to_quat(a,phi,q);
|
||||
}
|
||||
@@ -207,8 +207,8 @@ axis_to_quat(float a[3], float phi, float q[4])
|
||||
{
|
||||
vnormal(a);
|
||||
vcopy(a, q);
|
||||
vscale(q, (float) sin(phi/2.0));
|
||||
q[3] = (float) cos(phi/2.0);
|
||||
vscale(q, (float) sin((double)phi / 2));
|
||||
q[3] = (float) cos((double)phi / 2);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -220,9 +220,9 @@ tb_project_to_sphere(float r, float x, float y)
|
||||
{
|
||||
float d, t, z;
|
||||
|
||||
d = (float) sqrt(x*x + y*y);
|
||||
if (d < r * 0.70710678118654752440) { /* Inside sphere */
|
||||
z = (float) sqrt(r*r - d*d);
|
||||
d = (float) sqrt((double)(x*x + y*y));
|
||||
if (d < r * 0.70710678118654752440f) { /* Inside sphere */
|
||||
z = (float) sqrt((double)(r*r - d*d));
|
||||
} else { /* On hyperbola */
|
||||
t = r / 1.41421356237309504880f;
|
||||
z = t*t / d;
|
||||
|
@@ -21,6 +21,7 @@ class myVec3
|
||||
public:
|
||||
myVec3() { x = y = z = 0.0 ;}
|
||||
myVec3(double xd, double yd, double zd) : x(xd), y(yd), z(zd) {}
|
||||
myVec3(float xd, float yd, float zd) : x(double(xd)), y(double(yd)), z(double(zd)) {}
|
||||
~myVec3() {}
|
||||
|
||||
double x, y, z;
|
||||
|
@@ -1187,16 +1187,16 @@ void myOGLManager::SetStringOnPyr(const unsigned char* strImage, int iWidth, int
|
||||
double edgeLen = MyDistance(myVec3(gVerts[0], gVerts[1], gVerts[2]),
|
||||
myVec3(gVerts[6], gVerts[7], gVerts[8]));
|
||||
GLfloat prop = ((GLfloat) iHeigh) / ((GLfloat) iWidth);
|
||||
GLfloat rw = (GLfloat) (edgeLen / (1 + 4.0 * prop / sqrt(3.0)));
|
||||
GLfloat rw = float(edgeLen) / (1 + 4 * prop / std::sqrt(3.0f));
|
||||
GLfloat h = prop * rw;
|
||||
GLfloat de = (GLfloat)(2.0 * h / sqrt(3.0));
|
||||
GLfloat de = 2 * h / std::sqrt(3.0f);
|
||||
// A bit of separation of the face so as to avoid z-fighting
|
||||
GLfloat rY = gVerts[1] - (GLfloat)0.01; // Towards outside
|
||||
GLfloat rY = gVerts[1] - 0.01f; // Towards outside
|
||||
GLfloat sVerts[12];
|
||||
// The image was created top to bottom, but OpenGL axis are bottom to top.
|
||||
// The image would display upside down. We avoid it choosing the right
|
||||
// order of vertices and texture coords. See myOGLString::SetStringWithVerts()
|
||||
sVerts[0] = gVerts[6] + de; sVerts[1] = rY; sVerts[2] = gVerts[8] + h / (GLfloat)2.0;
|
||||
sVerts[0] = gVerts[6] + de; sVerts[1] = rY; sVerts[2] = gVerts[8] + h / 2;
|
||||
sVerts[3] = sVerts[0] ; sVerts[4] = rY; sVerts[5] = sVerts[2] + h;
|
||||
sVerts[6] = sVerts[0] + rw; sVerts[7] = rY; sVerts[8] = sVerts[2];
|
||||
sVerts[9] = sVerts[6] ; sVerts[10] = rY; sVerts[11] = sVerts[5];
|
||||
|
Reference in New Issue
Block a user