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. glGetString(GL_VERSION) returns NULL
Forum Updated to NodeBB v4.3 + New Features

glGetString(GL_VERSION) returns NULL

Scheduled Pinned Locked Moved General and Desktop
16 Posts 4 Posters 10.1k Views 3 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.
  • P Offline
    P Offline
    Paul H.
    wrote on 10 Jul 2015, 19:11 last edited by
    #2

    Have you tried using the windeployqt tool instead of copying everything manually?
    Paul

    1 Reply Last reply
    1
    • F Offline
      F Offline
      floatingWoods
      wrote on 10 Jul 2015, 19:58 last edited by
      #3

      Thank you Paul,

      I have tried that, but the result is the same..

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Paul H.
        wrote on 10 Jul 2015, 20:13 last edited by
        #4

        You can try comparing the path in QT Creator environment under Projects with the path in the command shell and see if anything is different. That might point you in the right direction. Can you build the application from the command shell you are using?
        Paul

        1 Reply Last reply
        1
        • F Offline
          F Offline
          floatingWoods
          wrote on 12 Jul 2015, 09:27 last edited by
          #5

          Thanks again Paul.

          That didn't help unfortunately. But I discovered something that could give a clue as to what is going wrong:

          So I called this time the glGetString openGl function twice, once directly (as is done in the whole application), and once via QOpenGLFunctions:

          const char* gl_version=(const char*)(glGetString(GL_VERSION));
          printf("called directly: glVersion: %s\n",gl_version);
          
          QOpenGLFunctions* f=openglWidget->context()->functions();
          gl_version=(const char*)(f->glGetString(GL_VERSION));
          printf("called via QOpenGLFunctions: glVersion: %s\n",gl_version);
          

          When I start the application via QtCreator, I get:

          called directly: glVersion: 4.3.0
          called via QOpenGLFunctions: glVersion: 4.3.0
          

          When I start the application via the command line, for the ready-to-ship application, I get:

          called directly: glVersion: (null)
          called via QOpenGLFunctions: glVersion: OpenGL ES 2.0 (ANGLE 2.1.99f075dade7c)
          

          I know it is best to call all gl functions via the second method, but the application is very large and openGl code is all over the place. So it will take quite some time to refactor things. But until then, I wish to be able to continue calling openGl functions directly.

          Do I need to change a setting in order to be able to do it?
          For information, that application is only deployed on desktops (Windows, Max and Linux)

          Thanks!

          1 Reply Last reply
          0
          • F Offline
            F Offline
            floatingWoods
            wrote on 12 Jul 2015, 11:49 last edited by
            #6

            I can also confirm that the problem is not directly linked to QOpenGLWidget: when still using QGLWidget, I have the same result.

            When I had to port the application from Qt 5.1 to Qt5.5 I had to add following line in the Qt project file, which wasn't needed in Qt 5.1:

            LIBS += -lopengl32
            

            Without above line, Qt5.5 doesn't recognize the OpenGl standard functions (such as glBegin, etc.)
            Might this be another clue?

            1 Reply Last reply
            0
            • P Offline
              P Offline
              Paul H.
              wrote on 12 Jul 2015, 14:44 last edited by
              #7

              Well, it is reporting different versions in the different environments. I would try running process explorer and see what dlls are being used for each environment.
              Paul

              1 Reply Last reply
              1
              • F Offline
                F Offline
                floatingWoods
                wrote on 12 Jul 2015, 21:22 last edited by
                #8

                Ok, so I used the process explorer, and noticed that the deployed application (i.e. the one not launched via QtCreator) is has libGLESV2.dll loaded. How come? I do not need GL ES, nor do I want it (my application still uses old OpenGL fixed-pipeline code).

                Searching the internet for libGLESV2.dll, I found out that libGLESv2.dll is distributed by Mozilla Foundation and used by Firefox 9.0.1 application. How come my application is using it? How can I prevent this?

                Thanks

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 12 Jul 2015, 22:01 last edited by
                  #9

                  Hi,

                  IIRC, Qt on Windows loads at runtime either the OpenGL or ANGLE backend depending on what you have available on the machine where you run the application. You might be seeing that happening.

                  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
                  • F Offline
                    F Offline
                    floatingWoods
                    wrote on 13 Jul 2015, 09:22 last edited by
                    #10

                    Thanks Samuel.

                    I basically don't need OpenGL ES, I am just using old fixed-pipeline OpenGl commands (probably not much more than OpenGl 2.0). What are my options?

                    I also tried to deploy the application by specifying that I don't want the ANGLE library (--no-angle), but then, I get a bunch of messages (then a crash) like:

                    Failed to load libEGL.dll ...
                    static QWindowsEGLStaticContext* QWindowsEGLStaticCOntext::create(QWindowsOpenGLTester::Renderers): Failed to load and resolve libEGL functions
                    ...
                    

                    Thanks

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 13 Jul 2015, 20:51 last edited by
                      #11

                      How are you doing the deployment ?

                      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
                      • F Offline
                        F Offline
                        floatingWoods
                        wrote on 15 Jul 2015, 14:57 last edited by
                        #12

                        Sorry for the delay..
                        I deploy the application (which is a library (loaded by an executable)) with:

                        windeployqt --no-angle directoryToMyDll\myDll.dll
                        

                        It then tells me:

                        To be deployed: Qt5Core Qt5Gui Qt5Network Qt5OpenGL Qt5Svg Qt5Widgets
                        

                        Thanks

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 19 Jul 2015, 15:06 last edited by
                          #13

                          I'm not sure I'm following you, you have a Qt application + library to deploy ?

                          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
                          • I Offline
                            I Offline
                            IanMoone
                            wrote on 20 Jul 2015, 10:32 last edited by IanMoone
                            #14

                            I have the same issue :
                            https://bugreports.qt.io/browse/QTBUG-47105

                            I force Qt to use OpenGL instead of Angle and it's not enough, I also link statically openGL library.
                            The openGL context is necessary created cause, we call glGetString after the display of the splash screen of the application.

                            Edit:
                            I want to check the QOpenGLContext::currentContext() ptr, but I can't make it build, the QOpenGLContext header doesn't provide the class definition.

                            1 Reply Last reply
                            1
                            • F Offline
                              F Offline
                              floatingWoods
                              wrote on 21 Jul 2015, 10:03 last edited by
                              #15

                              I have prepared a minimalistic application that illustrates the problem.

                              The minimalistic application will build a QMainWindow, and set a QOpenGlWidget-derived widget as the central element. Then, in that widget, in the initializeGL function I check the GL_VERSION. When I run it from QtCreator, it works fine. When I deploy the application and I run it from the command line, it fails with the glGetString function.
                              Here the minimalistic application:

                              Project file:

                              QT			+=	widgets opengl
                              LIBS		+=	-lopengl32
                              QT			+=	core
                              
                              HEADERS		=	myGlWidgetClass.h
                              SOURCES		=	myGlWidgetClass.cpp \
                              			main.cpp
                              

                              The QOpenGLWidget-derived class (header):

                              #include <QOpenGLWidget>
                              class MyGlWidgetClass : public QOpenGLWidget
                              {
                              	Q_OBJECT
                              public:
                              	MyGlWidgetClass(QWidget *parent = 0);
                              	~MyGlWidgetClass();
                              protected:
                              	void initializeGL();
                              };
                              #endif
                              

                              The QOpenGLWidget-derived class (implementation):

                              #include "myGlWidgetClass.h"
                              MyGlWidgetClass::MyGlWidgetClass(QWidget *parent) : QOpenGLWidget(parent)
                              {
                              }
                              
                              MyGlWidgetClass::~MyGlWidgetClass()
                              {
                              }
                              
                              void MyGlWidgetClass::initializeGL()
                              {
                              	const char* gl_version=(const char*)(glGetString(GL_VERSION));
                              	if (gl_version==NULL)
                              		Beep(4000,500);
                              }
                              

                              And the application main code:

                              #include <QApplication>
                              #include <QMainWindow>
                              #include "myGlWidgetClass.h"
                              int main(int argc, char *argv[])
                              {
                              	QApplication app(argc, argv);
                              	QMainWindow myMainWindow;
                              	myMainWindow.setCentralWidget(new MyGlWidgetClass(&myMainWindow));
                              	myMainWindow.showNormal();
                              	return app.exec();
                              }
                              

                              I also have to mention again that this problem happens with Qt 5.5, but not with Qt5.1.1 (both on Windows 8.1). (with Qt5.1.1, simply replace QOpenGLWidget with QGLWidget (since QOpenGLWidget is new since Qt5.4))

                              Thanks

                              1 Reply Last reply
                              0
                              • F Offline
                                F Offline
                                floatingWoods
                                wrote on 21 Jul 2015, 21:46 last edited by
                                #16

                                Hello again,

                                for your info: I am able to invert the problem with following code before building the application:

                                QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL,true);
                                

                                With invert, I mean that with above call, I can run my application from the command line, but not from QtCreator anymore (only a black screen in that case, not even the toolbar buttons are visible anymore)

                                Details and a demo application that illustrates the problem can be found here

                                Thanks

                                1 Reply Last reply
                                0

                                11/16

                                13 Jul 2015, 20:51

                                • Login

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