Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to use opengl on qt ?
QtWS25 Last Chance

How to use opengl on qt ?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    shadowfox
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qxoz
      wrote on last edited by
      #2

      Maybe using Signals and Slots for timing more preferred?

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved