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. how to create 4.0 opengl context with qt 5?
Forum Updated to NodeBB v4.3 + New Features

how to create 4.0 opengl context with qt 5?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.1k Views 2 Watching
  • 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.
  • B Offline
    B Offline
    billconan
    wrote on last edited by
    #1

    I need an example of creating opengl 4.0 context with qt 5.5.

    I tried this code before creating any window:

    QSurfaceFormat format;
      format.setMajorVersion( 3 );
      format.setMinorVersion( 2 );
      format.setProfile( QSurfaceFormat::CoreProfile );
    

    QSurfaceFormat::setDefaultFormat(format);

    and it crashes my program.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      billconan
      wrote on last edited by
      #2

      I checked the opengl version flag, for some reason, the highest version number is 2.1

      OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags();
      if(flags & QGLFormat::OpenGL_Version_1_5) qDebug() << "1.5 or higher";
      if(flags & QGLFormat::OpenGL_Version_2_0) qDebug() << "2.0 or higher";

      QFlags(0x1|0x2|0x4|0x8|0x10|0x20|0x40)

      1 Reply Last reply
      0
      • B Offline
        B Offline
        billconan
        wrote on last edited by
        #3

        the issue I had seems to be a Qt bug.

        we requested shared opengl context, and for some reason, Qt doesn't want to create 4.1 context

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You'll need to provide a lot more information if you want anything more than wild guesses.

          What platform are you on - OS, compiler, OpenGL Desktop/ES/Angle?
          What graphics card do you have? Are drivers up to date? Does it support the profile you want (have you confirmed it otherwise)?
          QGLFormat is obsolete. Are you mixing QGL* with QOpenGL* ?
          Where do you check the flags? Is a context made current at that point?
          How do you create your context?
          What code exactly crashes and are you sure it's not your code?
          If the code that crashes is not yours are you sure you're not trying to use OpenGL functions from a context that doesn't support them (e.g. lower version/profile)?

          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