Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. QOpenGlWidget and GLEW 2.0
QtWS25 Last Chance

QOpenGlWidget and GLEW 2.0

Scheduled Pinned Locked Moved Unsolved 3rd Party Software
7 Posts 2 Posters 3.1k 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.
  • A Offline
    A Offline
    AlKupone
    wrote on last edited by
    #1

    Hi,

    I know this is a very old topic, but I cannot seem to find a solution for this problem.
    I want to use GLEW 2.0 with QOpenGLWIdget as a window manager. I already did what most of the sites recommend: create a subclass of QOpenGLWidget, in initializeGL() first call makeCurrent() and then glewInit(). It works, the program can be compiled, I get no error messages and I can run my program. Now, as soon as I call an OpenGL function (like glClear) I get an error message:
    LNK2019 unresolved external symbol _imp_glClear referenced in function "public: init....)
    I don't understand this error. If I have a linker error, why does glewInit and glewExperimental work?

    I also did add a SurfaceFormat in my main:

    QSurfaceFormat format;
    format.setVersion(4, 5);
    format.setProfile(QSurfaceFormat::CoreProfile);
    format.setDepthBufferSize(24);
    QSurfaceFormat::setDefaultFormat(format);
    QApplication a(argc, argv);
    MainWindow mainWindow;
    mainWindow.show();
    return a.exec();
    

    Can anyone help me?
    Another question: does QOpenGLFunction contain native OpenGL API or OpenGL ES 2.0 (as I've read in some threads)?
    Thx!

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

      Hi and welcome to devnet,

      Because they are not in the same libraries.

      QOpenGLFunction provides the common subset of functions so check it to see if it have everything you need. Otherwise if you need functions only available in the 4.5 core profile, you can use the QOpenGLFunctions_4_5_Core class.

      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
      • A Offline
        A Offline
        AlKupone
        wrote on last edited by
        #3

        Thanks :)

        Hm, does this mean I need both libs: glew32 and glew32s? These are the only libraries that come with the include files.

        Oh, I didn't know there is a special class for 4.5 OpenGL.

        Thx

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

          AFAIK, the s means in this case static, so no you don't need both.

          AFAIK, there's one for each version of OpenGL.

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

          A 1 Reply Last reply
          0
          • A Offline
            A Offline
            AlKupone
            wrote on last edited by
            #5

            Hi,

            thanks for the answer, I managed to compile and run the program with GLEW :)
            Now I am facing a new problem: black window while rendering points.

            My workflow so far:
            MyWidget
            ::initGL() create the connections for signals ans slots, start GLEW and timer
            ::timer calls myUpdate() when timeout is called
            ::myUpdate() computes some values and calls update()
            ::paintGL() clears the window and calls custom shader::draw() function which uses GLEW for native OpenGL API

            MyShader
            ::construct() uses QOpenGLShaderProgram to compile and link the shaders; QOpenGLShaderProgram::link() returns true
            ::draw() calls glUseProgram(QOpenGLShaderProgram::programID), glPointSize(100.f), glDrawArrays(GL_POINTS, 0, 1) and glUseProgram(0) in that order. The result is a black window. I even call makeCurrent() before calling this function but it does not help. I get no shader compile errors. Are QOpenGLShaderProgram and GLEW interfering with eachother?

            Thx for the help!

            1 Reply Last reply
            0
            • SGaistS SGaist

              AFAIK, the s means in this case static, so no you don't need both.

              AFAIK, there's one for each version of OpenGL.

              A Offline
              A Offline
              AlKupone
              wrote on last edited by
              #6

              @SGaist If I subclass QOpenGLFunction_x_x, do I still need to call makeCurrent or pass the QOpenGLContext as an argument to my subclass?

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

                The QOpenGLFucntionXXX classes only provides your class with access to the OpenGL functions, it's still up to you to mange the context and friends properly.

                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

                • Login

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