OpenGL Version Support on OS X

I try to code an OpenGL project with Qt (v5.1.1) on OS X 10.9, in the manner of the modern pipeline implementation. However I encounter some problems to rebuild programs from tutorials as eg http://qt-project.org/wiki/How_to_use_OpenGL_Core_Profile_with_Qt

The simple triangle does not show up, however there are no warnings and the program itself shows up. I suspected that my mac might not support the GLSL. So I looked for a way to print some information. I found someone with a similar problem who did it like this.

#include <QApplication>
#include <QGLFormat>
#include "glwidget.h"

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

    QGLFormat mGlFormat;
    mGlFormat.setVersion(3, 3);
    mGlFormat.setProfile(QGLFormat::CoreProfile);
    mGlFormat.setSampleBuffers(true);

    qDebug() << "OpenGL context QFlags " << mGlFormat.openGLVersionFlags();
    qDebug() << "OpenGL context " << mGlFormat;

    GLWidget mWidget(mGlFormat);
    mWidget.show();

    qDebug() << "OpenGL context" << mWidget.format();
    qDebug() << "Driver Version String:" << glGetString(GL_VERSION);

    return mApplication.exec();
}

And I got as a result.

OpenGL context QFlags QFlags(0x1|0x2|0x4|0x8|0x10|0x20|0x40|0x1000|0x2000|0x4000|0x8000)

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 )

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 4 , swapInterval -1 , majorVersion 3 , minorVersion 3 , profile 1 )

Driver Version String: 0x10800e6be

Even though I am not sure about the exact meaning of this, derived from what was written at the source of this idea, it seems that the 0x8000 meant that OpenGL 3.3 is first supported but since later flags are only 0x400 the version support is lost somehow along the way.

My graphic card is NVIDIA GeForce 9400M 256 MB which should support OpenGL 3.3. https://developer.apple.com/graphicsimaging/opengl/capabilities/

  • Does that mean I am not able to use the GLSL under these configurations?
  • If so, is it possible to upgrade some library or graphics driver?
  • What happens to applications using the core profile when started on a computer that does not support the very same?
  • Similar post Can't set desired OpenGL version in QGLWidget


    It seems I was not the only one struggling with this tutorial, and I found the solution here. Even though it is mentioned the source code of the tutorial is missing to bind the VAO.

    Add this in initializeGL before m_shader.setAttributeBuffer:

    uint vao;
    
    typedef void (APIENTRY *_glGenVertexArrays) (GLsizei, GLuint*);
    typedef void (APIENTRY *_glBindVertexArray) (GLuint);
    
    _glGenVertexArrays glGenVertexArrays;
    _glBindVertexArray glBindVertexArray;
    
    glGenVertexArrays = (_glGenVertexArrays) QGLWidget::context()->getProcAddress("glGenVertexArrays");
    glBindVertexArray = (_glBindVertexArray) QGLWidget::context()->getProcAddress("glBindVertexArray");
    
    glGenVertexArrays(1, &vao);
    glBindVertexArray(vao);
    
    链接地址: http://www.djcxy.com/p/6554.html

    上一篇: 计算机视觉算法的CUDA性能

    下一篇: OS X上的OpenGL版本支持