1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| void OpenGLScene::drawBackground(QPainter *painter, const QRectF &)
{
if (painter->paintEngine()->type() != QPaintEngine::OpenGL) {
qWarning("OpenGLScene: drawBackground needs a QGLWidget to be set as viewport on the graphics view");
return;
}
glClearColor(m_backgroundColor.redF(), m_backgroundColor.greenF(), m_backgroundColor.blueF(), 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(zoom, width() / height(), near, far);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt( x1, moyenne[1], z1,
x0, moyenne[1], z0,
0, 1, 0 );
GLfloat x2 = cos(angle) * (x1 - x0) + sin(angle) * (z1 - z0) + x0;
GLfloat z2 = cos(angle) * (z1 - z0) - sin(angle) * (x1 - x0) + z0;
x1 = x2;
z1 = z2;
glBegin(GL_POINTS);
for(int i=0;i<nbPoints;i++){
glPushMatrix();
glColor3f(tab[i * 6 + 3] / 255.0f,tab[i * 6 + 4] / 255.0f,tab[i * 6 + 5] / 255.0f);
glVertex3f(tab[i * 6],tab[i * 6 + 1],tab[i * 6 + 2]);
glPopMatrix();
}
glEnd();
zoom += 0.1;
qDebug() << zoom;
} |
Partager