path: root/examples/widgets/graphicsview/boxes/glbuffers.cpp
diff options
authorEdward Welbourne <>2017-02-21 17:14:37 +0100
committerGiuseppe D'Angelo <>2017-07-05 10:15:34 +0000
commit8095c33bcddefebd16b7cb08b07690caf877f600 (patch)
tree816731835b77eb798295c4324f95b23f9916ebef /examples/widgets/graphicsview/boxes/glbuffers.cpp
parent827e53540c8de10f3a0b8548523ca80bf9e1c75b (diff)
Use qRadiansToDegrees() and qDegreesToRadians() more widely
Especially in examples, where we should show off our convenience functions, prefer calling these functions over doing arithmetic with M_PI (or approximations thereto) and 180 (give or take simple factors). This incidentally documents what's going on, just by the name of the function used (and reveals at least one place where variables were misnamed; the return from atan is in radians, *not* degrees). Task-number: QTBUG-58083 Change-Id: I6e5d66721cafab423378f970af525400423e971e Reviewed-by: Jüri Valdmann <> Reviewed-by: Allan Sandfeld Jensen <> Reviewed-by: Marc Mutz <>
Diffstat (limited to 'examples/widgets/graphicsview/boxes/glbuffers.cpp')
1 files changed, 2 insertions, 2 deletions
diff --git a/examples/widgets/graphicsview/boxes/glbuffers.cpp b/examples/widgets/graphicsview/boxes/glbuffers.cpp
index 1481292e76..851cd17796 100644
--- a/examples/widgets/graphicsview/boxes/glbuffers.cpp
+++ b/examples/widgets/graphicsview/boxes/glbuffers.cpp
@@ -50,11 +50,11 @@
#include "glbuffers.h"
#include <QtGui/qmatrix4x4.h>
+#include <QtCore/qmath.h>
void qgluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar)
- const GLdouble ymax = zNear * tan(fovy * M_PI / 360.0);
+ const GLdouble ymax = zNear * tan(qDegreesToRadians(fovy) / 2.0);
const GLdouble ymin = -ymax;
const GLdouble xmin = ymin * aspect;
const GLdouble xmax = ymax * aspect;