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

OpenGL gluPickMatrix not existing

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 4 Posters 1.6k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    IIRC this header comes from the glu library. On Debian it's the libglu1-mesa-dev package.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    1
    • S Offline
      S Offline
      sandro4912
      wrote on last edited by
      #3

      OK i could install it. But what else do i have to do that the project finds it?

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        Taking a look at the package content, the header is under "GL/glu.h".

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sandro4912
          wrote on last edited by
          #5

          I added the header however its not found.

          Steps i took:

          sudo apt-get update
          sudo apt-get install libglu1-mesa-dev
          

          Restart the project and

          #include "gl/glu.h"

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #6

            Casing is important.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1
            • S Offline
              S Offline
              sandro4912
              wrote on last edited by
              #7

              Ok I changed it to the correct:

              "GL/glu.h".

              It looks like it is found. However when i compile i still get an error with the gluPickMatrix like this:

              ../tetrahedron/tetrahedron.cpp:128: undefined reference togluPickMatrix'
              `

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #8

                You need to also link to libGLU.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                2
                • W Offline
                  W Offline
                  wrosecrans
                  wrote on last edited by
                  #9

                  GLU was last updated in the 1990's, it's basically deprecated, and depends on functionality that was deprecated from OpenGL years ago. Ideally you should find a different way of doing what you are trying to accomplish. If you are using any kind of modern OpenGL with vertex shaders from the last ~15 - 20 years, GLU will have no idea how to understand your projection matrices, and the results it gives you will be nonsensical or wrong even if you get it working.

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    sandro4912
                    wrote on last edited by
                    #10

                    The whole code which uses the gluPickMatrix looks like this.

                    int Tetrahedron::faceAtPosition(const QPoint &pos)
                    {
                        constexpr int MaxSize = 512;
                        GLuint buffer[MaxSize];
                        GLint viewport[4];
                    
                        makeCurrent();
                    
                        glGetIntegerv(GL_VIEWPORT, viewport);
                        glSelectBuffer(MaxSize, buffer);
                        glRenderMode(GL_SELECT);
                    
                        glInitNames();
                        glPushName(0);
                    
                        glMatrixMode(GL_PROJECTION);
                        glPushMatrix();
                        glLoadIdentity();
                        gluPickMatrix(GLdouble(pos.x()), GLdouble(viewport[3] - pos.y()),
                                      5.0, 5.0, viewport);
                        GLdouble x = GLdouble(width()) / height();
                        glFrustum(-x, x, -1.0, 1.0, 4.0, 15.0);
                        draw();
                        glMatrixMode(GL_PROJECTION);
                        glPopMatrix();
                    
                        if (!glRenderMode(GL_RENDER)) {
                            return -1;
                        }
                        return static_cast<int>(buffer[3]);
                    }
                    

                    What would be an alternative?

                    And how can i link against libGLU?

                    jsulmJ 1 Reply Last reply
                    0
                    • S sandro4912

                      The whole code which uses the gluPickMatrix looks like this.

                      int Tetrahedron::faceAtPosition(const QPoint &pos)
                      {
                          constexpr int MaxSize = 512;
                          GLuint buffer[MaxSize];
                          GLint viewport[4];
                      
                          makeCurrent();
                      
                          glGetIntegerv(GL_VIEWPORT, viewport);
                          glSelectBuffer(MaxSize, buffer);
                          glRenderMode(GL_SELECT);
                      
                          glInitNames();
                          glPushName(0);
                      
                          glMatrixMode(GL_PROJECTION);
                          glPushMatrix();
                          glLoadIdentity();
                          gluPickMatrix(GLdouble(pos.x()), GLdouble(viewport[3] - pos.y()),
                                        5.0, 5.0, viewport);
                          GLdouble x = GLdouble(width()) / height();
                          glFrustum(-x, x, -1.0, 1.0, 4.0, 15.0);
                          draw();
                          glMatrixMode(GL_PROJECTION);
                          glPopMatrix();
                      
                          if (!glRenderMode(GL_RENDER)) {
                              return -1;
                          }
                          return static_cast<int>(buffer[3]);
                      }
                      

                      What would be an alternative?

                      And how can i link against libGLU?

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      @sandro4912 said in OpenGL gluPickMatrix not existing:

                      And how can i link against libGLU?
                      Add

                      LIBS += -lGLU
                      

                      to your pro file.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      1
                      • S Offline
                        S Offline
                        sandro4912
                        wrote on last edited by
                        #12

                        The linking worked.

                        However i found this approach to implement gluPickMatrix and not need the glu library:

                        void gluPickMatrix(
                                GLdouble x, GLdouble y, GLdouble deltax, GLdouble deltay,
                                GLint viewport[4])
                        {
                           if (deltax <= 0 || deltay <= 0) {
                               return;
                             }
                        
                           /* Translate and scale the picked region to the entire window */
                           glTranslated((viewport[2] - 2 * (x - viewport[0])) / deltax,
                                   (viewport[3] - 2 * (y - viewport[1])) / deltay, 0);
                           glScaled(viewport[2] / deltax, viewport[3] / deltay, 1.0);
                        }
                        
                        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