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 3.2 core profile, QT 4.8 RC1 not working on Windows and Mac
QtWS25 Last Chance

OpenGL 3.2 core profile, QT 4.8 RC1 not working on Windows and Mac

Scheduled Pinned Locked Moved General and Desktop
21 Posts 8 Posters 14.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.
  • N Offline
    N Offline
    number23
    wrote on 26 Oct 2011, 09:49 last edited by
    #1

    I followed ZapB's "article":http://developer.qt.nokia.com/wiki/How_to_use_OpenGL_Core_Profile_with_Qt but I’m running into problems in creating an OpenGL 3.2 core profile context on both Windows and Mac Lion using the Qt 4.8 RC 1 from 13th Oct.

    On Windows 7 64bit I get a buffer overflow during the QGLExtensionMatcher … the 2nd time “m_offsets << m_extensions.size();” is called to be exact.

    On Mac there is no OpenGL 3.2 context created. glFormat.majorVersion() << “.” << glFormat.minorVersion() gives me 2.1 (using this->format() inside a QGLWidget).
    There was another "thread":http://developer.qt.nokia.com/forums/viewthread/8047 that created OpenGL 3.2 context using some Cocoa code on mac which I’ve tried that actually created the correct context but it isn’t recognized by Qt so I cant load a shader as it assumes I have a 2.1 context (Same version info from Qt while OpenGL tells me it’s 3.2). This means that it uses a pre-OpenGL-3 extension checker which leads to calling depracated functions and eventually failing to support any Shader.

    Is it just me? I’m trying this on 2 different machines btw. Any help is appreciated.

    1 Reply Last reply
    0
    • N Offline
      N Offline
      number23
      wrote on 27 Oct 2011, 09:04 last edited by
      #2

      I rewrote the QGLShaderProgram, copied over the main functions and removed the extension-checking. The shader is loading/compiling/linking fine now on both platforms, no error here.

      The windows variant still produces a buffer overflow but in an untrackable area - somewhere in the mainloop (between initializeGL and paintGL).

      The mac version (using the mentioned Cocoa context creation) creates a window with just the background color and no triangle. It is the same program (openGL-wise) as in the article.

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        ZapB
        wrote on 27 Oct 2011, 10:03 last edited by
        #3

        Hmmm, OK. I need to try this on Windows yet. Unfortunately I do not have access to any Macs on which to test.

        I'll take a look on windows when I get caught up from my DevDays backlog ;-)

        Nokia Certified Qt Specialist
        Interested in hearing about Qt related work

        1 Reply Last reply
        0
        • N Offline
          N Offline
          number23
          wrote on 27 Oct 2011, 11:35 last edited by
          #4

          the windows buffer-overflow problem even occurs when there's no actual OpenGL code inside the widget.

          Another Windows OpenGL 3.2 "example":http://sites.google.com/site/opengltutorialsbyaks/introduction-to-opengl-3-2---tutorial-01 works fine with nvidia driver 275.

          1 Reply Last reply
          0
          • R Offline
            R Offline
            rcari
            wrote on 27 Oct 2011, 13:17 last edited by
            #5

            The GL support on Mac OS X is rather poor and I haven't seen a Mac offering anything better than a 2.1 version of OpenGL. However you will find many of the new(er) GPU features exposed through the GL extensions system. I haven't tried OS X Lion but on 10.5 and 10.6 I have never been able to get a Core GL profile running.

            1 Reply Last reply
            0
            • N Offline
              N Offline
              number23
              wrote on 27 Oct 2011, 13:29 last edited by
              #6

              Macs pre lion can only do max. Opengl 2.1
              Lion is the first to do either 2.1 or 3.2 core (at least thats how i understood it).

              1 Reply Last reply
              0
              • R Offline
                R Offline
                rcari
                wrote on 27 Oct 2011, 13:32 last edited by
                #7

                Did you check that your hardware actually supports it ?
                Run glxinfo on the command line to get your GL implementation version.

                1 Reply Last reply
                0
                • N Offline
                  N Offline
                  number23
                  wrote on 27 Oct 2011, 13:38 last edited by
                  #8

                  I ran the opengl extension checker...
                  The hardware is a nvidia gtx 260 on windows and an ati 6970m hd on the current line imac. Both can do at least 3.2

                  I was able to create a 3.2 core context without qt

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    Bobby B
                    wrote on 15 Nov 2011, 15:28 last edited by
                    #9

                    Apologies for bumping an old post, but I am also experiencing this problem.

                    I have Qt 4.8.0 RC installed and I am using a brand new Macbook Pro with OSX Lion which does have support for OpenGL 3.2 as seen on the "OpenGL capabilities table for Mac OSX Lion":http://developer.apple.com/graphicsimaging/opengl/capabilities/GLInfo_1072_Core.html.

                    I have tried to run the example written by ZapB and only changed the GLSL version to #150 and the errors are saying
                    @
                    QGLShader::compile(Vertex): ERROR: 0:1: '' : version '150' is not supported

                    "ERROR: 0:1: '' : version '150' is not supported
                    "
                    QGLShader::compile(Fragment): ERROR: 0:1: '' : version '150' is not supported

                    "ERROR: 0:1: '' : version '150' is not supported
                    "
                    @
                    which simply is not true.

                    I would be interested to know if there are any others who could reproduce this problem Mac and I would be most grateful for anyone who knows of a solution to this problem.

                    1 Reply Last reply
                    0
                    • N Offline
                      N Offline
                      number23
                      wrote on 15 Nov 2011, 15:50 last edited by
                      #10

                      If u read out the OpenGL version you'll see the problem: I'm quite sure it'll be OpenGL 2.1 which doesn't support GLSL 1.5 - the error message is true in that way;)
                      I fiddled around with the problem for some time but I wasn't able to create an OpenGL 3.2 Context in the QGLWidget.

                      Here's my "solution":
                      I wrote my own GLWidget, based on a QMacCocoaViewContainer. It contains a NSOpenGLView in which I create the 3.2 core profile context. The main access methods/callbacks are wrapped outside so it behaves pretty much like the QGLWidget - at least the functions I need (paint, resize, key/mouse events, initialize) are "forewarded".
                      As the QGLShaderProgram uses Qt-internal version-testing methods to call the right functions for either OpenGL3 or OpenGL2, I also had to write my own implementation just for OpenGL3. The original class detected OpenGL 2.1 and made some wrong calls...

                      All in all it was quite some work, but it's running quite nicely with OpenGL 3.2 context and GLSL 150 core shader. If the "real" QGLWidget gets fixed I should be able to just replace it and the ShaderProgram class.

                      Sidenote:
                      I found out that nvidia drivers behave quite differently and allow a lot of calls that are outside the OpenGL spec (running OpenGL 4.1 introduced functions inside an OpenGL 3.2 core context, allowing GLSL-functions that are deprecated, etc. ). I'd be intersting to know if anyone with a nvidia gfx and OSX Lion has problems with the QGLWidget and OpenGL 3.2...

                      1 Reply Last reply
                      0
                      • B Offline
                        B Offline
                        Bobby B
                        wrote on 15 Nov 2011, 16:07 last edited by
                        #11

                        Thanks for the reply. I see that you've put in quite a lot of effort to work around this problem. I too hope that this problem will be fixed soon. In the mean time I'll try implementing your method, or at least just stick with Windows for just a while longer.

                        1 Reply Last reply
                        0
                        • Z Offline
                          Z Offline
                          ZapB
                          wrote on 14 Jan 2012, 15:11 last edited by
                          #12

                          Sorry to necropost. I am now able to reproduce the buffer overflow as mentioned by the OP. I have made a non-Qt windows OpenGL app that acquires an OpenGL 4.2 core profile context which works fine. So it appears that something is going wrong in the Qt context creation code.

                          Is anybody able to reproduce this on an ATI card on windows? Although I suspect it is not a driver issue but just something else to rule out.

                          I have stepped through the Qt OpenGL context creation code and from what I can see so far all appears to be fine. It creates a temporary context, resolves some function entry points, then creates a core profile context using the same options as my non-Qt app. Yes when it comes to call glGetStringi( GL_EXTENSIONS, i ); it seems that some sort of stack corruption is occurring as the debugger shows the value of "this" changing each time this function is called.

                          I'll keep digging but if I can't resolve it soon I'll file a bug report.

                          Nokia Certified Qt Specialist
                          Interested in hearing about Qt related work

                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            Mike Dinsdale
                            wrote on 16 Feb 2012, 00:01 last edited by
                            #13

                            I think I've also run into the buffer overflow (or at least stack corruption of some kind) in the call to glGetStringi. I suspect "this":http://developer.qt.nokia.com/forums/viewthread/4495/P15 is the same issue as well. Actually exactly the same problem was discussed in comments on the bug report which originally introduced this code, "QTBUG-11052":https://bugreports.qt-project.org/browse/QTBUG-11052. The fix was to add the missing APIENTRY macro to the qt_glGetStringi function pointer typedef (it makes sense that leaving this off would lead to stack corruption). However the APIENTRY wasn't included in the version of the code that was eventually commited in commit 2f59eaee. I've verified that adding the APIENTRY does fix the problem for me, but perhaps it causes problems on some platforms? (I'm on Win 7 64-bit with a GT545).

                            1 Reply Last reply
                            0
                            • Z Offline
                              Z Offline
                              ZapB
                              wrote on 16 Feb 2012, 01:59 last edited by
                              #14

                              Well spotted! Thanks for the tip. I am on the road at the moment but will try this fix when I return home at the weekend. I'll post back here with the results. Thanks again!

                              Nokia Certified Qt Specialist
                              Interested in hearing about Qt related work

                              1 Reply Last reply
                              0
                              • Z Offline
                                Z Offline
                                ZapB
                                wrote on 28 Feb 2012, 08:20 last edited by
                                #15

                                The "fix for this":http://codereview.qt-project.org/#change,16794 has been merged into Qt5 now. Next up I will cherry pick it for Qt 4.8 later today.

                                Nokia Certified Qt Specialist
                                Interested in hearing about Qt related work

                                1 Reply Last reply
                                0
                                • A Offline
                                  A Offline
                                  andre
                                  wrote on 28 Feb 2012, 09:08 last edited by
                                  #16

                                  Was Mac giving you troubles? ;-)

                                  1 Reply Last reply
                                  0
                                  • Z Offline
                                    Z Offline
                                    ZapB
                                    wrote on 28 Feb 2012, 09:13 last edited by
                                    #17

                                    Yeah. The way that APIENTRY macro is brought into play is slightly different in Qt5 and I never tried building it on Mac myself before my first attempt. My bad as I do actually have a MacBook now.

                                    /me must try harder ;-)

                                    Nokia Certified Qt Specialist
                                    Interested in hearing about Qt related work

                                    1 Reply Last reply
                                    0
                                    • M Offline
                                      M Offline
                                      mightcouldb1
                                      wrote on 5 Mar 2012, 05:04 last edited by
                                      #18

                                      Hi ZapB,
                                      I am experiencing similar problems when trying to use the 3.2 core profile and GLSL 1.5 on Mac OSX Lion. How can I obtain the fix that you posted above(http://codereview.qt-project.org/#change,16794)? Is this Windows specific?

                                      Will I have to wait for the release of Qt 5 or a patch for 4.8?

                                      Thanks in advance,
                                      Jason

                                      1 Reply Last reply
                                      0
                                      • Z Offline
                                        Z Offline
                                        ZapB
                                        wrote on 5 Mar 2012, 08:39 last edited by
                                        #19

                                        Hi Jason,

                                        that particular fix was to fix a stack corruption on Windows. My next task is to fix the OpenGL context creation code for Mac and Windows to actually allow use of a Core profile context - it works fine on Linux. I'll post back here when I have something usable but it may take me a few days as I am away on a course most of this week.

                                        Nokia Certified Qt Specialist
                                        Interested in hearing about Qt related work

                                        1 Reply Last reply
                                        0
                                        • S Offline
                                          S Offline
                                          shucre
                                          wrote on 28 Apr 2012, 00:56 last edited by
                                          #20

                                          Hi ZapB,

                                          Are we getting any closed to this fix (use of a Core profile context in Mac) or has it been postponed further?

                                          Thanks in advance,
                                          Shucre

                                          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