PDA

View Full Version : OpenGL + QSurfaceFormat (set opengl 3+ version) + QPainter = crash



avis_phoenix
6th July 2014, 02:48
Hi!

I'm learning to use OpenGL 3.2 in Qt5, I understand that you want to use version 3.2 must use QSurfaceFormat follows:


QSurfaceFormat format;
format.setVersion(3, 2);
format.setProfile(QSurfaceFormat::CompatibilityPro file);


But if I set a version 3.0 and up, when I use QPainter to draw information in the screen, crash my program, with this error message:


QOpenGLShader::compile(Vertex): Vertex shader failed to compile with the following errors:
ERROR: error(#272) Implicit version number 110 not supported by GL3 forward compatible context
ERROR: error(#273) 1 compilation errors. No code generated


Obviously this is because GLSL 1.10 is only supports by OpenGL 2.0, and I need use GLSL 1.50 for OpenGL 3.2, and for OpenGL 4 GLSL 4, but I don't know how to specify this, because is an internal code for QPainter.

Anyone can help me?

I use:

Qt 5.2.1 and Qt 5.3.0
Windows 8.1 64 bits and Linux 64 bits(Ubuntu 14.04, with online installation, not from repositories)
AMD Radeon HD 7700 Series
Version of Catalyst 14.4

dabu
14th October 2014, 16:10
Hi,
I got more or less the same problem:

In my case the crash occurs when using a QGLWidget:
- set version 3.2 in the format
- use the CoreProfile
- open a QPainter with the QGLWidget as a paintDevice

At the moment you create the QPainter, it gives the same error as above...
By setting the CoreProfile I am able to use OpenGL 3.2 (printing out the version of QGLWidget::format() in the paint function, I get 3.2)
But I think the QPainter is still using some of the older API's which are not available any more in the CoreProfile.
The shaders which are mentioned in the errors are not mine (I don't even use any shaders of my own)


QGLShader::compile(Vertex): ERROR: 0:1: '' : #version required and missing.
ERROR: 0:11: 'attribute' : syntax error syntax error

Vertex shader for simpleShaderProg (MainVertexShader & PositionOnlyVertexShader) failed to compile
QGLShader::compile(Fragment): ERROR: 0:1: '' : #version required and missing.

Fragment shader for simpleShaderProg (MainFragmentShader & ShockingPinkSrcFragmentShader) failed to compile
QGLShader::link: "ERROR: One or more attached shaders not successfully compiled
"
Errors linking simple shader: ERROR: One or more attached shaders not successfully compiled

QGLShader::compile(Vertex): ERROR: 0:1: '' : #version required and missing.
ERROR: 0:5: 'attribute' : syntax error syntax error

Vertex shader for blitShaderProg (MainWithTexCoordsVertexShader & UntransformedPositionVertexShader) failed to compile
QGLShader::compile(Fragment): ERROR: 0:1: '' : #version required and missing.
ERROR: 0:11: 'varying' : syntax error syntax error

Fragment shader for blitShaderProg (MainFragmentShader & ImageSrcFragmentShader) failed to compile
QGLShader::link: "ERROR: One or more attached shaders not successfully compiled
"
Errors linking blit shader: ERROR: One or more attached shaders not successfully compiled

Hopefully someone can help us with this extra information,
kr,
dabu

I use:
Qt 5.3
OS: Mac OSX 10.8.5
GPU: AMD Radeon HD 6750M 512 MB

sampad1370
5th July 2017, 13:28
hi @dabu and @avis_phoenix
@avis_phoenix according to say of @dabu you can fix your this error but if you test, I interested to know result.
and @dabu, please explain your problem more!
Are you set your version of shader?