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
Forum Updated to NodeBB v4.3 + New Features

Qt gets matrix data

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 503 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.
  • Q Offline
    Q Offline
    Qt_crazyer
    wrote on 28 Mar 2018, 09:54 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);
        }
    }
    
    
    B 1 Reply Last reply 30 Mar 2018, 07:58
    0
    • Q Qt_crazyer
      28 Mar 2018, 09:54

      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);
          }
      }
      
      
      B Offline
      B Offline
      beecksche
      wrote on 30 Mar 2018, 07:58 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

      1/2

      28 Mar 2018, 09:54

      • Login

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