how to create 4.0 opengl context with qt 5?
-
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.
-
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)
-
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)?