How to translate Qt3d shapes (like a sphere) continually.
-
hi , i am trying to draw sphere that changes its place continually, i tried this :
@
void GLWidget::paintGL(QGLPainter *painter)
{
while (true)
{
vertex.setX(qrand()%5);
vertex.setY(qrand()%5);
vertex.setZ(qrand()%5);
painter->modelViewMatrix().translate(vertex);
sphere->draw(painter);
}
}
@where :
" sphere " is a QGLSceneNode.
" vertex " is a QVector3D.the result of the previous code is :
the sphere position is being changed when i zoom in or out or when i move around it (with the mouse ) , but not automatically !!???
i think i must use QGLBuffer . -
Hi and welcome to devnet,
You should not use a while loop, you are locking your program in paintGL and he can't to anything else. Just use the standard approach that updates your GL scene at a regular fps and you should be good.
-
thank you very much , i am glad to be here ....
my class descending from "QGLView" and it seems that there is no way to call updateGL() from it ,so what should i do ? .
on the other hand , i have made another project that uses "QGLWidget" and " QGLBuffer" , and i easily used updateGL() , however the advantage of using " QGLView " class is the ease of using " QGLBuilder " to build spheres .
is there away to call " updateGL() " in a class that inherit from "QGLView " class , or a way to use " QGLSphere " in a class inherit from "QGLWidget "? -
AFAIK, QGLView inherit QGLWidget so you should be able to call updateGL
What error are you getting ?
-
What error are you getting when calling updateGL ?
-
Hi, I am stuck with the same problem. Could you figure out a solution for the same?
-
Hi, I am stuck with the same problem. Could you figure out a solution for the same?
-
I've made a mistake, QGLView inherits QWindow where there's no updateGL.
-
I've made a mistake, QGLView inherits QWindow where there's no updateGL.
-
But, is there any update method in QGLView?
-
But, is there any update method in QGLView?