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. Qt gets matrix data
Qt 6.11 is out! See what's new in the release blog

Qt gets matrix data

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.2k Views 1 Watching
  • 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.
  • Qt_crazyerQ Offline
    Qt_crazyerQ Offline
    Qt_crazyer
    wrote on last edited by
    #1

    I am drawing some 3D graphics on QOpenGLWidget. I want to use glGetFloatv(GL_MODELVIEW_MATRIX, m) to get the model-view matrix. But a problem occurs. When I use this function in my paintGL loop. I can get the right results. When I put this function in the mousePressEvent, the matrix m always an unit matrix.
    Is it related to the Thread? Thanks in advance.
    Qt Creator 5.9.1 on windows10

    float m[16];
    
    void Coordinary::paintGL()
    {
        const qreal retinaScale = devicePixelRatio();
        glViewport(0, 0, width() * retinaScale, height() * retinaScale);
    
        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    
        glBegin(GL_TRIANGLES);
    
        glColor3f(1.0f,0.2f,0.3f);
        glVertex3f(1.0f,0.0f,0.0f);
        glColor3f(0.4f,1.0f,0.8f);
        glVertex3f(0.0f,1.0f,0.0f);
        glColor3f(0.1f,0.7f,1.0f);
        glVertex3f(0.0f,0.0f,1.0f);
    
        glEnd();
    
        update();
    
        glGetFloatv(GL_MODELVIEW_MATRIX, m);
    }
    
    void Coordinary::mousePressEvent(QMouseEvent *event)
    {
        if(event->button() == Qt::RightButton)
        {
            glGetFloatv(GL_MODELVIEW_MATRIX, m);
        }
    }
    
    
    beeckscheB 1 Reply Last reply
    0
    • Qt_crazyerQ Qt_crazyer

      I am drawing some 3D graphics on QOpenGLWidget. I want to use glGetFloatv(GL_MODELVIEW_MATRIX, m) to get the model-view matrix. But a problem occurs. When I use this function in my paintGL loop. I can get the right results. When I put this function in the mousePressEvent, the matrix m always an unit matrix.
      Is it related to the Thread? Thanks in advance.
      Qt Creator 5.9.1 on windows10

      float m[16];
      
      void Coordinary::paintGL()
      {
          const qreal retinaScale = devicePixelRatio();
          glViewport(0, 0, width() * retinaScale, height() * retinaScale);
      
          glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
      
          glBegin(GL_TRIANGLES);
      
          glColor3f(1.0f,0.2f,0.3f);
          glVertex3f(1.0f,0.0f,0.0f);
          glColor3f(0.4f,1.0f,0.8f);
          glVertex3f(0.0f,1.0f,0.0f);
          glColor3f(0.1f,0.7f,1.0f);
          glVertex3f(0.0f,0.0f,1.0f);
      
          glEnd();
      
          update();
      
          glGetFloatv(GL_MODELVIEW_MATRIX, m);
      }
      
      void Coordinary::mousePressEvent(QMouseEvent *event)
      {
          if(event->button() == Qt::RightButton)
          {
              glGetFloatv(GL_MODELVIEW_MATRIX, m);
          }
      }
      
      
      beeckscheB Offline
      beeckscheB Offline
      beecksche
      wrote on last edited by
      #2

      Hi @Qt_crazyer

      i'm really not into OpenGL but try the QOpenGLFunctions:

      QOpenGLFunctions *glFuncs = QOpenGLContext::currentContext()->functions();
      glFuncs-> glGetFloatv(GL_MODELVIEW_MATRIX, m);
      
      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