How to use opengl on qt ?
-
well i can now draw a picture there. but it can't move.
for example i use this code in paintGL
@
void visualazition::paintGL(){glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glLoadIdentity(); for (int i=0;i<=10;i++){ glTranslatef( -1.5, 0.0, -6.0 ); glTranslatef( rTri, 0.0, -2.0 ); glBegin( GL_TRIANGLES ); glColor3f( 1.0, 0.0, 0.0 ); glVertex3f( 0.0, 1.0, 0.0 ); glColor3f( 0.0, 1.0, 0.0 ); glVertex3f( -1.0, -1.0, 0.0 ); glColor3f( 0.0, 0.0, 1.0 ); glVertex3f( 1.0, -1.0, 0.0 ); glEnd(); glLoadIdentity(); glTranslatef( 1.5, 0.0, -6.0 ); glRotatef( rQuad, 1.0, 0.0, 0.0 ); glColor3f( 0.5, 0.5, 1.0 ); glBegin( GL_QUADS ); glVertex3f( -1.0, 1.0, 0.0 ); glVertex3f( 1.0, 1.0, 0.0 ); glVertex3f( 1.0, -1.0, 0.0 ); glVertex3f( -1.0, -1.0, 0.0 ); glEnd(); QTime dieTime = QTime::currentTime().addMSecs(1000); while( QTime::currentTime() < dieTime ) QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); //glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); rTri += 0.2; rQuad -= 0.15;
}@
but it only show the final picture. i want to see tirangles moving on screen.