OpenGL OS-X Lion 2.1 vs 3.2 context



  • 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.



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



  • 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]



  • 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.



  • 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?



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



  • 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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.