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. QOpenGLContext on Mac OS X

QOpenGLContext on Mac OS X

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.6k 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.
  • U Offline
    U Offline
    user2970139
    wrote on last edited by
    #1

    Hi,

    System: OS X 10.9, Qt 5.2.1 (installed view homebrew), Graphics: nvidia GTX 750M, Intel Iris Pro

    I am new to OpenGL and Qt. For the last days I played with various examples, primarily using QGLWidget. I wanted to use the modern QOpenGLContext and tried this example here: http://qt-project.org/doc/qt-5.0/qtgui/openglwindow.html

    When I change the following two lines:

    @QSurfaceFormat format;
    format.setSamples(4);@

    to:

    @QSurfaceFormat format;
    format.setDepthBufferSize( 24 );
    format.setMajorVersion( 4 );
    format.setMinorVersion( 3 );
    format.setSamples( 4 );
    format.setProfile( QSurfaceFormat::CoreProfile );
    format.setOption( QSurfaceFormat::DebugContext );@

    The screen is black, no matter which version combination I use. The reason is I wanted to use some features of newer GLSL standards.

    What am I doing wrong or missing?

    Thanks a lot in advance!

    1 Reply Last reply
    0
    • U Offline
      U Offline
      user2970139
      wrote on last edited by
      #2

      I figured out that for newer OpenGL versions, one must use VertexArrayObjects, otherwise it does not work. That fixed the problem.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        drhalftone
        wrote on last edited by
        #3

        I'm just getting started myself, and I found the following code extremely useful. Just copy it into your initializeGL function before you do anything else.

        @ // get context opengl-version
        qDebug() << "Widget OpenGl: " << format().majorVersion() << "." << format().minorVersion();
        qDebug() << "Context valid: " << context()->isValid();
        qDebug() << "Really used OpenGl: " << context()->format().majorVersion() << "." << context()->format().minorVersion();
        qDebug() << "OpenGl information: VENDOR: " << (const char*)glGetString(GL_VENDOR);
        qDebug() << " RENDERDER: " << (const char*)glGetString(GL_RENDERER);
        qDebug() << " VERSION: " << (const char*)glGetString(GL_VERSION);
        qDebug() << " GLSL VERSION: " << (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
        @

        This is what you will see in the application output:
        @Widget OpenGl: 4 . 1
        Context valid: true
        Really used OpenGl: 4 . 1
        OpenGl information: VENDOR: ATI Technologies Inc.
        RENDERDER: AMD Radeon HD - FirePro D300 OpenGL Engine
        VERSION: 4.1 ATI-1.16.39
        GLSL VERSION: 4.10
        @

        1 Reply Last reply
        0
        • U Offline
          U Offline
          user2970139
          wrote on last edited by
          #4

          That's nice of you, thanks a lot for sharing this snippet!

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            ZapB
            wrote on last edited by
            #5

            Right, as you found, a core profile context requires a vertex array object to be bound. The easy way to port from legacy OpenGKL is to simply create and bind a VAO up front and then forget about it.

            Nokia Certified Qt Specialist
            Interested in hearing about Qt related work

            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