Hello ,
for my last question , i had to use glLoadMatrix function before drawing my cube: @glLoadMatrixf(matrix.constData());@
@qDebug() << “Transformed pos =” << m * QVector3D( 1.0f, 1.0f, 1.0f );@ unfortunately,it still not giving me the coordinates of vertices. Don't know where is the problem. i had put that line in my paint function. is it correct??
However , these last days i started to read about Modern openGL, in order to use the first solution given to me here, to get my new vertices' coordinates. My code is like that now:
@
void GLWidget::paintGL()
{
QMatrix4x4 matrixTransformation;
matrixTransformation.rotate(alpha, 0,1,0);
matrixTransformation.rotate(beta, 0, 1, 0);
QVector3D cameraPosition = matrixTransformation * QVector3D(0,0,distance);
QVector3D cameraUpDirection = matrixTransformation * QVector3D(0, 1, 0);
vMatrix.lookAt(cameraPosition, QVector3D(), cameraUpDirection);
// display the coordinates
foreach(const QVector3D& p, cameraPosition) {
qDebug() << "Rotated position =" << matrixTransformation * p;
}
shaderProgram.bind();
shaderProgram.setUniformValue("mvpMatrix", pMatrix * vMatrix *mMatrix);
shaderProgram.setUniformValue("color", QColor(Qt::white));
shaderProgram.setAttributeArray("vertex", vertices.constData());
shaderProgram.enableAttributeArray("vertex");
glDrawArrays(GL_TRIANGLES, 0,vertices.size());
shaderProgram.disableAttributeArray("vertex");
shaderProgram.release();}@
}
an error appeared : error C2039: 'const_iterator' : is not a member of 'QVector3D'
error C2039: 'i' : is not a member of 'QForeachContainer<QVector3D>'
I had included <Vector > and <iterator> in my header but the error still there.
Is the way i used correct to get the coordinates of vertices??
the error is from my foreach loop code, and is maybe about the declaration of QVector3D in a qvector3d.h of Qt. How to solve it??
thanks and sorry for my questions which are maybe stupid, but i 'm still learning OpenGL.