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

Qt and OpenGL3.3 Tutorial

Scheduled Pinned Locked Moved General and Desktop
11 Posts 4 Posters 4.0k 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.
  • M Offline
    M Offline
    milsabor
    wrote on 14 Oct 2013, 16:34 last edited by
    #1

    Hi.
    I'm running ubuntu 12.04 and I use Qt creator with the Qt 4.8 library.
    glxinfo informs me that I have OpenGL 3.3.0 and GLSL 3.3.0
    I'm trying to follow this tutorial : "http://qt-project.org/wiki/How_to_use_OpenGL_Core_Profile_with_Qt":http://qt-project.org/wiki/How_to_use_OpenGL_Core_Profile_with_Qt

    So I downloaded the provided source files and opened the project in Qt Creator. The compilation works fine but when I run the program, the window opens but the red triangle is not displayed, and I can't figure why because there is no error during the compilation.

    Thanks for your help

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 14 Oct 2013, 19:58 last edited by
      #2

      Hi and welcome to devnet,

      You should also check if you really got the format you asked for

      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
      • M Offline
        M Offline
        milsabor
        wrote on 14 Oct 2013, 20:16 last edited by
        #3

        Hi Sgaist, thank you for your answer.
        Unfortunately, I don't understand what you are asking me to check .. which format are you talking about ?
        Thanks

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 14 Oct 2013, 20:52 last edited by
          #4

          The QGLFormat created in the main.cpp

          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
          • M Offline
            M Offline
            milsabor
            wrote on 15 Oct 2013, 10:13 last edited by
            #5

            Ok, so here's what I did, I just added some debug lines to the existing code :
            @
            #include <QApplication>
            #include <QGLFormat>
            #include "glwidget.h"

            int main( int argc, char* argv[] )
            {
            QApplication a( argc, argv );

            // Specify an OpenGL 3.3 format using the Core profile.
            // That is, no old-school fixed pipeline functionality
            QGLFormat glFormat;
            glFormat.setVersion( 3, 3 );
            glFormat.setProfile&#40; QGLFormat::CoreProfile &#41;; // Requires >=Qt-4.8.0
            glFormat.setSampleBuffers( true );
            
            qDebug() << "OpenGL context QFlags " << glFormat.openGLVersionFlags();
            
            qDebug() << "OpenGL context " << glFormat;
            
            
            // Create a GLWidget requesting our format
            GLWidget w( glFormat );
            
            qDebug() << "OpenGL context" << w.format();
            
            qDebug() << "Driver Version String:" << glGetString(GL_VERSION);
            
            w.show();
            
            return a.exec&#40;&#41;;
            

            }

            @

            line 16 returns :
            @
            OpenGL context QFlags QFlags(0x1|0x2|0x4|0x8|0x10|0x20|0x40|0x1000|0x2000|0x4000|0x8000)
            @

            So, the flag 0x8000 which stands for opengl 3.3, show that openGL 3.3 is supported.
            But line 18 returns :
            @
            OpenGL context QGLFormat(options QFlags(0x1|0x2|0x4|0x20|0x80|0x200|0x400) , plane 0 , depthBufferSize -1 , accumBufferSize -1 , stencilBufferSize -1 , redBufferSize -1 , greenBufferSize -1 , blueBufferSize -1 , alphaBufferSize -1 , samples -1 , swapInterval -1 , majorVersion 3 , minorVersion 3 , profile 1 )
            @
            Here, the flag 0x8000 has disappeared. Yet, the openGL major and minor version is still 3.3 ...

            And finally, once the QGLWidget has been instanciated, line 24 returns :
            @
            OpenGL context QGLFormat(options QFlags(0x1|0x2|0x4|0x10|0x20|0x80|0x200|0x400) , plane 0 , depthBufferSize 24 , accumBufferSize 16 , stencilBufferSize 8 , redBufferSize 8 , greenBufferSize 8 , blueBufferSize 8 , alphaBufferSize -1 , samples 4 , swapInterval 0 , majorVersion 3 , minorVersion 3 , profile 1 )
            @

            I tried on line 26 to display one more information but it returns "0x0", I don't know why.

            Could someone help me to identify what's wrong ?

            Thanks

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tilsitt
              wrote on 15 Oct 2013, 10:47 last edited by
              #6

              Hi,

              You should call the show() method before calling glGetString(). Before show(), despite you called the constructor, initializeGL() should'nt have been called and your OpenGL context will not be initialized. I think that is why glGetString() is returning NULL (and it is returning a GLubyte*: you should cast it into a char* to display it with qDebug())..

              1 Reply Last reply
              0
              • M Offline
                M Offline
                milsabor
                wrote on 15 Oct 2013, 12:21 last edited by
                #7

                Oh yes thanks !
                So, I called glGetString after the call of show() and it returns this :

                "3.3.0 NVIDIA 304.88"

                So it should be okay, it proves that opengl3.3 is supported right, so why is it not working ?

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 15 Oct 2013, 19:53 last edited by
                  #8

                  Just to be sure, you are not having any warning shown on the console when running the application ?

                  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
                  • M Offline
                    M Offline
                    milsabor
                    wrote on 15 Oct 2013, 20:52 last edited by
                    #9

                    Nope, no warnings at all ...

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 28 Oct 2013, 21:48 last edited by
                      #10

                      Just thought about something, did you try to run another OpenGL example/demo from Qt's sources, just to be sure they are doing fine

                      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
                      • T Offline
                        T Offline
                        TheMindWithin
                        wrote on 14 Nov 2013, 21:30 last edited by
                        #11

                        Very same problem here, working on OS X 10.9 with Qt 5.1.1. Has a solution been found so far?

                        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