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 OS-X Lion 2.1 vs 3.2 context
QtWS25 Last Chance

OpenGL OS-X Lion 2.1 vs 3.2 context

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 4.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.
  • P Offline
    P Offline
    piercer
    wrote on last edited by
    #1

    Hi -

    I've been developing a cross-platform rendering engine that once complete will serve as the basis for physics simulations. Up until this week I've been targeting Windows using Qt 4.8RC using the msvc2010 toolchain w/ CDB. I have access now to a Macbook w/ a 9400m Nvidia card that shows it will support OpenGL 3.2 w/ GLSL 1.5 (using 10.7.2).

    After downloading and installing Xcode and Qt 4.8 (I use Creator as my IDE) I've compiled my code but can't seem to get a 3.2 context setup, which seems should be straightforward using the following code snippet I have in main.cpp, before the window is created.
    @
    QGLFormat glwformat;
    glwformat.setVersion( 3, 2 );
    glwformat.setProfile( QGLFormat::CoreProfile );
    QGLFormat::setDefaultFormat(glwformat);@

    But when the GLWidget is created it reports a v2.1 context and tells me that my v1.5 shaders are not compatible (makes sense given 2.1 compatibility context). Is this a bug or some other implementation issue? I went w/ 4.8 because it appears 3.2/GLSL1.5 is supported but I can't figure out how to get it to work. I can create a 3.2 context not using Qt so I'm wondering if it is something in the initialization.

    Any help appreciated.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris H
      wrote on last edited by
      #2

      Have you checked the output of the @QGLFormat::openGLVersionFlags ()@ static function to make sure it thinks 3.2 is OK?

      1 Reply Last reply
      0
      • P Offline
        P Offline
        piercer
        wrote on last edited by
        #3

        The following outputs that 3.2 isn't supported:

        [code]
        if((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_3_2) == 0)
        {
        TRACE("GL 3.2 Not supported");
        }
        [/code]

        BUT if I compile the following example code from Apple it will run and as you can see below it's using OpenGL 3.2, so it is accessible/available.

        http://developer.apple.com/library/mac/#samplecode/GLEssentials/Introduction/Intro.html
        [Switching to process 7647 thread 0x0]
        2011-12-28 20:05:29.590 MacGLEssentials[7647:407] NVIDIA GeForce 9400M OpenGL Engine 3.2 NVIDIA-7.12.9

        Even though I don't program in Objective-C, here is the code snippet that seems to properly initialize the context, it seems the 3.2 profile must be requested directly. Wondering if somewhere under the hood of Qt this isn't happening.

        [code]
        NSOpenGLPixelFormatAttribute attrs[] =
        {
        NSOpenGLPFADoubleBuffer,
        NSOpenGLPFADepthSize, 24,
        // Must specify the 3.2 Core Profile to use OpenGL 3.2
        #if ESSENTIAL_GL_PRACTICES_SUPPORT_GL3
        NSOpenGLPFAOpenGLProfile,
        NSOpenGLProfileVersion3_2Core,
        #endif
        0
        };

        NSOpenGLPixelFormat *pf = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];
        [/code]

        1 Reply Last reply
        0
        • P Offline
          P Offline
          piercer
          wrote on last edited by
          #4

          I did a scan of qgl_mac.mm and it doesn't show any reference to NSOpenGLPFAOpenGLProfle or NSOpenGLProfileVersion3_2Core. From the mac excerpt it seems these need to be explicitly called to get a GL 3.2 context.

          1 Reply Last reply
          0
          • P Offline
            P Offline
            piercer
            wrote on last edited by
            #5

            So last night I downloaded the source for Qt4.8, configured and built it then I modified the qgl_mac.mm file at line 431 I added the following lines:

            @ attribs[cnt++] = NSOpenGLPFAOpenGLProfile;
            attribs[cnt++] = NSOpenGLProfileVersion3_2Core;
            @

            Rebuilt and installed. With this modification I get OpenGL 3.2 and GLSL 1.5 working on my Macbook under Lion 10.7.2 - I found no other references to the above attributes in the Qt code so I'm guessing these have been mistakenly skipped? Do I submit this as a bug?

            1 Reply Last reply
            0
            • C Offline
              C Offline
              Chris H
              wrote on last edited by
              #6

              Can't hurt: if they were skipped for a reason they'll just close out the bug, no harm done.

              1 Reply Last reply
              0
              • P Offline
                P Offline
                piercer
                wrote on last edited by
                #7

                Oopppssss... Ok, so it does initialize and load the Core profile for 3.2 and it will accept my shaders, but now that I've gone to render some things nothing is showing. Seems I will need to dig a bit deeper... gah

                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