summaryrefslogtreecommitdiffstats
path: root/examples/opengl/legacy
diff options
context:
space:
mode:
Diffstat (limited to 'examples/opengl/legacy')
-rw-r--r--examples/opengl/legacy/overpainting/bubble.cpp10
-rw-r--r--examples/opengl/legacy/overpainting/glwidget.cpp12
2 files changed, 12 insertions, 10 deletions
diff --git a/examples/opengl/legacy/overpainting/bubble.cpp b/examples/opengl/legacy/overpainting/bubble.cpp
index afc50117d0..352e359cf9 100644
--- a/examples/opengl/legacy/overpainting/bubble.cpp
+++ b/examples/opengl/legacy/overpainting/bubble.cpp
@@ -50,6 +50,8 @@
#include "bubble.h"
+#include <QRandomGenerator>
+
Bubble::Bubble(const QPointF &position, qreal radius, const QPointF &velocity)
: position(position), vel(velocity), radius(radius)
{
@@ -80,10 +82,10 @@ void Bubble::drawBubble(QPainter *painter)
QColor Bubble::randomColor()
{
- int red = int(205 + 50.0*qrand()/(RAND_MAX+1.0));
- int green = int(205 + 50.0*qrand()/(RAND_MAX+1.0));
- int blue = int(205 + 50.0*qrand()/(RAND_MAX+1.0));
- int alpha = int(91 + 100.0*qrand()/(RAND_MAX+1.0));
+ int red = int(205 + QRandomGenerator::global()->bounded(50));
+ int green = int(205 + QRandomGenerator::global()->bounded(50));
+ int blue = int(205 + QRandomGenerator::global()->bounded(50));
+ int alpha = int(91 + QRandomGenerator::global()->bounded(100));
return QColor(red, green, blue, alpha);
}
diff --git a/examples/opengl/legacy/overpainting/glwidget.cpp b/examples/opengl/legacy/overpainting/glwidget.cpp
index 7e9f4a5beb..1ec7bd731c 100644
--- a/examples/opengl/legacy/overpainting/glwidget.cpp
+++ b/examples/opengl/legacy/overpainting/glwidget.cpp
@@ -53,6 +53,7 @@
#include "glwidget.h"
#include <QMouseEvent>
+#include <QRandomGenerator>
#include <QTime>
#include <math.h>
@@ -67,7 +68,6 @@ GLWidget::GLWidget(QWidget *parent)
: QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
{
QTime midnight(0, 0, 0);
- qsrand(midnight.secsTo(QTime::currentTime()));
logo = 0;
xRot = 0;
@@ -234,11 +234,11 @@ QSize GLWidget::sizeHint() const
void GLWidget::createBubbles(int number)
{
for (int i = 0; i < number; ++i) {
- QPointF position(width()*(0.1 + (0.8*qrand()/(RAND_MAX+1.0))),
- height()*(0.1 + (0.8*qrand()/(RAND_MAX+1.0))));
- qreal radius = qMin(width(), height())*(0.0125 + 0.0875*qrand()/(RAND_MAX+1.0));
- QPointF velocity(width()*0.0125*(-0.5 + qrand()/(RAND_MAX+1.0)),
- height()*0.0125*(-0.5 + qrand()/(RAND_MAX+1.0)));
+ QPointF position(width()*(0.1 + QRandomGenerator::global()->bounded(0.8)),
+ height()*(0.1 + QRandomGenerator::global()->bounded(0.8)));
+ qreal radius = qMin(width(), height())*(0.0125 + QRandomGenerator::global()->bounded(0.0875));
+ QPointF velocity(width()*0.0125*(-0.5 + QRandomGenerator::global()->bounded(1.0)),
+ height()*0.0125*(-0.5 + QRandomGenerator::global()->bounded(1.0)));
bubbles.append(new Bubble(position, radius, velocity));
}