diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-02-14 10:23:27 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2015-02-14 09:29:45 +0000 |
commit | ed0457ce6d655fa42ada6f71780344a6bd97d9b9 (patch) | |
tree | db44f6ae36a7954e4d7dffec0d4443dcedf4ead1 /examples | |
parent | 3e1887c023b09826380ecc47445c08048f585fd0 (diff) |
Use Qt wrappers for math functions
Make sure it builds on obscure platforms like WinCE.
Functions like cosf live in some unexpected headers there.
Best is to avoid the issue altogether by using the qmath functions.
Change-Id: I3cbf0f811aef36997ad38db431426e9eb582198b
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/bigscene-cpp/main.cpp | 4 | ||||
-rw-r--r-- | examples/dynamicscene-cpp/boxentity.cpp | 4 | ||||
-rw-r--r-- | examples/dynamicscene-cpp/examplescene.cpp | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/examples/bigscene-cpp/main.cpp b/examples/bigscene-cpp/main.cpp index c6fb4df37..5ab25bf5e 100644 --- a/examples/bigscene-cpp/main.cpp +++ b/examples/bigscene-cpp/main.cpp @@ -111,12 +111,12 @@ int main(int ac, char **av) const float angle = M_PI * 2.0f * i * det * 10.; - material->setDiffuse(QColor(fabs(cosf(angle)) * 255, 204, 75)); + material->setDiffuse(QColor(qFabs(qCos(angle)) * 255, 204, 75)); material->setAmbient(Qt::gray); material->setSpecular(Qt::white); material->setShininess(150.0f); - translation->setTranslation(QVector3D(radius * cos(angle), 200.* i * det, radius * sin(angle))); + translation->setTranslation(QVector3D(radius * qCos(angle), 200.* i * det, radius * qSin(angle))); rotateX->setAxis(QVector3D(1.0f, 0.0f, 0.0f)); rotateZ->setAxis(QVector3D(0.0f, 0.0f, 1.0f)); rotateX->setAngleDeg(30.0f * i); diff --git a/examples/dynamicscene-cpp/boxentity.cpp b/examples/dynamicscene-cpp/boxentity.cpp index dea4b9365..a3f539564 100644 --- a/examples/dynamicscene-cpp/boxentity.cpp +++ b/examples/dynamicscene-cpp/boxentity.cpp @@ -101,8 +101,8 @@ float BoxEntity::radius() const void BoxEntity::updateTransformation() { - m_translate->setTranslation(QVector3D(cosf(m_angle) * m_radius, + m_translate->setTranslation(QVector3D(qCos(m_angle) * m_radius, 1.0f, - sinf(m_angle) * m_radius)); + qSin(m_angle) * m_radius)); } diff --git a/examples/dynamicscene-cpp/examplescene.cpp b/examples/dynamicscene-cpp/examplescene.cpp index fe0c46108..ca15b1a9f 100644 --- a/examples/dynamicscene-cpp/examplescene.cpp +++ b/examples/dynamicscene-cpp/examplescene.cpp @@ -80,7 +80,7 @@ void ExampleScene::buildScene() const float angle = M_PI * 2.0f * float(i) / count; entity->setAngle(angle); entity->setRadius(radius); - entity->setDiffuseColor(QColor(fabs(cosf(angle)) * 255, 204, 75)); + entity->setDiffuseColor(QColor(qFabs(qCos(angle)) * 255, 204, 75)); m_entities.append(entity); } } |